annotate test/testgl2.c @ 3107:3cf236d3cd81

Update README for QNX 6.x
author Mike Gorchak <lestat@i.com.ua>
date Fri, 24 Apr 2009 03:46:54 +0000
parents 82e60908fab1
children 7f684f249ec9
rev   line source
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 #include <stdlib.h>
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 #include <stdio.h>
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 #include <string.h>
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4 #include <math.h>
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
6 #include "common.h"
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 #ifdef __MACOS__
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9 #define HAVE_OPENGL
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 #endif
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 #ifdef HAVE_OPENGL
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14 #include "SDL_opengl.h"
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 /* Undefine this if you want a flat cube instead of a rainbow cube */
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 #define SHADED_CUBE
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
19 static CommonState *state;
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
20 static SDL_GLContext context;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
22 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
23 static void
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
24 quit(int rc)
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 {
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
26 if (context) {
2328
91e601d9df8b re: bug#563. checking in some commented out trace code and a fix so that the in testalpha.c the background only flashes when alpha == 255. The problem that is being
Bob Pendleton <bob@pendleton.com>
parents: 2232
diff changeset
27 /* SDL_GL_MakeCurrent(0, NULL); *//* doesn't do anything */
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
28 SDL_GL_DeleteContext(context);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 }
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
30 CommonQuit(state);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
31 exit(rc);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
34 static void
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
35 Render()
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 {
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
37 static float color[8][3] = {
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
38 {1.0, 1.0, 0.0},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
39 {1.0, 0.0, 0.0},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
40 {0.0, 0.0, 0.0},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
41 {0.0, 1.0, 0.0},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
42 {0.0, 1.0, 1.0},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
43 {1.0, 1.0, 1.0},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
44 {1.0, 0.0, 1.0},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
45 {0.0, 0.0, 1.0}
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
46 };
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
47 static float cube[8][3] = {
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
48 {0.5, 0.5, -0.5},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
49 {0.5, -0.5, -0.5},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
50 {-0.5, -0.5, -0.5},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
51 {-0.5, 0.5, -0.5},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
52 {-0.5, 0.5, 0.5},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
53 {0.5, 0.5, 0.5},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
54 {0.5, -0.5, 0.5},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
55 {-0.5, -0.5, 0.5}
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
56 };
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
57
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
58 /* Do our drawing, too. */
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
59 glClearColor(0.0, 0.0, 0.0, 1.0);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
60 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
61
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
62 glBegin(GL_QUADS);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
63
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
64 #ifdef SHADED_CUBE
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
65 glColor3fv(color[0]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
66 glVertex3fv(cube[0]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
67 glColor3fv(color[1]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
68 glVertex3fv(cube[1]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
69 glColor3fv(color[2]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
70 glVertex3fv(cube[2]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
71 glColor3fv(color[3]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
72 glVertex3fv(cube[3]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
73
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
74 glColor3fv(color[3]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
75 glVertex3fv(cube[3]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
76 glColor3fv(color[4]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
77 glVertex3fv(cube[4]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
78 glColor3fv(color[7]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
79 glVertex3fv(cube[7]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
80 glColor3fv(color[2]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
81 glVertex3fv(cube[2]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
82
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
83 glColor3fv(color[0]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
84 glVertex3fv(cube[0]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
85 glColor3fv(color[5]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
86 glVertex3fv(cube[5]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
87 glColor3fv(color[6]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
88 glVertex3fv(cube[6]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
89 glColor3fv(color[1]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
90 glVertex3fv(cube[1]);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
92 glColor3fv(color[5]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
93 glVertex3fv(cube[5]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
94 glColor3fv(color[4]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
95 glVertex3fv(cube[4]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
96 glColor3fv(color[7]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
97 glVertex3fv(cube[7]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
98 glColor3fv(color[6]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
99 glVertex3fv(cube[6]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
100
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
101 glColor3fv(color[5]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
102 glVertex3fv(cube[5]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
103 glColor3fv(color[0]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
104 glVertex3fv(cube[0]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
105 glColor3fv(color[3]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
106 glVertex3fv(cube[3]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
107 glColor3fv(color[4]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
108 glVertex3fv(cube[4]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
109
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
110 glColor3fv(color[6]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
111 glVertex3fv(cube[6]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
112 glColor3fv(color[1]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
113 glVertex3fv(cube[1]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
114 glColor3fv(color[2]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
115 glVertex3fv(cube[2]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
116 glColor3fv(color[7]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
117 glVertex3fv(cube[7]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
118 #else /* flat cube */
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
119 glColor3f(1.0, 0.0, 0.0);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
120 glVertex3fv(cube[0]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
121 glVertex3fv(cube[1]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
122 glVertex3fv(cube[2]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
123 glVertex3fv(cube[3]);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
125 glColor3f(0.0, 1.0, 0.0);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
126 glVertex3fv(cube[3]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
127 glVertex3fv(cube[4]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
128 glVertex3fv(cube[7]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
129 glVertex3fv(cube[2]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
130
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
131 glColor3f(0.0, 0.0, 1.0);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
132 glVertex3fv(cube[0]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
133 glVertex3fv(cube[5]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
134 glVertex3fv(cube[6]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
135 glVertex3fv(cube[1]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
136
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
137 glColor3f(0.0, 1.0, 1.0);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
138 glVertex3fv(cube[5]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
139 glVertex3fv(cube[4]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
140 glVertex3fv(cube[7]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
141 glVertex3fv(cube[6]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
142
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
143 glColor3f(1.0, 1.0, 0.0);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
144 glVertex3fv(cube[5]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
145 glVertex3fv(cube[0]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
146 glVertex3fv(cube[3]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
147 glVertex3fv(cube[4]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
148
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
149 glColor3f(1.0, 0.0, 1.0);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
150 glVertex3fv(cube[6]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
151 glVertex3fv(cube[1]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
152 glVertex3fv(cube[2]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
153 glVertex3fv(cube[7]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
154 #endif /* SHADED_CUBE */
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
155
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
156 glEnd();
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
157
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
158 glMatrixMode(GL_MODELVIEW);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
159 glRotatef(5.0, 1.0, 1.0, 1.0);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 int
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
163 main(int argc, char *argv[])
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 {
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
165 int fsaa, accel;
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
166 int value;
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
167 int i, done;
1967
01e29c3e9a29 In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
168 SDL_DisplayMode mode;
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
169 SDL_Event event;
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
170 Uint32 then, now, frames;
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
171 int status;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
173 /* Initialize parameters */
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
174 fsaa = 0;
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
175 accel = 0;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
177 /* Initialize test framework */
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
178 state = CommonCreateState(argv, SDL_INIT_VIDEO);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
179 if (!state) {
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
180 return 1;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 }
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
182 for (i = 1; i < argc;) {
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
183 int consumed;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
185 consumed = CommonArg(state, i);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
186 if (consumed == 0) {
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
187 if (SDL_strcasecmp(argv[i], "--fsaa") == 0) {
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
188 ++fsaa;
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
189 consumed = 1;
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
190 } else if (SDL_strcasecmp(argv[i], "--accel") == 0) {
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
191 ++accel;
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
192 consumed = 1;
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
193 } else {
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
194 consumed = -1;
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
195 }
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
196 }
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
197 if (consumed < 0) {
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1967
diff changeset
198 fprintf(stderr, "Usage: %s %s [--fsaa] [--accel]\n", argv[0],
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
199 CommonUsage(state));
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
200 quit(1);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
201 }
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
202 i += consumed;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
205 /* Set OpenGL parameters */
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
206 state->window_flags |= SDL_WINDOW_OPENGL;
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
207 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
208 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
209 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 if (fsaa) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 if (accel) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 }
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
219 if (!CommonInit(state)) {
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
220 quit(2);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 }
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
222
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
223 /* Create OpenGL context */
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
224 context = SDL_GL_CreateContext(state->windows[0]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
225 if (!context) {
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
226 fprintf(stderr, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
227 quit(2);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
228 }
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
229
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1936
diff changeset
230 if (state->render_flags & SDL_RENDERER_PRESENTVSYNC) {
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231 SDL_GL_SetSwapInterval(1);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 } else {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 SDL_GL_SetSwapInterval(0);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235
1967
01e29c3e9a29 In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
236 SDL_GetCurrentDisplayMode(&mode);
01e29c3e9a29 In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
237 printf("Screen BPP: %d\n", SDL_BITSPERPIXEL(mode.format));
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238 printf("\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 printf("Vendor : %s\n", glGetString(GL_VENDOR));
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240 printf("Renderer : %s\n", glGetString(GL_RENDERER));
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 printf("Version : %s\n", glGetString(GL_VERSION));
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 printf("Extensions : %s\n", glGetString(GL_EXTENSIONS));
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243 printf("\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
245 status=SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
246 if (!status) {
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
247 printf("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
248 } else {
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
249 printf("Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError());
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
250 }
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
251 status=SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
252 if (!status) {
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
253 printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
254 } else {
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
255 printf("Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError());
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
256 }
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
257 status=SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
258 if (!status) {
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
259 printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
260 } else {
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
261 printf("Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError());
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
262 }
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
263 status=SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
264 if (!status) {
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
265 printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value);
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
266 } else {
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
267 printf("Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError());
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
268 }
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269 if (fsaa) {
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
270 status=SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
271 if (!status) {
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
272 printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
273 } else {
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
274 printf("Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", SDL_GetError());
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
275 }
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
276 status=SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
277 if (!status) {
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
278 printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, value);
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
279 } else {
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
280 printf("Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", SDL_GetError());
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
281 }
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283 if (accel) {
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
284 status=SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
285 if (!status)
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
286 {
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
287 printf("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
288 } else {
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
289 printf("Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", SDL_GetError());
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
290 }
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
291 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
292
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
293 /* Set rendering settings */
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
294 glMatrixMode(GL_PROJECTION);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
295 glLoadIdentity();
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296 glOrtho(-2.0, 2.0, -2.0, 2.0, -20.0, 20.0);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
297 glMatrixMode(GL_MODELVIEW);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
298 glLoadIdentity();
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
299 glEnable(GL_DEPTH_TEST);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
300 glDepthFunc(GL_LESS);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
301 glShadeModel(GL_SMOOTH);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
302
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
303 /* Main render loop */
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
304 frames = 0;
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
305 then = SDL_GetTicks();
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
306 done = 0;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
307 while (!done) {
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
308 /* Check for events */
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
309 ++frames;
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
310 while (SDL_PollEvent(&event)) {
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
311 CommonEvent(state, &event, &done);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
312 }
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
313 for (i = 0; i < state->num_windows; ++i) {
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
314 int w, h;
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
315 SDL_GL_MakeCurrent(state->windows[i], context);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
316 SDL_GetWindowSize(state->windows[i], &w, &h);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
317 glViewport(0, 0, w, h);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
318 Render();
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
319 SDL_GL_SwapWindow(state->windows[i]);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
320 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
322
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
323 /* Print out some timing information */
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
324 now = SDL_GetTicks();
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
325 if (now > then) {
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
326 printf("%2.2f frames per second\n",
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
327 ((double) frames * 1000) / (now - then));
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 }
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
329 quit(0);
2232
Sam Lantinga <slouken@libsdl.org>
parents: 2228
diff changeset
330 return 0;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333 #else /* HAVE_OPENGL */
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335 int
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336 main(int argc, char *argv[])
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338 printf("No OpenGL support on this system\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339 return 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
342 #endif /* HAVE_OPENGL */