Skip to main content

Posts

Showing posts from September, 2015

Hidden Surface Removal

Look at the scratch code " RotatingSolidCube.cpp " and s tudy it carefully #include #include #include #include typedef struct{float x;float y;}Point2D; float dx = 200, dy = 200, dz = 200; GLfloat n[6][3]; /* Normals for the 6 faces of a cube. */ /* Vertex indices for the 6 faces of a cube. */ GLint faces[6][4] = { //traversed in counterclockwise direction as seen from outside {0, 1, 2, 3}, {3, 2, 6, 7}, {7, 6, 5, 4}, {4, 5, 1, 0}, {5, 6, 2, 1}, {7, 4, 0, 3} }; GLfloat v[8][3]; /* Will be filled in with X,Y,Z vertexes. */ void init(void) { /* Setup cube vertex data. */         v[0][0] =100; v[0][1] = 100; v[0][2] = 300;           v[1][0] =300; v[1][1] = 100; v[1][2] = 300;         v[2][0] =300; v[2][1] = 300; v[2][2] = 300;         v[3][0] =100; v[3][1] = 300; v[3][2] = 300;         v[4][0] =100; v[4][1] = 100; v[4][2] = 100;         v[5][0] =300; v[5][1] = 100; v[5][2] = 100;         v[6][0] =300; v[6][1] = 300; v[6][2] = 100;         v[7][0] =10