Mercurial > sdl-ios-xcode
annotate test/testgl2.c @ 1940:255fb6feae0d
Removing DGA support for SDL 1.3 - it's still buggy years later, and now
it's deprecated by the developers in favor of the render APIs.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 26 Jul 2006 03:06:07 +0000 |
parents | 83946ee0ff1f |
children | a788656ca29a |
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) { |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
27 SDL_GL_MakeCurrent(0, NULL); |
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; |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
168 SDL_Event event; |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
169 Uint32 then, now, frames; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 |
1915
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
171 /* Initialize parameters */ |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
172 fsaa = 0; |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
173 accel = 0; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 |
1915
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
175 /* Initialize test framework */ |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
176 state = CommonCreateState(argv, SDL_INIT_VIDEO); |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
177 if (!state) { |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
178 return 1; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 } |
1915
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
180 for (i = 1; i < argc;) { |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
181 int consumed; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 |
1915
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
183 consumed = CommonArg(state, i); |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
184 if (consumed == 0) { |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
185 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
|
186 ++fsaa; |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
187 consumed = 1; |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
188 } 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
|
189 ++accel; |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
190 consumed = 1; |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
191 } else { |
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 } |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
194 } |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
195 if (consumed < 0) { |
1916
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1915
diff
changeset
|
196 fprintf(stderr, "Usage: %s %s [--fsaa] [--accel]", argv[0], |
1915
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
197 CommonUsage(state)); |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
198 quit(1); |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
199 } |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
200 i += consumed; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 |
1915
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
203 /* Set OpenGL parameters */ |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
204 state->window_flags |= SDL_WINDOW_OPENGL; |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
205 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
|
206 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
|
207 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
|
208 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
|
209 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 if (fsaa) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 if (accel) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
215 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
|
216 } |
1915
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
217 if (!CommonInit(state)) { |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
218 quit(2); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
219 } |
1915
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
220 |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
221 /* Create OpenGL context */ |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
222 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
|
223 if (!context) { |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
224 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
|
225 quit(2); |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
226 } |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
227 if (SDL_GL_MakeCurrent(state->windows[0], context) < 0) { |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
228 fprintf(stderr, "SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
229 quit(2); |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
230 } |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
231 |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
232 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
|
233 SDL_GL_SetSwapInterval(1); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 } else { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 SDL_GL_SetSwapInterval(0); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 |
1915
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
238 printf("Screen BPP: %d\n", |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
239 SDL_BITSPERPIXEL(SDL_GetCurrentDisplayMode()->format)); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 printf("\n"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 printf("Vendor : %s\n", glGetString(GL_VENDOR)); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 printf("Renderer : %s\n", glGetString(GL_RENDERER)); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 printf("Version : %s\n", glGetString(GL_VERSION)); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 printf("Extensions : %s\n", glGetString(GL_EXTENSIONS)); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 printf("\n"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 |
1936
83946ee0ff1f
Implemented OpenGL support on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
247 SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value); |
1915
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
248 printf("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value); |
1936
83946ee0ff1f
Implemented OpenGL support on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
249 SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value); |
1915
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
250 printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value); |
1936
83946ee0ff1f
Implemented OpenGL support on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
251 SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value); |
1915
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
252 printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value); |
1936
83946ee0ff1f
Implemented OpenGL support on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
253 SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value); |
1915
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
254 printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value); |
1936
83946ee0ff1f
Implemented OpenGL support on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
255 SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &value); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 printf("SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 if (fsaa) { |
1936
83946ee0ff1f
Implemented OpenGL support on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
258 SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); |
1936
83946ee0ff1f
Implemented OpenGL support on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
260 SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 value); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 if (accel) { |
1936
83946ee0ff1f
Implemented OpenGL support on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
265 SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 printf("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 |
1915
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
269 /* Set rendering settings */ |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
270 glMatrixMode(GL_PROJECTION); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 glLoadIdentity(); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 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
|
273 glMatrixMode(GL_MODELVIEW); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 glLoadIdentity(); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
275 glEnable(GL_DEPTH_TEST); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 glDepthFunc(GL_LESS); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 glShadeModel(GL_SMOOTH); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 |
1915
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
279 /* Main render loop */ |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 frames = 0; |
1915
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
281 then = SDL_GetTicks(); |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
282 done = 0; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 while (!done) { |
1915
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
284 /* Check for events */ |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
285 ++frames; |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
286 while (SDL_PollEvent(&event)) { |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
287 CommonEvent(state, &event, &done); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 } |
1915
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
289 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
|
290 int w, h; |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
291 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
|
292 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
|
293 glViewport(0, 0, w, h); |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
294 Render(); |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
295 SDL_GL_SwapWindow(state->windows[i]); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
298 |
1915
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
299 /* Print out some timing information */ |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
300 now = SDL_GetTicks(); |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
301 if (now > then) { |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
302 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
|
303 ((double) frames * 1000) / (now - then)); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
304 } |
1915
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
305 quit(0); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
306 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
307 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
308 #else /* HAVE_OPENGL */ |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
310 int |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 main(int argc, char *argv[]) |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 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
|
314 return 1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
315 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
316 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 #endif /* HAVE_OPENGL */ |