1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
int w, h; GetClientSize(&w, &h);
glDepthFunc (GL_LESS); // The Type Of Depth Test To Do
glDepthMask (GL_TRUE);
glEnable (GL_DEPTH_TEST);
glBindFramebuffer(GL_FRAMEBUFFER, FBO);
glClearColor (1, 1, 1, 1);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode (GL_MODELVIEW); glLoadIdentity();
gluPerspective (45.0, (float)w / (float)h, 1.0, 100.0);
glPushMatrix ();
glTranslatef (-2.0f, 0, -18.0f);
glRotatef (-RotX, 0.0, 1.0, 0.0);
glRotatef (RotY, 1.0, 0.0, 0.0);
glBindTexture (GL_TEXTURE_2D, texture[1]);
glBegin(GL_QUADS);
[...RENDER CUBE TO TEXTURE...]
glEnd();
glPopMatrix();
glFlush(); // Flush the GL Pipeline
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glActiveTexture(GL_TEXTURE0);
glViewport (0, 0, w, h);
glClearColor(0, 0, 0, 1);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode (GL_MODELVIEW); glLoadIdentity();
gluPerspective (45.0, (float)w / (float)h, 1.0, 100.0);
//glPushMatrix();
glTranslated (0.0, 0.0, Depth);
glRotatef (RotY, 0.0, 1.0, 0.0);
glRotatef (RotX, 1.0, 0.0, 0.0);
glBindTexture (GL_TEXTURE_2D, texture[0]);
glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, 0);
glBegin(GL_QUADS);
[...RENDER CUBE TO OUTPUT...]
glEnd();
glFlush(); // Flush the GL Pipeline
SwapBuffers(); // Swap Buffers
|