Mercurial > sdl-ios-xcode
annotate test/testgles.c @ 3359:aecbdf3362c3
Added some debug output to loopwave.c
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Sat, 10 Oct 2009 06:32:11 +0000 |
parents | c18c03927a77 |
children | c64ae6ee6a6d |
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 |
3194
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
245 glViewport(0, 0, DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT); |
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
|
246 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
|
247 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
|
248 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
|
249 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
|
250 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
|
251 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
|
252 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
|
253 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
|
254 } |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 /* Main render loop */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 frames = 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 then = SDL_GetTicks(); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 done = 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 while (!done) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 /* Check for events */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 ++frames; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 while (SDL_PollEvent(&event)) { |
3194
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
264 switch (event.type) { |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
265 case SDL_WINDOWEVENT: |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
266 switch (event.window.event) { |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
267 case SDL_WINDOWEVENT_RESIZED: |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
268 for (i = 0; i < state->num_windows; ++i) { |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
269 if (event.window.windowID == state->windows[i]) { |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
270 status = SDL_GL_MakeCurrent(state->windows[i], context[i]); |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
271 if (status) { |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
272 printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
273 break; |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
274 } |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
275 /* Change view port to the new window dimensions */ |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
276 glViewport(0, 0, event.window.data1, event.window.data2); |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
277 /* Update window content */ |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
278 Render(); |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
279 SDL_GL_SwapWindow(state->windows[i]); |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
280 break; |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
281 } |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
282 } |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
283 break; |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
284 } |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
285 } |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 CommonEvent(state, &event, &done); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 for (i = 0; i < state->num_windows; ++i) { |
3139 | 289 status = SDL_GL_MakeCurrent(state->windows[i], context[i]); |
290 if (status) { | |
291 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
|
292 |
3139 | 293 /* Continue for next window */ |
294 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
|
295 } |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 Render(); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 SDL_GL_SwapWindow(state->windows[i]); |
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 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
301 /* Print out some timing information */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
302 now = SDL_GetTicks(); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
303 if (now > then) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
304 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
|
305 ((double) frames * 1000) / (now - then)); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
306 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
307 quit(0); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
308 return 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
310 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 #else /* HAVE_OPENGLES */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 int |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
314 main(int argc, char *argv[]) |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
315 { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
316 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
|
317 return 1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
318 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 #endif /* HAVE_OPENGLES */ |