Mercurial > sdl-ios-xcode
annotate test/testgles.c @ 4666:52e871f486b8
Revision 3163 added the following formats for OpenGL ES:
SDL_PIXELFORMAT_ABGR4444, SDL_PIXELFORMAT_ABGR1555, SDL_PIXELFORMAT_BGR565
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 16 Jul 2010 22:16:05 -0700 |
parents | 55541ddf13e3 |
children | c92950635837 |
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; |
3408
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
18 static int depth = 16; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 /* 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
|
21 static void |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 quit(int rc) |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 { |
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
|
24 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
|
25 |
3139 | 26 if (context != NULL) { |
27 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
|
28 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
|
29 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
|
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 |
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
|
33 SDL_free(context); |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 } |
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
|
35 |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 CommonQuit(state); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 exit(rc); |
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 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 static void |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 Render() |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 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
|
44 {255, 0, 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 {0, 255, 0, 255}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 {255, 255, 255, 255}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 {255, 0, 255, 255}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 {0, 0, 255, 255} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 }; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 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
|
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 {-0.5f, -0.5f, 0.5f} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 }; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 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
|
62 4, 5, 0, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 0, 5, 6, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 6, 1, 0, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 6, 7, 2, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 2, 1, 6, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 7, 4, 3, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 3, 2, 7, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 5, 4, 7, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 7, 6, 5, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 2, 3, 1, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 3, 0, 1 |
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 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 /* Do our drawing, too. */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 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
|
78 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
|
79 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 /* Draw the cube */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 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
|
82 glEnableClientState(GL_COLOR_ARRAY); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 glVertexPointer(3, GL_FLOAT, 0, cube); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 glEnableClientState(GL_VERTEX_ARRAY); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 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
|
86 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 glMatrixMode(GL_MODELVIEW); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 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
|
89 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 int |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 main(int argc, char *argv[]) |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 int fsaa, accel; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 int value; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 int i, done; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 SDL_DisplayMode mode; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 SDL_Event event; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 Uint32 then, now, frames; |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
100 int status; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 /* Initialize parameters */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 fsaa = 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 accel = 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 /* Initialize test framework */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 state = CommonCreateState(argv, SDL_INIT_VIDEO); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 if (!state) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 return 1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 for (i = 1; i < argc;) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 int consumed; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 consumed = CommonArg(state, i); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 if (consumed == 0) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 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
|
117 ++fsaa; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 consumed = 1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 } 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
|
120 ++accel; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 consumed = 1; |
3408
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
122 } else if (SDL_strcasecmp(argv[i], "--zdepth") == 0) { |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
123 i++; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
124 if (!argv[i]) { |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
125 consumed = -1; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
126 } else { |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
127 depth = SDL_atoi(argv[i]); |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
128 consumed = 1; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
129 } |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 } else { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 consumed = -1; |
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 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 if (consumed < 0) { |
3408
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
135 fprintf(stderr, "Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0], |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 CommonUsage(state)); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 quit(1); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 i += consumed; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 /* Set OpenGL parameters */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 state->window_flags |= SDL_WINDOW_OPENGL; |
3408
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
144 state->gl_red_size = 5; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
145 state->gl_green_size = 5; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
146 state->gl_blue_size = 5; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
147 state->gl_depth_size = depth; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 if (fsaa) { |
3408
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
149 state->gl_multisamplebuffers=1; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
150 state->gl_multisamplesamples=fsaa; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 if (accel) { |
3408
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
153 state->gl_accelerated=1; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 if (!CommonInit(state)) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 quit(2); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 |
3398
5ecc05616f39
Fixed memory allocation size.
Mike Gorchak <lestat@i.com.ua>
parents:
3397
diff
changeset
|
159 context = SDL_calloc(state->num_windows, sizeof(context)); |
3139 | 160 if (context == NULL) { |
161 fprintf(stderr, "Out of memory!\n"); | |
162 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
|
163 } |
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
|
164 |
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
|
165 /* Create OpenGL ES contexts */ |
3139 | 166 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
|
167 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
|
168 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
|
169 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
|
170 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
|
171 } |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 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
|
175 SDL_GL_SetSwapInterval(1); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 } else { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 SDL_GL_SetSwapInterval(0); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 SDL_GetCurrentDisplayMode(&mode); |
3408
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
181 printf("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format)); |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 printf("\n"); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 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
|
184 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
|
185 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
|
186 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
|
187 printf("\n"); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 |
3139 | 189 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
|
190 if (!status) { |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
191 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
|
192 } else { |
3139 | 193 fprintf(stderr, "Failed to get SDL_GL_RED_SIZE: %s\n", |
194 SDL_GetError()); | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
195 } |
3139 | 196 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
|
197 if (!status) { |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
198 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
|
199 } else { |
3139 | 200 fprintf(stderr, "Failed to get SDL_GL_GREEN_SIZE: %s\n", |
201 SDL_GetError()); | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
202 } |
3139 | 203 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
|
204 if (!status) { |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
205 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
|
206 } else { |
3139 | 207 fprintf(stderr, "Failed to get SDL_GL_BLUE_SIZE: %s\n", |
208 SDL_GetError()); | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
209 } |
3139 | 210 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
|
211 if (!status) { |
3408
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
212 printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value); |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
213 } else { |
3139 | 214 fprintf(stderr, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", |
215 SDL_GetError()); | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
216 } |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 if (fsaa) { |
3139 | 218 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
|
219 if (!status) { |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
220 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
|
221 } else { |
3139 | 222 fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", |
223 SDL_GetError()); | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
224 } |
3139 | 225 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
|
226 if (!status) { |
3139 | 227 printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, |
228 value); | |
3099
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_MULTISAMPLESAMPLES: %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 if (accel) { |
3139 | 235 status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value); |
236 if (!status) { | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
237 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
|
238 } else { |
3139 | 239 fprintf(stderr, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", |
240 SDL_GetError()); | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
241 } |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 |
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
|
244 /* 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
|
245 for (i = 0; i < state->num_windows; ++i) { |
3139 | 246 status = SDL_GL_MakeCurrent(state->windows[i], context[i]); |
247 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
|
248 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
|
249 |
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 /* 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
|
251 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
|
252 } |
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 |
3397
c64ae6ee6a6d
Fixed handling of the initial window size.
Mike Gorchak <lestat@i.com.ua>
parents:
3194
diff
changeset
|
254 glViewport(0, 0, state->window_w, state->window_h); |
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
|
255 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
|
256 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
|
257 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
|
258 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
|
259 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
|
260 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
|
261 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
|
262 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
|
263 } |
2765
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 /* Main render loop */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 frames = 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 then = SDL_GetTicks(); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 done = 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 while (!done) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
270 /* Check for events */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 ++frames; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 while (SDL_PollEvent(&event)) { |
3194
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
273 switch (event.type) { |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
274 case SDL_WINDOWEVENT: |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
275 switch (event.window.event) { |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
276 case SDL_WINDOWEVENT_RESIZED: |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
277 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
|
278 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
|
279 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
|
280 if (status) { |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
281 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
|
282 break; |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
283 } |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
284 /* 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
|
285 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
|
286 /* Update window content */ |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
287 Render(); |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
288 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
|
289 break; |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
290 } |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
291 } |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
292 break; |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
293 } |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
294 } |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 CommonEvent(state, &event, &done); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 for (i = 0; i < state->num_windows; ++i) { |
3139 | 298 status = SDL_GL_MakeCurrent(state->windows[i], context[i]); |
299 if (status) { | |
300 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
|
301 |
3139 | 302 /* Continue for next window */ |
303 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
|
304 } |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
305 Render(); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
306 SDL_GL_SwapWindow(state->windows[i]); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
307 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
308 } |
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 /* Print out some timing information */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 now = SDL_GetTicks(); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 if (now > then) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 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
|
314 ((double) frames * 1000) / (now - then)); |
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 quit(0); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 return 0; |
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 #else /* HAVE_OPENGLES */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
321 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 int |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 main(int argc, char *argv[]) |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
324 { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
325 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
|
326 return 1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
328 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 #endif /* HAVE_OPENGLES */ |