Lecture 16: slide

# Interactive Computer Graphics: A Top-Down Approach Using OpenGL (4th Edition)

• Notes
• davidvictor
• 4

This preview shows pages 1–3. Sign up to view the full content.

1 ECE/CS 433 Introduction to Computer Graphics Pradeep Sen Advanced Graphics Lab Class 16 October 16, 2007 ECE/CS 433 Introduction to Computer Graphics Pradeep Sen Class 16 – October 16, 2007 Announcements Quick review of exam Go over hw3 ECE/CS 433 Introduction to Computer Graphics Pradeep Sen Class 16 – October 16, 2007 Rasterization Conversion from floating point screen space coordinates into integer pixel coordinates on the screen ECE/CS 433 Introduction to Computer Graphics Pradeep Sen Class 16 – October 16, 2007 Bounding box algorithm void rasterizeTriangle(void) { for (y = y_min; y < y_max; y++) { for (x = x_min; x < x_max; x++) { if insideTriangle(x,y) { generateFragment(x,y); } } } } box y_min y_max x_min x_max ECE/CS 433 Introduction to Computer Graphics Pradeep Sen Class 16 – October 16, 2007 Inside tests v0 v1 v2 ECE/CS 433 Introduction to Computer Graphics Pradeep Sen Class 16 – October 16, 2007 Inside tests void lineEquation(float *v0, float *v1, float *f){ crossProduct(v1, v0, f); } bool insideTriangle(int x,y) { lineEquation(v0, v1, &f0); lineEquation(v1, v2, &f1); lineEquation(v2, v0, &f2); Pt p(x,y,1); if ((dotProduct(p, f0) > 0) && (dotProduct(p, f1) > 0) && (dotProduct(p, f2) > 0) { // inside the triangle return true; } return false; }

This preview has intentionally blurred sections. Sign up to view the full version.