From a94861b09ae9e7e8edce1eb518cb5e5f20e328a3 Mon Sep 17 00:00:00 2001 From: Wolfgang Draxinger Date: Thu, 31 Dec 2020 16:52:07 +0100 Subject: commit it --- test_copy_to_front.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 test_copy_to_front.c (limited to 'test_copy_to_front.c') diff --git a/test_copy_to_front.c b/test_copy_to_front.c new file mode 100644 index 0000000..3d69f81 --- /dev/null +++ b/test_copy_to_front.c @@ -0,0 +1,44 @@ +#include +#include +#include + +static void display(void) +{ + static float a = 0; + + int const win_w = glutGet(GLUT_WINDOW_WIDTH); + int const win_h = glutGet(GLUT_WINDOW_HEIGHT); + float const win_a = (float)win_w/(float)win_h; + + glDrawBuffer(GL_BACK); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glViewport(0, 0, win_w, win_h); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-win_a, win_a, -1, 1, 1, 5); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0,0,-3); + glRotatef( a = fmodf(a + 1, 360) , 0,1,0); + + glutWireTeapot(1); + + glFlush(); + glDrawBuffer(GL_FRONT); + glReadBuffer(GL_BACK); + glCopyPixels(0, 0, win_w, win_h, GL_COLOR); + glFinish(); +} + +int main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); + glutCreateWindow("Test copy back->front instead of buffer swap"); + glutDisplayFunc(display); + glutIdleFunc(glutPostRedisplay); + + glutMainLoop(); + return 0; +} -- cgit v1.2.3