author | Sam Lantinga <slouken@libsdl.org> |
Fri, 08 Apr 2011 13:03:26 -0700 | |
changeset 5535 | 96594ac5fd1a |
parent 5520 | 09b500e0656d |
child 6785 | c094c438c0a6 |
permissions | -rw-r--r-- |
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5520
diff
changeset
|
1 |
/* |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5520
diff
changeset
|
2 |
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org> |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5520
diff
changeset
|
3 |
|
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5520
diff
changeset
|
4 |
This software is provided 'as-is', without any express or implied |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5520
diff
changeset
|
5 |
warranty. In no event will the authors be held liable for any damages |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5520
diff
changeset
|
6 |
arising from the use of this software. |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5520
diff
changeset
|
7 |
|
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5520
diff
changeset
|
8 |
Permission is granted to anyone to use this software for any purpose, |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5520
diff
changeset
|
9 |
including commercial applications, and to alter it and redistribute it |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5520
diff
changeset
|
10 |
freely. |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5520
diff
changeset
|
11 |
*/ |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 |
#include <stdlib.h> |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 |
#include <stdio.h> |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
#include <string.h> |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 |
#include <math.h> |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 |
#include "common.h" |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
|
4961
c92950635837
Android has OpenGL ES too...
Sam Lantinga <slouken@libsdl.org>
parents:
3408
diff
changeset
|
19 |
#if defined(__IPHONEOS__) || defined(__ANDROID__) |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 |
#define HAVE_OPENGLES |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 |
#endif |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
#ifdef HAVE_OPENGLES |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 |
#include "SDL_opengles.h" |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 |
static CommonState *state; |
3139 | 28 |
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
|
29 |
static int depth = 16; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 |
/* 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
|
32 |
static void |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 |
quit(int rc) |
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 |
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
|
36 |
|
3139 | 37 |
if (context != NULL) { |
38 |
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
|
39 |
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
|
40 |
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
|
41 |
} |
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
|
42 |
} |
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
|
43 |
|
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
|
44 |
SDL_free(context); |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 |
} |
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
|
46 |
|
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 |
CommonQuit(state); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 |
exit(rc); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 |
} |
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 void |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 |
Render() |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 |
{ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 |
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
|
55 |
{255, 0, 0, 255}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 |
{0, 255, 0, 255}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 |
{0, 255, 0, 255}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 |
{0, 255, 0, 255}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 |
{255, 255, 255, 255}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 |
{255, 0, 255, 255}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 |
{0, 0, 255, 255} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 |
}; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 |
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
|
64 |
{0.5f, -0.5f, -0.5f}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 |
{-0.5f, -0.5f, -0.5f}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 |
{-0.5f, 0.5f, -0.5f}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 |
{-0.5f, 0.5f, 0.5f}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 |
{0.5f, 0.5f, 0.5f}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 |
{0.5f, -0.5f, 0.5f}, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 |
{-0.5f, -0.5f, 0.5f} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 |
}; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 |
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
|
73 |
4, 5, 0, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 |
0, 5, 6, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 |
6, 1, 0, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 |
6, 7, 2, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 |
2, 1, 6, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 |
7, 4, 3, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 |
3, 2, 7, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 |
5, 4, 7, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 |
7, 6, 5, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 |
2, 3, 1, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 |
3, 0, 1 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 |
}; |
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 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 |
/* Do our drawing, too. */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 |
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
|
89 |
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
|
90 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 |
/* Draw the cube */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 |
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
|
93 |
glEnableClientState(GL_COLOR_ARRAY); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 |
glVertexPointer(3, GL_FLOAT, 0, cube); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 |
glEnableClientState(GL_VERTEX_ARRAY); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 |
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
|
97 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 |
glMatrixMode(GL_MODELVIEW); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 |
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
|
100 |
} |
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 |
int |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 |
main(int argc, char *argv[]) |
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 |
int fsaa, accel; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 |
int value; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 |
int i, done; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 |
SDL_DisplayMode mode; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 |
SDL_Event event; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 |
Uint32 then, now, frames; |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
111 |
int status; |
2765
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 |
/* Initialize parameters */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 |
fsaa = 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 |
accel = 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 |
/* Initialize test framework */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 |
state = CommonCreateState(argv, SDL_INIT_VIDEO); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 |
if (!state) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 |
return 1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 |
for (i = 1; i < argc;) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 |
int consumed; |
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 |
consumed = CommonArg(state, i); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 |
if (consumed == 0) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 |
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
|
128 |
++fsaa; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 |
consumed = 1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 |
} 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
|
131 |
++accel; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 |
consumed = 1; |
3408
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
133 |
} 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
|
134 |
i++; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
135 |
if (!argv[i]) { |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
136 |
consumed = -1; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
137 |
} else { |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
138 |
depth = SDL_atoi(argv[i]); |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
139 |
consumed = 1; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
140 |
} |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 |
} else { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 |
consumed = -1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 |
if (consumed < 0) { |
3408
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
146 |
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
|
147 |
CommonUsage(state)); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 |
quit(1); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 |
i += consumed; |
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 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 |
/* Set OpenGL parameters */ |
5520
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5363
diff
changeset
|
154 |
state->window_flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS; |
3408
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
155 |
state->gl_red_size = 5; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
156 |
state->gl_green_size = 5; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
157 |
state->gl_blue_size = 5; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
158 |
state->gl_depth_size = depth; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 |
if (fsaa) { |
3408
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
160 |
state->gl_multisamplebuffers=1; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
161 |
state->gl_multisamplesamples=fsaa; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 |
if (accel) { |
3408
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
164 |
state->gl_accelerated=1; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 |
if (!CommonInit(state)) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 |
quit(2); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 |
|
3398
5ecc05616f39
Fixed memory allocation size.
Mike Gorchak <lestat@i.com.ua>
parents:
3397
diff
changeset
|
170 |
context = SDL_calloc(state->num_windows, sizeof(context)); |
3139 | 171 |
if (context == NULL) { |
172 |
fprintf(stderr, "Out of memory!\n"); |
|
173 |
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
|
174 |
} |
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
|
175 |
|
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
|
176 |
/* Create OpenGL ES contexts */ |
3139 | 177 |
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
|
178 |
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
|
179 |
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
|
180 |
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
|
181 |
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
|
182 |
} |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 |
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
|
186 |
SDL_GL_SetSwapInterval(1); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 |
} else { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 |
SDL_GL_SetSwapInterval(0); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
189 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 |
|
5363
96799a165806
Fixed testgles on iOS (bug 1136)
Sam Lantinga <slouken@libsdl.org>
parents:
4961
diff
changeset
|
191 |
SDL_GetCurrentDisplayMode(0, &mode); |
3408
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
192 |
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
|
193 |
printf("\n"); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 |
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
|
195 |
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
|
196 |
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
|
197 |
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
|
198 |
printf("\n"); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 |
|
3139 | 200 |
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
|
201 |
if (!status) { |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
202 |
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
|
203 |
} else { |
3139 | 204 |
fprintf(stderr, "Failed to get SDL_GL_RED_SIZE: %s\n", |
205 |
SDL_GetError()); |
|
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
206 |
} |
3139 | 207 |
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
|
208 |
if (!status) { |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
209 |
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
|
210 |
} else { |
3139 | 211 |
fprintf(stderr, "Failed to get SDL_GL_GREEN_SIZE: %s\n", |
212 |
SDL_GetError()); |
|
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
213 |
} |
3139 | 214 |
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
|
215 |
if (!status) { |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
216 |
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
|
217 |
} else { |
3139 | 218 |
fprintf(stderr, "Failed to get SDL_GL_BLUE_SIZE: %s\n", |
219 |
SDL_GetError()); |
|
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
220 |
} |
3139 | 221 |
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
|
222 |
if (!status) { |
3408
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
223 |
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
|
224 |
} else { |
3139 | 225 |
fprintf(stderr, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", |
226 |
SDL_GetError()); |
|
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
227 |
} |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 |
if (fsaa) { |
3139 | 229 |
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
|
230 |
if (!status) { |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
231 |
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
|
232 |
} else { |
3139 | 233 |
fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", |
234 |
SDL_GetError()); |
|
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
235 |
} |
3139 | 236 |
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
|
237 |
if (!status) { |
3139 | 238 |
printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, |
239 |
value); |
|
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
240 |
} else { |
3139 | 241 |
fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", |
242 |
SDL_GetError()); |
|
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
243 |
} |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 |
if (accel) { |
3139 | 246 |
status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value); |
247 |
if (!status) { |
|
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
248 |
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
|
249 |
} else { |
3139 | 250 |
fprintf(stderr, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", |
251 |
SDL_GetError()); |
|
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
252 |
} |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 |
|
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 |
/* 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
|
256 |
for (i = 0; i < state->num_windows; ++i) { |
5363
96799a165806
Fixed testgles on iOS (bug 1136)
Sam Lantinga <slouken@libsdl.org>
parents:
4961
diff
changeset
|
257 |
float aspectAdjust; |
96799a165806
Fixed testgles on iOS (bug 1136)
Sam Lantinga <slouken@libsdl.org>
parents:
4961
diff
changeset
|
258 |
|
3139 | 259 |
status = SDL_GL_MakeCurrent(state->windows[i], context[i]); |
260 |
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
|
261 |
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
|
262 |
|
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 |
/* 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
|
264 |
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
|
265 |
} |
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
|
266 |
|
5363
96799a165806
Fixed testgles on iOS (bug 1136)
Sam Lantinga <slouken@libsdl.org>
parents:
4961
diff
changeset
|
267 |
aspectAdjust = (4.0f / 3.0f) / ((float)state->window_w / state->window_h); |
3397
c64ae6ee6a6d
Fixed handling of the initial window size.
Mike Gorchak <lestat@i.com.ua>
parents:
3194
diff
changeset
|
268 |
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
|
269 |
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
|
270 |
glLoadIdentity(); |
5363
96799a165806
Fixed testgles on iOS (bug 1136)
Sam Lantinga <slouken@libsdl.org>
parents:
4961
diff
changeset
|
271 |
glOrthof(-2.0, 2.0, -2.0 * aspectAdjust, 2.0 * aspectAdjust, -20.0, 20.0); |
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
|
272 |
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
|
273 |
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
|
274 |
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
|
275 |
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
|
276 |
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
|
277 |
} |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 |
/* Main render loop */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 |
frames = 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
281 |
then = SDL_GetTicks(); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 |
done = 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 |
while (!done) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 |
/* Check for events */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 |
++frames; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 |
while (SDL_PollEvent(&event)) { |
3194
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
287 |
switch (event.type) { |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
288 |
case SDL_WINDOWEVENT: |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
289 |
switch (event.window.event) { |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
290 |
case SDL_WINDOWEVENT_RESIZED: |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
291 |
for (i = 0; i < state->num_windows; ++i) { |
5363
96799a165806
Fixed testgles on iOS (bug 1136)
Sam Lantinga <slouken@libsdl.org>
parents:
4961
diff
changeset
|
292 |
if (event.window.windowID == SDL_GetWindowID(state->windows[i])) { |
3194
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
293 |
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
|
294 |
if (status) { |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
295 |
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
|
296 |
break; |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
297 |
} |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
298 |
/* 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
|
299 |
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
|
300 |
/* Update window content */ |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
301 |
Render(); |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
302 |
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
|
303 |
break; |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
304 |
} |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
305 |
} |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
306 |
break; |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
307 |
} |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
308 |
} |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 |
CommonEvent(state, &event, &done); |
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 |
for (i = 0; i < state->num_windows; ++i) { |
3139 | 312 |
status = SDL_GL_MakeCurrent(state->windows[i], context[i]); |
313 |
if (status) { |
|
314 |
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
|
315 |
|
3139 | 316 |
/* Continue for next window */ |
317 |
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
|
318 |
} |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 |
Render(); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 |
SDL_GL_SwapWindow(state->windows[i]); |
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 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
324 |
/* Print out some timing information */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
325 |
now = SDL_GetTicks(); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 |
if (now > then) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 |
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
|
328 |
((double) frames * 1000) / (now - then)); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
330 |
quit(0); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 |
return 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
332 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
333 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
334 |
#else /* HAVE_OPENGLES */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
335 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 |
int |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
337 |
main(int argc, char *argv[]) |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
338 |
{ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
339 |
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
|
340 |
return 1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 |
#endif /* HAVE_OPENGLES */ |
5363
96799a165806
Fixed testgles on iOS (bug 1136)
Sam Lantinga <slouken@libsdl.org>
parents:
4961
diff
changeset
|
344 |
|
96799a165806
Fixed testgles on iOS (bug 1136)
Sam Lantinga <slouken@libsdl.org>
parents:
4961
diff
changeset
|
345 |
/* vi: set ts=4 sw=4 expandtab: */ |