void display(void){ glClear(GL_COLOR_BUFFER_BIT); if(leftFirst){ drawLeftTriangle(); drawRightTriangle(); } else { drawRightTriangle(); drawLeftTriangle(); } glFlush(); }
void qblending::paintGL() { glClear(GL_COLOR_BUFFER_BIT); if (leftFirst) { drawLeftTriangle(); drawRightTriangle(); } else { drawRightTriangle(); drawLeftTriangle(); } glFlush(); }
void display(UGWindow uwin) { glClear(GL_COLOR_BUFFER_BIT); if (leftFirst) { drawLeftTriangle(); drawRightTriangle(); } else { drawRightTriangle(); drawLeftTriangle(); } glFlush(); ugSwapBuffers(uwin); }
void display(void) { printf("GL_CLEAR_DEPTH = %f GL_DEPTH_FUNC = %s\n", clearVal, funcs[curFunc].str); glClearDepth(clearVal); glDepthFunc(funcs[curFunc].func); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if (leftFirst) { drawLeftTriangle(); drawRightTriangle(); } else { drawRightTriangle(); drawLeftTriangle(); } glFlush(); }
void display(void) { glClear(GL_COLOR_BUFFER_BIT); glClearColor(0.5f, 0.5f, 0.5f, 1.0f); // Clear the background of our window to red if (rotateY){ rotateY = !rotateY; glRotatef(yRotationAngle, 0.0f, 1.0f, 0.0f); // Rotate our object around the y axis yRotationAngle += 0.05f; if (yRotationAngle > 360.0f) // If we have rotated beyond 360 degrees (a full rotation) yRotationAngle -= 360.0f; // Subtract 360 degrees off of our rotation } if (translateZ){ translateZ = !translateZ; glLoadIdentity(); // Load the Identity Matrix to reset our drawing locations glTranslatef(zLocation, 0.0f, 0.0f); // Translate our object along the y axis zLocation += 0.05f; if (zLocation > 1.0f){ // If we have rotated beyond 360 degrees (a full rotation) zLocation = 0.0f; glLoadIdentity(); // Load the Identity Matrix to reset our drawing locations glTranslatef(0.0f, 0.0f, 0.0f); // Translate our object along the y axis } } if (leftFirst) { drawLeftTriangle(); drawRightTriangle(); } else { drawRightTriangle(); drawLeftTriangle(); } glFlush(); }
/* Main triangle drawing function */ void endTriangle() { vertex* b; vertex* t; vertex* m; int flag = 0x0; /* bit flags for tests */ int A,B,C; /* implcit line coefficients */ /* First, figure out which vertex should be b (bottom vertex), t (top vertex) and m (middle vertex) */ if (v[0]->y < v[1]->y) flag = 0x1; flag <<= 1; /* shift over one bit */ if (v[1]->y < v[2]->y) flag |= 0x1; flag <<= 1; if (v[2]->y < v[0]->y) flag |= 0x1; switch (flag) { case 0x1: /* 001 */ t = v[0]; m = v[1]; b = v[2]; break; case 0x2: /* 010 */ m = v[0]; b = v[1]; t = v[2]; break; case 0x3: /* 011 */ t = v[0]; b = v[1]; m = v[2]; break; case 0x4: /* 100 */ b = v[0]; t = v[1]; m = v[2]; break; case 0x5: /* 101 */ m = v[0]; t = v[1]; b = v[2]; break; case 0x6: /* 110 */ b = v[0]; m = v[1]; t = v[2]; break; default: printf("Bad triangle! \n"); /* only gets here if all vertices equal */ return; } /* Now test to see if m is right or left of line bt */ /* Use implicit line equation */ A = b->y - t->y; B = t->x - b->x; C = b->x * t->y - t->x * b->y; if (A*m->x + B*m->y + C > 0) drawLeftTriangle(b,t,m); else drawRightTriangle(b,t,m); free(v[0]); free(v[1]); free(v[2]); }