OpenGL相关

参考资料
OpenGL架构的介绍
Shadow Map 介绍
OpenGL tutorials
ProjectionMatrix
Left hand & Right hand
GPU Image Processing
GPU JPEG
Ant Colony
The paper introduce a data drived design which can produce simpler an efficient code. C++ is not cache friendly, so performance issue occurs when applying c++ to graphic programming. The paper can be referenced here. paper
optimize example tell you how to optimize your program.
square root how to calculate square root.
game related
black book
obfuscated
code complete
hack delight
build a compiler

drawing lines

My implementation for bresenham algorithms

// draw positive slope lines
242 void SoftwareRendererImp::rasterize_line1( int x0, int y0,
243                                            int x1, int y1,
244                                           Color color) 
245 {
246         int dx = x1 -x0, dy = y1 -y0;
247         int x = x0, y = y0, eps = 0;
248         if (dy <= dx)
249         {
250             for (; x <= x1; ++x)
251             {
252                     rasterize_point(x, y, color);
253                     eps += dy;
254                     if ((eps << 1) > dx)
255                     {
256                             ++y; eps -= dx;
257                     }
258             }
259         }
260         else
261         {
262             for (; y <= y1; ++y)
263             {
264                 rasterize_point(x, y, color);
265                 eps += dx;
266                 if ((eps << 1) > dy)
267                 {
268                     ++x; eps -=dy;
269                 }
270             }
271         }
272 }
// draw nagetive slope line
275 void SoftwareRendererImp::rasterize_line2( int x0, int y0,
276                                           int x1, int y1,
277                                           Color color) 
278 {
279 
280         int dx = x1 -x0, dy = y1 -y0;
281         int x = x0, y = y0, eps = 0;
282         if (-dy <= dx)
283         {
284             for (; x <= x1; ++x)
285             {
286                     rasterize_point(x, y, color);
287                     eps -= dy;
288                     if ((eps << 1) > dx)
289                     {
290                         --y; eps -= dx;
291                     }
292             }
293         }
294         else
295         {
296             for (; y >=  y1; --y)
297             {
298                 rasterize_point(x, y, color);
299                 eps += dx;
300                 if ((eps << 1) > -dy)
301                 {
302                     ++x; eps +=dy;
303                 }
304             }
305         }
306 }
void SoftwareRendererImp::rasterize_line( float x0, float y0,
308                                           float x1, float y1,
309                                           Color color) 
310 {
311     int dx = x1 - x0, dy = y1 - y0;
312     if (dx >= 0 && dy >= 0)
313       rasterize_line1(x0, y0, x1, y1, color);
314     else if (dx < 0 && dy < 0)
315       rasterize_line1(x1, y1, x0, y0, color);
316     else if (dx >= 0 && dy <= 0)
317       rasterize_line2(x0, y0, x1, y1, color);
318     else if (dx < 0 && dy >= 0)
319       rasterize_line2(x1, y1, x0, y0, color);
325 }

drawing-line-using-bresenham-algorithm
bresenh
easyfilter
microsoft

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值