aboutsummaryrefslogtreecommitdiff
path: root/test_copy_to_front.c
diff options
context:
space:
mode:
Diffstat (limited to 'test_copy_to_front.c')
-rw-r--r--test_copy_to_front.c44
1 files changed, 44 insertions, 0 deletions
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 <GL/glut.h>
+#include <GL/gl.h>
+#include <math.h>
+
+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;
+}