参考资料
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