Lecture 16: slide

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

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

View Full Document Right Arrow Icon
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; }
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 ECE/CS 433 Introduction to Computer Graphics Pradeep Sen Class 16 – October 16, 2007 Inside tests void rasterizeTriangle(void) {
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

Lecture 16: slide - Announcements ECE/CS 433 Introduction...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online