author | Gabriel Jacobo <gabomdq@gmail.com> |
Wed, 06 Nov 2013 11:23:24 -0300 | |
changeset 7910 | 261addaa47d0 |
parent 7796 | 75c80f36038e |
child 8149 | 681eb46b8ac4 |
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 |
/* |
7517
965d57022c01
Updated the copyright year for the test programs
Sam Lantinga <slouken@libsdl.org>
parents:
6785
diff
changeset
|
2 |
Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org> |
5535
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 |
|
6785
c094c438c0a6
Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents:
5535
diff
changeset
|
17 |
#include "SDL_test_common.h" |
2765
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 |
|
6785
c094c438c0a6
Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents:
5535
diff
changeset
|
27 |
static SDLTest_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 |
|
6785
c094c438c0a6
Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents:
5535
diff
changeset
|
47 |
SDLTest_CommonQuit(state); |
2765
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 |
|
7639
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
113 |
/* Enable standard application logging */ |
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
114 |
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); |
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
115 |
|
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 |
/* Initialize parameters */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 |
fsaa = 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 |
accel = 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 |
/* Initialize test framework */ |
6785
c094c438c0a6
Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents:
5535
diff
changeset
|
121 |
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 |
if (!state) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 |
return 1; |
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 |
for (i = 1; i < argc;) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 |
int consumed; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 |
|
6785
c094c438c0a6
Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents:
5535
diff
changeset
|
128 |
consumed = SDLTest_CommonArg(state, i); |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 |
if (consumed == 0) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 |
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
|
131 |
++fsaa; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 |
consumed = 1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 |
} 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
|
134 |
++accel; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 |
consumed = 1; |
3408
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
136 |
} 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
|
137 |
i++; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
138 |
if (!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 |
} else { |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
141 |
depth = SDL_atoi(argv[i]); |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
142 |
consumed = 1; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
143 |
} |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 |
} else { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 |
consumed = -1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 |
if (consumed < 0) { |
7639
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
149 |
SDL_Log("Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0], |
6785
c094c438c0a6
Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents:
5535
diff
changeset
|
150 |
SDLTest_CommonUsage(state)); |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 |
quit(1); |
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 |
i += consumed; |
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 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 |
/* Set OpenGL parameters */ |
5520
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5363
diff
changeset
|
157 |
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
|
158 |
state->gl_red_size = 5; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
159 |
state->gl_green_size = 5; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
160 |
state->gl_blue_size = 5; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
161 |
state->gl_depth_size = depth; |
7794
7995e0920bf9
Fixes testgles and testgl
Gabriel Jacobo <gabomdq@gmail.com>
parents:
7787
diff
changeset
|
162 |
state->gl_major_version = 1; |
7995e0920bf9
Fixes testgles and testgl
Gabriel Jacobo <gabomdq@gmail.com>
parents:
7787
diff
changeset
|
163 |
state->gl_minor_version = 1; |
7796
75c80f36038e
Adds gl_profile_mask to test framework, uses it in testgles
Gabriel Jacobo <gabomdq@gmail.com>
parents:
7794
diff
changeset
|
164 |
state->gl_profile_mask = SDL_GL_CONTEXT_PROFILE_ES; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 |
if (fsaa) { |
3408
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
166 |
state->gl_multisamplebuffers=1; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
167 |
state->gl_multisamplesamples=fsaa; |
2765
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 |
if (accel) { |
3408
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3398
diff
changeset
|
170 |
state->gl_accelerated=1; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 |
} |
6785
c094c438c0a6
Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents:
5535
diff
changeset
|
172 |
if (!SDLTest_CommonInit(state)) { |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 |
quit(2); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 |
|
3398
5ecc05616f39
Fixed memory allocation size.
Mike Gorchak <lestat@i.com.ua>
parents:
3397
diff
changeset
|
176 |
context = SDL_calloc(state->num_windows, sizeof(context)); |
3139 | 177 |
if (context == NULL) { |
7639
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
178 |
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); |
3139 | 179 |
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
|
180 |
} |
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 |
|
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 |
/* Create OpenGL ES contexts */ |
3139 | 183 |
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
|
184 |
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
|
185 |
if (!context[i]) { |
7639
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
186 |
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GL_CreateContext(): %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
|
187 |
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
|
188 |
} |
2765
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 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 |
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
|
192 |
SDL_GL_SetSwapInterval(1); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 |
} else { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 |
SDL_GL_SetSwapInterval(0); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 |
|
5363
96799a165806
Fixed testgles on iOS (bug 1136)
Sam Lantinga <slouken@libsdl.org>
parents:
4961
diff
changeset
|
197 |
SDL_GetCurrentDisplayMode(0, &mode); |
7639
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
198 |
SDL_Log("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format)); |
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
199 |
SDL_Log("\n"); |
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
200 |
SDL_Log("Vendor : %s\n", glGetString(GL_VENDOR)); |
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
201 |
SDL_Log("Renderer : %s\n", glGetString(GL_RENDERER)); |
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
202 |
SDL_Log("Version : %s\n", glGetString(GL_VERSION)); |
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
203 |
SDL_Log("Extensions : %s\n", glGetString(GL_EXTENSIONS)); |
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
204 |
SDL_Log("\n"); |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 |
|
3139 | 206 |
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
|
207 |
if (!status) { |
7639
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
208 |
SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value); |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
209 |
} else { |
7639
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
210 |
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_RED_SIZE: %s\n", |
3139 | 211 |
SDL_GetError()); |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
212 |
} |
3139 | 213 |
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
|
214 |
if (!status) { |
7639
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
215 |
SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value); |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
216 |
} else { |
7639
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
217 |
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_GREEN_SIZE: %s\n", |
3139 | 218 |
SDL_GetError()); |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
219 |
} |
3139 | 220 |
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
|
221 |
if (!status) { |
7639
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
222 |
SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value); |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
223 |
} else { |
7639
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
224 |
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_BLUE_SIZE: %s\n", |
3139 | 225 |
SDL_GetError()); |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
226 |
} |
3139 | 227 |
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
|
228 |
if (!status) { |
7639
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
229 |
SDL_Log("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
|
230 |
} else { |
7639
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
231 |
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", |
3139 | 232 |
SDL_GetError()); |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
233 |
} |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 |
if (fsaa) { |
3139 | 235 |
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
|
236 |
if (!status) { |
7639
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
237 |
SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
238 |
} else { |
7639
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
239 |
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", |
3139 | 240 |
SDL_GetError()); |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
241 |
} |
3139 | 242 |
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
|
243 |
if (!status) { |
7639
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
244 |
SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, |
3139 | 245 |
value); |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
246 |
} else { |
7639
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
247 |
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", |
3139 | 248 |
SDL_GetError()); |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
249 |
} |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 |
if (accel) { |
3139 | 252 |
status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value); |
253 |
if (!status) { |
|
7639
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
254 |
SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value); |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
255 |
} else { |
7639
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
256 |
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", |
3139 | 257 |
SDL_GetError()); |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2765
diff
changeset
|
258 |
} |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 |
|
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 |
/* 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
|
262 |
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
|
263 |
float aspectAdjust; |
96799a165806
Fixed testgles on iOS (bug 1136)
Sam Lantinga <slouken@libsdl.org>
parents:
4961
diff
changeset
|
264 |
|
3139 | 265 |
status = SDL_GL_MakeCurrent(state->windows[i], context[i]); |
266 |
if (status) { |
|
7639
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
267 |
SDL_Log("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
|
268 |
|
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 |
/* 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
|
270 |
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
|
271 |
} |
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 |
|
5363
96799a165806
Fixed testgles on iOS (bug 1136)
Sam Lantinga <slouken@libsdl.org>
parents:
4961
diff
changeset
|
273 |
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
|
274 |
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
|
275 |
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
|
276 |
glLoadIdentity(); |
5363
96799a165806
Fixed testgles on iOS (bug 1136)
Sam Lantinga <slouken@libsdl.org>
parents:
4961
diff
changeset
|
277 |
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
|
278 |
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
|
279 |
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
|
280 |
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
|
281 |
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
|
282 |
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
|
283 |
} |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 |
/* Main render loop */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 |
frames = 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 |
then = SDL_GetTicks(); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 |
done = 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
289 |
while (!done) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
290 |
/* Check for events */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 |
++frames; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
292 |
while (SDL_PollEvent(&event)) { |
3194
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
293 |
switch (event.type) { |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
294 |
case SDL_WINDOWEVENT: |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
295 |
switch (event.window.event) { |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
296 |
case SDL_WINDOWEVENT_RESIZED: |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
297 |
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
|
298 |
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
|
299 |
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
|
300 |
if (status) { |
7639
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
301 |
SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); |
3194
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
302 |
break; |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
303 |
} |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
304 |
/* 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
|
305 |
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
|
306 |
/* Update window content */ |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
307 |
Render(); |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
308 |
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
|
309 |
break; |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
310 |
} |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
311 |
} |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
312 |
break; |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
313 |
} |
c18c03927a77
Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
314 |
} |
6785
c094c438c0a6
Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents:
5535
diff
changeset
|
315 |
SDLTest_CommonEvent(state, &event, &done); |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
316 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 |
for (i = 0; i < state->num_windows; ++i) { |
7787
e6f3e8fc96ea
Fixed bug 2132 - Tests may use invalid SDL_window pointers when windows are closed
Sam Lantinga <slouken@libsdl.org>
parents:
7639
diff
changeset
|
318 |
if (state->windows[i] == NULL) |
e6f3e8fc96ea
Fixed bug 2132 - Tests may use invalid SDL_window pointers when windows are closed
Sam Lantinga <slouken@libsdl.org>
parents:
7639
diff
changeset
|
319 |
continue; |
3139 | 320 |
status = SDL_GL_MakeCurrent(state->windows[i], context[i]); |
321 |
if (status) { |
|
7639
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
322 |
SDL_Log("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
|
323 |
|
3139 | 324 |
/* Continue for next window */ |
325 |
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
|
326 |
} |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 |
Render(); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
328 |
SDL_GL_SwapWindow(state->windows[i]); |
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 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
332 |
/* Print out some timing information */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
333 |
now = SDL_GetTicks(); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
334 |
if (now > then) { |
7639
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
335 |
SDL_Log("%2.2f frames per second\n", |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 |
((double) frames * 1000) / (now - then)); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
337 |
} |
7910
261addaa47d0
[Android] Fixes Bug 2041 - can't get SDL_QUIT event...
Gabriel Jacobo <gabomdq@gmail.com>
parents:
7796
diff
changeset
|
338 |
#if !defined(__ANDROID__) |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
339 |
quit(0); |
7910
261addaa47d0
[Android] Fixes Bug 2041 - can't get SDL_QUIT event...
Gabriel Jacobo <gabomdq@gmail.com>
parents:
7796
diff
changeset
|
340 |
#endif |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 |
return 0; |
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 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 |
#else /* HAVE_OPENGLES */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
346 |
int |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 |
main(int argc, char *argv[]) |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
348 |
{ |
7639
9406b7dd2f2d
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
7517
diff
changeset
|
349 |
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL ES support on this system\n"); |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
350 |
return 1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
353 |
#endif /* HAVE_OPENGLES */ |
5363
96799a165806
Fixed testgles on iOS (bug 1136)
Sam Lantinga <slouken@libsdl.org>
parents:
4961
diff
changeset
|
354 |
|
96799a165806
Fixed testgles on iOS (bug 1136)
Sam Lantinga <slouken@libsdl.org>
parents:
4961
diff
changeset
|
355 |
/* vi: set ts=4 sw=4 expandtab: */ |