Mercurial > sdl-ios-xcode
annotate test/testgles.c @ 3186:51750b7a966f
indent
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 10 Jun 2009 13:34:20 +0000 |
parents | 7f684f249ec9 |
children | c18c03927a77 |
rev | line source |
---|---|
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 #include <stdlib.h> |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 #include <stdio.h> |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 #include <string.h> |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 #include <math.h> |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 #include "common.h" |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 #ifdef __IPHONEOS__ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 #define HAVE_OPENGLES |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 #endif |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 #ifdef HAVE_OPENGLES |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 #include "SDL_opengles.h" |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 static CommonState *state; |
3139 | 17 static SDL_GLContext *context = NULL; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 static void |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 quit(int rc) |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 { |
3110
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
23 int i; |
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
24 |
3139 | 25 if (context != NULL) { |
26 for (i = 0; i < state->num_windows; i++) { | |
3110
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
27 if (context[i]) { |
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
28 SDL_GL_DeleteContext(context[i]); |
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
29 } |
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
30 } |
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
31 |
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
32 SDL_free(context); |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 } |
3110
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
34 |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 CommonQuit(state); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 exit(rc); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 static void |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 Render() |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 static GLubyte color[8][4] = { {255, 0, 0, 0}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 {255, 0, 0, 255}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 {0, 255, 0, 255}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 {0, 255, 0, 255}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 {0, 255, 0, 255}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 {255, 255, 255, 255}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 {255, 0, 255, 255}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 {0, 0, 255, 255} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 }; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 static GLfloat cube[8][3] = { {0.5, 0.5, -0.5}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 {0.5f, -0.5f, -0.5f}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 {-0.5f, -0.5f, -0.5f}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 {-0.5f, 0.5f, -0.5f}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 {-0.5f, 0.5f, 0.5f}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 {0.5f, 0.5f, 0.5f}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 {0.5f, -0.5f, 0.5f}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 {-0.5f, -0.5f, 0.5f} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 }; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 static GLubyte indices[36] = { 0, 3, 4, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 4, 5, 0, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 0, 5, 6, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 6, 1, 0, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 6, 7, 2, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 2, 1, 6, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 7, 4, 3, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 3, 2, 7, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 5, 4, 7, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 7, 6, 5, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 2, 3, 1, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 3, 0, 1 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 }; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 /* Do our drawing, too. */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 glClearColor(0.0, 0.0, 0.0, 1.0); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 /* Draw the cube */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 glColorPointer(4, GL_UNSIGNED_BYTE, 0, color); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 glEnableClientState(GL_COLOR_ARRAY); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 glVertexPointer(3, GL_FLOAT, 0, cube); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 glEnableClientState(GL_VERTEX_ARRAY); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_BYTE, indices); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 glMatrixMode(GL_MODELVIEW); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 glRotatef(5.0, 1.0, 1.0, 1.0); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 int |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 main(int argc, char *argv[]) |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 int fsaa, accel; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 int value; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 int i, done; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 SDL_DisplayMode mode; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 SDL_Event event; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 Uint32 then, now, frames; |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
99 int status; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 /* Initialize parameters */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 fsaa = 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 accel = 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 /* Initialize test framework */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 state = CommonCreateState(argv, SDL_INIT_VIDEO); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 if (!state) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 return 1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 for (i = 1; i < argc;) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 int consumed; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 consumed = CommonArg(state, i); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 if (consumed == 0) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 if (SDL_strcasecmp(argv[i], "--fsaa") == 0) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 ++fsaa; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 consumed = 1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 } else if (SDL_strcasecmp(argv[i], "--accel") == 0) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 ++accel; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 consumed = 1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 } else { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 consumed = -1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 if (consumed < 0) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 fprintf(stderr, "Usage: %s %s [--fsaa] [--accel]\n", argv[0], |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 CommonUsage(state)); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 quit(1); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 i += consumed; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 /* Set OpenGL parameters */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 state->window_flags |= SDL_WINDOW_OPENGL; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 if (fsaa) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 if (accel) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 if (!CommonInit(state)) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 quit(2); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 |
3139 | 150 context = SDL_calloc(state->num_windows, sizeof(SDL_GLContext)); |
151 if (context == NULL) { | |
152 fprintf(stderr, "Out of memory!\n"); | |
153 quit(2); | |
3110
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
154 } |
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
155 |
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
156 /* Create OpenGL ES contexts */ |
3139 | 157 for (i = 0; i < state->num_windows; i++) { |
3110
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
158 context[i] = SDL_GL_CreateContext(state->windows[i]); |
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
159 if (!context[i]) { |
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
160 fprintf(stderr, "SDL_GL_CreateContext(): %s\n", SDL_GetError()); |
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
161 quit(2); |
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
162 } |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 if (state->render_flags & SDL_RENDERER_PRESENTVSYNC) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 SDL_GL_SetSwapInterval(1); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 } else { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 SDL_GL_SetSwapInterval(0); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 SDL_GetCurrentDisplayMode(&mode); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 printf("Screen BPP: %d\n", SDL_BITSPERPIXEL(mode.format)); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 printf("\n"); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 printf("Vendor : %s\n", glGetString(GL_VENDOR)); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 printf("Renderer : %s\n", glGetString(GL_RENDERER)); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 printf("Version : %s\n", glGetString(GL_VERSION)); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 printf("Extensions : %s\n", glGetString(GL_EXTENSIONS)); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 printf("\n"); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 |
3139 | 180 status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value); |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
181 if (!status) { |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
182 printf("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value); |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
183 } else { |
3139 | 184 fprintf(stderr, "Failed to get SDL_GL_RED_SIZE: %s\n", |
185 SDL_GetError()); | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
186 } |
3139 | 187 status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value); |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
188 if (!status) { |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
189 printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value); |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
190 } else { |
3139 | 191 fprintf(stderr, "Failed to get SDL_GL_GREEN_SIZE: %s\n", |
192 SDL_GetError()); | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
193 } |
3139 | 194 status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value); |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
195 if (!status) { |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
196 printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value); |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
197 } else { |
3139 | 198 fprintf(stderr, "Failed to get SDL_GL_BLUE_SIZE: %s\n", |
199 SDL_GetError()); | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
200 } |
3139 | 201 status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value); |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
202 if (!status) { |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
203 printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value); |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
204 } else { |
3139 | 205 fprintf(stderr, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", |
206 SDL_GetError()); | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
207 } |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 if (fsaa) { |
3139 | 209 status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value); |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
210 if (!status) { |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
211 printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
212 } else { |
3139 | 213 fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", |
214 SDL_GetError()); | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
215 } |
3139 | 216 status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value); |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
217 if (!status) { |
3139 | 218 printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, |
219 value); | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
220 } else { |
3139 | 221 fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", |
222 SDL_GetError()); | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
223 } |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
225 if (accel) { |
3139 | 226 status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value); |
227 if (!status) { | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
228 printf("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value); |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
229 } else { |
3139 | 230 fprintf(stderr, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", |
231 SDL_GetError()); | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
232 } |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 |
3110
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
235 /* Set rendering settings for each context */ |
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
236 for (i = 0; i < state->num_windows; ++i) { |
3139 | 237 status = SDL_GL_MakeCurrent(state->windows[i], context[i]); |
238 if (status) { | |
3110
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
239 printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); |
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
240 |
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
241 /* Continue for next window */ |
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
242 continue; |
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
243 } |
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
244 |
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
245 glMatrixMode(GL_PROJECTION); |
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
246 glLoadIdentity(); |
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
247 glOrthof(-2.0, 2.0, -2.0, 2.0, -20.0, 20.0); |
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
248 glMatrixMode(GL_MODELVIEW); |
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
249 glLoadIdentity(); |
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
250 glEnable(GL_DEPTH_TEST); |
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
251 glDepthFunc(GL_LESS); |
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
252 glShadeModel(GL_SMOOTH); |
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
253 } |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 /* Main render loop */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 frames = 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 then = SDL_GetTicks(); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 done = 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 while (!done) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 /* Check for events */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 ++frames; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 while (SDL_PollEvent(&event)) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 CommonEvent(state, &event, &done); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 for (i = 0; i < state->num_windows; ++i) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 int w, h; |
3139 | 267 status = SDL_GL_MakeCurrent(state->windows[i], context[i]); |
268 if (status) { | |
269 printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); | |
3110
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
270 |
3139 | 271 /* Continue for next window */ |
272 continue; | |
3110
e6c21c14ce3a
Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
273 } |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 SDL_GetWindowSize(state->windows[i], &w, &h); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
275 glViewport(0, 0, w, h); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 Render(); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 SDL_GL_SwapWindow(state->windows[i]); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
281 /* Print out some timing information */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 now = SDL_GetTicks(); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 if (now > then) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 printf("%2.2f frames per second\n", |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 ((double) frames * 1000) / (now - then)); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 quit(0); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 return 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
289 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
290 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 #else /* HAVE_OPENGLES */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
292 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
293 int |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
294 main(int argc, char *argv[]) |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 printf("No OpenGL ES support on this system\n"); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 return 1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
298 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
299 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
300 #endif /* HAVE_OPENGLES */ |