Mercurial > sdl-ios-xcode
annotate test/testgles.c @ 2430:166821fa1591 gsoc2008_iphone
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
author | Holmes Futrell <hfutrell@umail.ucsb.edu> |
---|---|
date | Fri, 15 Aug 2008 00:54:21 +0000 |
parents | |
children |
rev | line source |
---|---|
2430
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
1 #include <stdlib.h> |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
2 #include <stdio.h> |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
3 #include <string.h> |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
4 #include <math.h> |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
5 |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
6 #include "common.h" |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
7 |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
8 #ifdef __IPHONEOS__ |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
9 #define HAVE_OPENGLES |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
10 #endif |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
11 |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
12 #ifdef HAVE_OPENGLES |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
13 |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
14 #include "SDL_opengles.h" |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
15 |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
16 static CommonState *state; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
17 static SDL_GLContext context; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
18 |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
19 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
20 static void |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
21 quit(int rc) |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
22 { |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
23 if (context) { |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
24 /* SDL_GL_MakeCurrent(0, NULL); *//* doesn't do anything */ |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
25 SDL_GL_DeleteContext(context); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
26 } |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
27 CommonQuit(state); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
28 exit(rc); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
29 } |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
30 |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
31 static void |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
32 Render() |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
33 { |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
34 static GLubyte color[8][4] = { {255, 0, 0, 0}, |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
35 { 255, 0, 0, 255}, |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
36 { 0, 255, 0, 255}, |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
37 { 0, 255, 0, 255}, |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
38 { 0, 255, 0, 255}, |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
39 { 255, 255, 255, 255}, |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
40 { 255, 0, 255, 255}, |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
41 { 0, 0, 255, 255} |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
42 }; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
43 static GLfloat cube[8][3] = { {0.5, 0.5, -0.5}, |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
44 {0.5f, -0.5f, -0.5f}, |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
45 {-0.5f, -0.5f, -0.5f}, |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
46 {-0.5f, 0.5f, -0.5f}, |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
47 {-0.5f, 0.5f, 0.5f}, |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
48 {0.5f, 0.5f, 0.5f}, |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
49 {0.5f, -0.5f, 0.5f}, |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
50 {-0.5f, -0.5f, 0.5f} |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
51 }; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
52 static GLubyte indices[36] = { 0, 3, 4,\ |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
53 4, 5, 0,\ |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
54 0, 5, 6,\ |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
55 6, 1, 0,\ |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
56 6, 7, 2,\ |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
57 2, 1, 6,\ |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
58 7, 4, 3,\ |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
59 3, 2, 7,\ |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
60 5, 4, 7,\ |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
61 7, 6, 5,\ |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
62 2, 3, 1,\ |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
63 3, 0, 1 }; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
64 |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
65 |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
66 /* Do our drawing, too. */ |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
67 glClearColor(0.0, 0.0, 0.0, 1.0); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
68 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
69 |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
70 /* Draw the cube */ |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
71 glColorPointer(4, GL_UNSIGNED_BYTE, 0, color); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
72 glEnableClientState(GL_COLOR_ARRAY); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
73 glVertexPointer(3, GL_FLOAT, 0, cube); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
74 glEnableClientState(GL_VERTEX_ARRAY); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
75 glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_BYTE, indices); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
76 |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
77 glMatrixMode(GL_MODELVIEW); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
78 glRotatef(5.0, 1.0, 1.0, 1.0); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
79 } |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
80 |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
81 int |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
82 main(int argc, char *argv[]) |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
83 { |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
84 int fsaa, accel; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
85 int value; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
86 int i, done; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
87 SDL_DisplayMode mode; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
88 SDL_Event event; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
89 Uint32 then, now, frames; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
90 |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
91 /* Initialize parameters */ |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
92 fsaa = 0; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
93 accel = 0; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
94 |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
95 /* Initialize test framework */ |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
96 state = CommonCreateState(argv, SDL_INIT_VIDEO); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
97 if (!state) { |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
98 return 1; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
99 } |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
100 for (i = 1; i < argc;) { |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
101 int consumed; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
102 |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
103 consumed = CommonArg(state, i); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
104 if (consumed == 0) { |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
105 if (SDL_strcasecmp(argv[i], "--fsaa") == 0) { |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
106 ++fsaa; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
107 consumed = 1; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
108 } else if (SDL_strcasecmp(argv[i], "--accel") == 0) { |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
109 ++accel; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
110 consumed = 1; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
111 } else { |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
112 consumed = -1; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
113 } |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
114 } |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
115 if (consumed < 0) { |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
116 fprintf(stderr, "Usage: %s %s [--fsaa] [--accel]\n", argv[0], |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
117 CommonUsage(state)); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
118 quit(1); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
119 } |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
120 i += consumed; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
121 } |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
122 |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
123 /* Set OpenGL parameters */ |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
124 state->window_flags |= SDL_WINDOW_OPENGL; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
125 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
126 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
127 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
128 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
129 if (fsaa) { |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
130 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
131 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
132 } |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
133 if (accel) { |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
134 SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
135 } |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
136 if (!CommonInit(state)) { |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
137 quit(2); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
138 } |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
139 |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
140 /* Create OpenGL context */ |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
141 context = SDL_GL_CreateContext(state->windows[0]); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
142 if (!context) { |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
143 fprintf(stderr, "SDL_GL_CreateContext(): %s\n", SDL_GetError()); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
144 quit(2); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
145 } |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
146 |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
147 if (state->render_flags & SDL_RENDERER_PRESENTVSYNC) { |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
148 SDL_GL_SetSwapInterval(1); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
149 } else { |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
150 SDL_GL_SetSwapInterval(0); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
151 } |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
152 |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
153 SDL_GetCurrentDisplayMode(&mode); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
154 printf("Screen BPP: %d\n", SDL_BITSPERPIXEL(mode.format)); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
155 printf("\n"); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
156 printf("Vendor : %s\n", glGetString(GL_VENDOR)); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
157 printf("Renderer : %s\n", glGetString(GL_RENDERER)); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
158 printf("Version : %s\n", glGetString(GL_VERSION)); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
159 printf("Extensions : %s\n", glGetString(GL_EXTENSIONS)); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
160 printf("\n"); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
161 |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
162 SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
163 printf("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
164 SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
165 printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
166 SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
167 printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
168 SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
169 printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
170 if (fsaa) { |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
171 SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
172 printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
173 SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
174 printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
175 value); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
176 } |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
177 if (accel) { |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
178 SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
179 printf("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
180 } |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
181 |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
182 /* Set rendering settings */ |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
183 glMatrixMode(GL_PROJECTION); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
184 glLoadIdentity(); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
185 glOrthof(-2.0, 2.0, -2.0, 2.0, -20.0, 20.0); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
186 glMatrixMode(GL_MODELVIEW); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
187 glLoadIdentity(); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
188 glEnable(GL_DEPTH_TEST); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
189 glDepthFunc(GL_LESS); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
190 glShadeModel(GL_SMOOTH); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
191 |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
192 /* Main render loop */ |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
193 frames = 0; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
194 then = SDL_GetTicks(); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
195 done = 0; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
196 while (!done) { |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
197 /* Check for events */ |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
198 ++frames; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
199 while (SDL_PollEvent(&event)) { |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
200 CommonEvent(state, &event, &done); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
201 } |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
202 for (i = 0; i < state->num_windows; ++i) { |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
203 int w, h; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
204 SDL_GL_MakeCurrent(state->windows[i], context); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
205 SDL_GetWindowSize(state->windows[i], &w, &h); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
206 glViewport(0, 0, w, h); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
207 Render(); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
208 SDL_GL_SwapWindow(state->windows[i]); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
209 } |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
210 } |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
211 |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
212 /* Print out some timing information */ |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
213 now = SDL_GetTicks(); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
214 if (now > then) { |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
215 printf("%2.2f frames per second\n", |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
216 ((double) frames * 1000) / (now - then)); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
217 } |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
218 quit(0); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
219 return 0; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
220 } |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
221 |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
222 #else /* HAVE_OPENGLES */ |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
223 |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
224 int |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
225 main(int argc, char *argv[]) |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
226 { |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
227 printf("No OpenGL ES support on this system\n"); |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
228 return 1; |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
229 } |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
230 |
166821fa1591
A version of testgl2 written using OpenGL ES calls. Necessary because there's no glBegin/glEnd, etc.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
231 #endif /* HAVE_OPENGLES */ |