Mercurial > sdl-ios-xcode
annotate test/testgl.c @ 1654:0a53c90a37f9 SDL-1.3
Updated to 1.3.0, SDL_OPENGLBLIT is no longer supported
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 27 Apr 2006 05:30:05 +0000 |
parents | 4d3bb026cd16 |
children | 96c2f89cc7e1 |
rev | line source |
---|---|
0 | 1 #include <stdlib.h> |
2 #include <stdio.h> | |
3 #include <string.h> | |
4 #include <math.h> | |
5 | |
6 #include "SDL.h" | |
7 | |
8 #ifdef HAVE_OPENGL | |
234
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
9 |
214
0e5d6dd77bda
Added platform independent OpenGL header - SDL_opengl.h
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
10 #include "SDL_opengl.h" |
0 | 11 |
234
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
12 /* Undefine this if you want a flat cube instead of a rainbow cube */ |
0 | 13 #define SHADED_CUBE |
14 | |
234
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
15 /* Define this to be the name of the logo image to use with -logo */ |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
16 #define LOGO_FILE "icon.bmp" |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
17 |
492
c59692dcdce0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
363
diff
changeset
|
18 static SDL_Surface *global_image = NULL; |
c59692dcdce0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
363
diff
changeset
|
19 static GLuint global_texture = 0; |
933
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
20 static GLuint cursor_texture = 0; |
492
c59692dcdce0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
363
diff
changeset
|
21 |
234
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
22 /**********************************************************************/ |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
23 |
0 | 24 void HotKey_ToggleFullScreen(void) |
25 { | |
26 SDL_Surface *screen; | |
27 | |
28 screen = SDL_GetVideoSurface(); | |
29 if ( SDL_WM_ToggleFullScreen(screen) ) { | |
30 printf("Toggled fullscreen mode - now %s\n", | |
31 (screen->flags&SDL_FULLSCREEN) ? "fullscreen" : "windowed"); | |
32 } else { | |
33 printf("Unable to toggle fullscreen mode\n"); | |
34 } | |
35 } | |
36 | |
37 void HotKey_ToggleGrab(void) | |
38 { | |
39 SDL_GrabMode mode; | |
40 | |
41 printf("Ctrl-G: toggling input grab!\n"); | |
42 mode = SDL_WM_GrabInput(SDL_GRAB_QUERY); | |
43 if ( mode == SDL_GRAB_ON ) { | |
44 printf("Grab was on\n"); | |
45 } else { | |
46 printf("Grab was off\n"); | |
47 } | |
48 mode = SDL_WM_GrabInput(!mode); | |
49 if ( mode == SDL_GRAB_ON ) { | |
50 printf("Grab is now on\n"); | |
51 } else { | |
52 printf("Grab is now off\n"); | |
53 } | |
54 } | |
55 | |
56 void HotKey_Iconify(void) | |
57 { | |
58 printf("Ctrl-Z: iconifying window!\n"); | |
59 SDL_WM_IconifyWindow(); | |
60 } | |
61 | |
62 int HandleEvent(SDL_Event *event) | |
63 { | |
64 int done; | |
65 | |
66 done = 0; | |
67 switch( event->type ) { | |
68 case SDL_ACTIVEEVENT: | |
69 /* See what happened */ | |
70 printf( "app %s ", event->active.gain ? "gained" : "lost" ); | |
71 if ( event->active.state & SDL_APPACTIVE ) { | |
72 printf( "active " ); | |
73 } else if ( event->active.state & SDL_APPMOUSEFOCUS ) { | |
74 printf( "mouse " ); | |
75 } else if ( event->active.state & SDL_APPINPUTFOCUS ) { | |
76 printf( "input " ); | |
77 } | |
78 printf( "focus\n" ); | |
79 break; | |
80 | |
81 | |
82 case SDL_KEYDOWN: | |
83 if ( event->key.keysym.sym == SDLK_ESCAPE ) { | |
84 done = 1; | |
85 } | |
86 if ( (event->key.keysym.sym == SDLK_g) && | |
87 (event->key.keysym.mod & KMOD_CTRL) ) { | |
88 HotKey_ToggleGrab(); | |
89 } | |
90 if ( (event->key.keysym.sym == SDLK_z) && | |
91 (event->key.keysym.mod & KMOD_CTRL) ) { | |
92 HotKey_Iconify(); | |
93 } | |
94 if ( (event->key.keysym.sym == SDLK_RETURN) && | |
95 (event->key.keysym.mod & KMOD_ALT) ) { | |
96 HotKey_ToggleFullScreen(); | |
97 } | |
98 printf("key '%s' pressed\n", | |
99 SDL_GetKeyName(event->key.keysym.sym)); | |
100 break; | |
101 case SDL_QUIT: | |
102 done = 1; | |
103 break; | |
104 } | |
105 return(done); | |
106 } | |
107 | |
233
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
108 void SDL_GL_Enter2DMode() |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
109 { |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
110 SDL_Surface *screen = SDL_GetVideoSurface(); |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
111 |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
112 /* Note, there may be other things you need to change, |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
113 depending on how you have your OpenGL state set up. |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
114 */ |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
115 glPushAttrib(GL_ENABLE_BIT); |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
116 glDisable(GL_DEPTH_TEST); |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
117 glDisable(GL_CULL_FACE); |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
118 glEnable(GL_TEXTURE_2D); |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
119 |
243
cf4944faad96
Fixed testgl so that SDL_GL_Enter2DMode() allows alpha blending
Sam Lantinga <slouken@libsdl.org>
parents:
234
diff
changeset
|
120 /* This allows alpha blending of 2D textures with the scene */ |
cf4944faad96
Fixed testgl so that SDL_GL_Enter2DMode() allows alpha blending
Sam Lantinga <slouken@libsdl.org>
parents:
234
diff
changeset
|
121 glEnable(GL_BLEND); |
cf4944faad96
Fixed testgl so that SDL_GL_Enter2DMode() allows alpha blending
Sam Lantinga <slouken@libsdl.org>
parents:
234
diff
changeset
|
122 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
cf4944faad96
Fixed testgl so that SDL_GL_Enter2DMode() allows alpha blending
Sam Lantinga <slouken@libsdl.org>
parents:
234
diff
changeset
|
123 |
233
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
124 glViewport(0, 0, screen->w, screen->h); |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
125 |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
126 glMatrixMode(GL_PROJECTION); |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
127 glPushMatrix(); |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
128 glLoadIdentity(); |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
129 |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
130 glOrtho(0.0, (GLdouble)screen->w, (GLdouble)screen->h, 0.0, 0.0, 1.0); |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
131 |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
132 glMatrixMode(GL_MODELVIEW); |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
133 glPushMatrix(); |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
134 glLoadIdentity(); |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
135 |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
136 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
137 } |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
138 |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
139 void SDL_GL_Leave2DMode() |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
140 { |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
141 glMatrixMode(GL_MODELVIEW); |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
142 glPopMatrix(); |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
143 |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
144 glMatrixMode(GL_PROJECTION); |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
145 glPopMatrix(); |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
146 |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
147 glPopAttrib(); |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
148 } |
5b42a7f5fab3
SDL_OPENGLBLIT is deprecated, show the "right way" of doing things
Sam Lantinga <slouken@libsdl.org>
parents:
221
diff
changeset
|
149 |
234
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
150 /* Quick utility function for texture creation */ |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
151 static int power_of_two(int input) |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
152 { |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
153 int value = 1; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
154 |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
155 while ( value < input ) { |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
156 value <<= 1; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
157 } |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
158 return value; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
159 } |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
160 |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
161 GLuint SDL_GL_LoadTexture(SDL_Surface *surface, GLfloat *texcoord) |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
162 { |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
163 GLuint texture; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
164 int w, h; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
165 SDL_Surface *image; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
166 SDL_Rect area; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
167 Uint32 saved_flags; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
168 Uint8 saved_alpha; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
169 |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
170 /* Use the surface width and height expanded to powers of 2 */ |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
171 w = power_of_two(surface->w); |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
172 h = power_of_two(surface->h); |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
173 texcoord[0] = 0.0f; /* Min X */ |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
174 texcoord[1] = 0.0f; /* Min Y */ |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
175 texcoord[2] = (GLfloat)surface->w / w; /* Max X */ |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
176 texcoord[3] = (GLfloat)surface->h / h; /* Max Y */ |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
177 |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
178 image = SDL_CreateRGBSurface( |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
179 SDL_SWSURFACE, |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
180 w, h, |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
181 32, |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
182 #if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */ |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
183 0x000000FF, |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
184 0x0000FF00, |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
185 0x00FF0000, |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
186 0xFF000000 |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
187 #else |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
188 0xFF000000, |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
189 0x00FF0000, |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
190 0x0000FF00, |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
191 0x000000FF |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
192 #endif |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
193 ); |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
194 if ( image == NULL ) { |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
195 return 0; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
196 } |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
197 |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
198 /* Save the alpha blending attributes */ |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
199 saved_flags = surface->flags&(SDL_SRCALPHA|SDL_RLEACCELOK); |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
200 saved_alpha = surface->format->alpha; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
201 if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) { |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
202 SDL_SetAlpha(surface, 0, 0); |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
203 } |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
204 |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
205 /* Copy the surface into the GL texture image */ |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
206 area.x = 0; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
207 area.y = 0; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
208 area.w = surface->w; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
209 area.h = surface->h; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
210 SDL_BlitSurface(surface, &area, image, &area); |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
211 |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
212 /* Restore the alpha blending attributes */ |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
213 if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) { |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
214 SDL_SetAlpha(surface, saved_flags, saved_alpha); |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
215 } |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
216 |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
217 /* Create an OpenGL texture for the image */ |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
218 glGenTextures(1, &texture); |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
219 glBindTexture(GL_TEXTURE_2D, texture); |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
220 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
221 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
222 glTexImage2D(GL_TEXTURE_2D, |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
223 0, |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
224 GL_RGBA, |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
225 w, h, |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
226 0, |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
227 GL_RGBA, |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
228 GL_UNSIGNED_BYTE, |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
229 image->pixels); |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
230 SDL_FreeSurface(image); /* No longer needed */ |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
231 |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
232 return texture; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
233 } |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
234 |
933
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
235 void DrawLogoCursor(void) |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
236 { |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
237 static GLfloat texMinX, texMinY; |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
238 static GLfloat texMaxX, texMaxY; |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
239 static int w, h; |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
240 int x, y; |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
241 |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
242 if ( ! cursor_texture ) { |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
243 SDL_Surface *image; |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
244 GLfloat texcoord[4]; |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
245 |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
246 /* Load the image (could use SDL_image library here) */ |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
247 image = SDL_LoadBMP(LOGO_FILE); |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
248 if ( image == NULL ) { |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
249 return; |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
250 } |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
251 w = image->w; |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
252 h = image->h; |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
253 |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
254 /* Convert the image into an OpenGL texture */ |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
255 cursor_texture = SDL_GL_LoadTexture(image, texcoord); |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
256 |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
257 /* Make texture coordinates easy to understand */ |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
258 texMinX = texcoord[0]; |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
259 texMinY = texcoord[1]; |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
260 texMaxX = texcoord[2]; |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
261 texMaxY = texcoord[3]; |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
262 |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
263 /* We don't need the original image anymore */ |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
264 SDL_FreeSurface(image); |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
265 |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
266 /* Make sure that the texture conversion is okay */ |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
267 if ( ! cursor_texture ) { |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
268 return; |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
269 } |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
270 } |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
271 |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
272 /* Move the image around */ |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
273 SDL_GetMouseState(&x, &y); |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
274 x -= w/2; |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
275 y -= h/2; |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
276 |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
277 /* Show the image on the screen */ |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
278 SDL_GL_Enter2DMode(); |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
279 glBindTexture(GL_TEXTURE_2D, cursor_texture); |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
280 glBegin(GL_TRIANGLE_STRIP); |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
281 glTexCoord2f(texMinX, texMinY); glVertex2i(x, y ); |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
282 glTexCoord2f(texMaxX, texMinY); glVertex2i(x+w, y ); |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
283 glTexCoord2f(texMinX, texMaxY); glVertex2i(x, y+h); |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
284 glTexCoord2f(texMaxX, texMaxY); glVertex2i(x+w, y+h); |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
285 glEnd(); |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
286 SDL_GL_Leave2DMode(); |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
287 } |
492
c59692dcdce0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
363
diff
changeset
|
288 |
234
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
289 void DrawLogoTexture(void) |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
290 { |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
291 static GLfloat texMinX, texMinY; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
292 static GLfloat texMaxX, texMaxY; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
293 static int x = 0; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
294 static int y = 0; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
295 static int w, h; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
296 static int delta_x = 1; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
297 static int delta_y = 1; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
298 |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
299 SDL_Surface *screen = SDL_GetVideoSurface(); |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
300 |
492
c59692dcdce0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
363
diff
changeset
|
301 if ( ! global_texture ) { |
234
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
302 SDL_Surface *image; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
303 GLfloat texcoord[4]; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
304 |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
305 /* Load the image (could use SDL_image library here) */ |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
306 image = SDL_LoadBMP(LOGO_FILE); |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
307 if ( image == NULL ) { |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
308 return; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
309 } |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
310 w = image->w; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
311 h = image->h; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
312 |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
313 /* Convert the image into an OpenGL texture */ |
492
c59692dcdce0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
363
diff
changeset
|
314 global_texture = SDL_GL_LoadTexture(image, texcoord); |
234
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
315 |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
316 /* Make texture coordinates easy to understand */ |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
317 texMinX = texcoord[0]; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
318 texMinY = texcoord[1]; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
319 texMaxX = texcoord[2]; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
320 texMaxY = texcoord[3]; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
321 |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
322 /* We don't need the original image anymore */ |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
323 SDL_FreeSurface(image); |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
324 |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
325 /* Make sure that the texture conversion is okay */ |
492
c59692dcdce0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
363
diff
changeset
|
326 if ( ! global_texture ) { |
234
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
327 return; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
328 } |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
329 } |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
330 |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
331 /* Move the image around */ |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
332 x += delta_x; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
333 if ( x < 0 ) { |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
334 x = 0; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
335 delta_x = -delta_x; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
336 } else |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
337 if ( (x+w) > screen->w ) { |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
338 x = screen->w-w; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
339 delta_x = -delta_x; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
340 } |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
341 y += delta_y; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
342 if ( y < 0 ) { |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
343 y = 0; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
344 delta_y = -delta_y; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
345 } else |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
346 if ( (y+h) > screen->h ) { |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
347 y = screen->h-h; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
348 delta_y = -delta_y; |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
349 } |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
350 |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
351 /* Show the image on the screen */ |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
352 SDL_GL_Enter2DMode(); |
492
c59692dcdce0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
363
diff
changeset
|
353 glBindTexture(GL_TEXTURE_2D, global_texture); |
234
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
354 glBegin(GL_TRIANGLE_STRIP); |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
355 glTexCoord2f(texMinX, texMinY); glVertex2i(x, y ); |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
356 glTexCoord2f(texMaxX, texMinY); glVertex2i(x+w, y ); |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
357 glTexCoord2f(texMinX, texMaxY); glVertex2i(x, y+h); |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
358 glTexCoord2f(texMaxX, texMaxY); glVertex2i(x+w, y+h); |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
359 glEnd(); |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
360 SDL_GL_Leave2DMode(); |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
361 } |
1af4be6a73cd
Modified the logo texture load to accept any width/height image
Sam Lantinga <slouken@libsdl.org>
parents:
233
diff
changeset
|
362 |
0 | 363 int RunGLTest( int argc, char* argv[], |
933
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
364 int logo, int logocursor, int slowly, int bpp, float gamma, int noframe, int fsaa ) |
0 | 365 { |
366 int i; | |
367 int rgb_size[3]; | |
368 int w = 640; | |
369 int h = 480; | |
370 int done = 0; | |
371 int frames; | |
372 Uint32 start_time, this_time; | |
373 float color[8][3]= {{ 1.0, 1.0, 0.0}, | |
374 { 1.0, 0.0, 0.0}, | |
375 { 0.0, 0.0, 0.0}, | |
376 { 0.0, 1.0, 0.0}, | |
377 { 0.0, 1.0, 1.0}, | |
378 { 1.0, 1.0, 1.0}, | |
379 { 1.0, 0.0, 1.0}, | |
380 { 0.0, 0.0, 1.0}}; | |
381 float cube[8][3]= {{ 0.5, 0.5, -0.5}, | |
382 { 0.5, -0.5, -0.5}, | |
383 {-0.5, -0.5, -0.5}, | |
384 {-0.5, 0.5, -0.5}, | |
385 {-0.5, 0.5, 0.5}, | |
386 { 0.5, 0.5, 0.5}, | |
387 { 0.5, -0.5, 0.5}, | |
388 {-0.5, -0.5, 0.5}}; | |
389 Uint32 video_flags; | |
390 int value; | |
391 | |
392 if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) { | |
393 fprintf(stderr,"Couldn't initialize SDL: %s\n",SDL_GetError()); | |
394 exit( 1 ); | |
395 } | |
396 | |
397 /* See if we should detect the display depth */ | |
398 if ( bpp == 0 ) { | |
399 if ( SDL_GetVideoInfo()->vfmt->BitsPerPixel <= 8 ) { | |
400 bpp = 8; | |
401 } else { | |
402 bpp = 16; /* More doesn't seem to work */ | |
403 } | |
404 } | |
405 | |
406 /* Set the flags we want to use for setting the video mode */ | |
1654
0a53c90a37f9
Updated to 1.3.0, SDL_OPENGLBLIT is no longer supported
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
407 video_flags = SDL_OPENGL; |
0 | 408 for ( i=1; argv[i]; ++i ) { |
1265
670e74bf5cc8
Date: Mon, 22 Sep 2003 23:31:54 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents:
933
diff
changeset
|
409 if ( strcmp(argv[i], "-fullscreen") == 0 ) { |
0 | 410 video_flags |= SDL_FULLSCREEN; |
411 } | |
412 } | |
413 | |
320
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
243
diff
changeset
|
414 if (noframe) { |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
243
diff
changeset
|
415 video_flags |= SDL_NOFRAME; |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
243
diff
changeset
|
416 } |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
243
diff
changeset
|
417 |
0 | 418 /* Initialize the display */ |
419 switch (bpp) { | |
420 case 8: | |
363
ca0b4ba5313e
Date: Thu, 18 Apr 2002 13:50:53 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
320
diff
changeset
|
421 rgb_size[0] = 3; |
0 | 422 rgb_size[1] = 3; |
363
ca0b4ba5313e
Date: Thu, 18 Apr 2002 13:50:53 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
320
diff
changeset
|
423 rgb_size[2] = 2; |
0 | 424 break; |
425 case 15: | |
426 case 16: | |
427 rgb_size[0] = 5; | |
428 rgb_size[1] = 5; | |
429 rgb_size[2] = 5; | |
430 break; | |
431 default: | |
432 rgb_size[0] = 8; | |
433 rgb_size[1] = 8; | |
434 rgb_size[2] = 8; | |
435 break; | |
436 } | |
437 SDL_GL_SetAttribute( SDL_GL_RED_SIZE, rgb_size[0] ); | |
438 SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, rgb_size[1] ); | |
439 SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, rgb_size[2] ); | |
440 SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ); | |
441 SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); | |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
492
diff
changeset
|
442 if ( fsaa ) { |
656
864e2d2a9a55
Merged in Ryan's multisample code for MacOS, and changed the constants to match.
Sam Lantinga <slouken@libsdl.org>
parents:
655
diff
changeset
|
443 SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ); |
864e2d2a9a55
Merged in Ryan's multisample code for MacOS, and changed the constants to match.
Sam Lantinga <slouken@libsdl.org>
parents:
655
diff
changeset
|
444 SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, fsaa ); |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
492
diff
changeset
|
445 } |
0 | 446 if ( SDL_SetVideoMode( w, h, bpp, video_flags ) == NULL ) { |
447 fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError()); | |
448 SDL_Quit(); | |
449 exit(1); | |
450 } | |
451 | |
452 printf("Screen BPP: %d\n", SDL_GetVideoSurface()->format->BitsPerPixel); | |
453 printf("\n"); | |
454 printf( "Vendor : %s\n", glGetString( GL_VENDOR ) ); | |
455 printf( "Renderer : %s\n", glGetString( GL_RENDERER ) ); | |
456 printf( "Version : %s\n", glGetString( GL_VERSION ) ); | |
457 printf( "Extensions : %s\n", glGetString( GL_EXTENSIONS ) ); | |
458 printf("\n"); | |
459 | |
460 SDL_GL_GetAttribute( SDL_GL_RED_SIZE, &value ); | |
461 printf( "SDL_GL_RED_SIZE: requested %d, got %d\n", rgb_size[0],value); | |
462 SDL_GL_GetAttribute( SDL_GL_GREEN_SIZE, &value ); | |
463 printf( "SDL_GL_GREEN_SIZE: requested %d, got %d\n", rgb_size[1],value); | |
464 SDL_GL_GetAttribute( SDL_GL_BLUE_SIZE, &value ); | |
465 printf( "SDL_GL_BLUE_SIZE: requested %d, got %d\n", rgb_size[2],value); | |
466 SDL_GL_GetAttribute( SDL_GL_DEPTH_SIZE, &value ); | |
467 printf( "SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value ); | |
468 SDL_GL_GetAttribute( SDL_GL_DOUBLEBUFFER, &value ); | |
469 printf( "SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value ); | |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
492
diff
changeset
|
470 if ( fsaa ) { |
656
864e2d2a9a55
Merged in Ryan's multisample code for MacOS, and changed the constants to match.
Sam Lantinga <slouken@libsdl.org>
parents:
655
diff
changeset
|
471 SDL_GL_GetAttribute( SDL_GL_MULTISAMPLEBUFFERS, &value ); |
864e2d2a9a55
Merged in Ryan's multisample code for MacOS, and changed the constants to match.
Sam Lantinga <slouken@libsdl.org>
parents:
655
diff
changeset
|
472 printf( "SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value ); |
864e2d2a9a55
Merged in Ryan's multisample code for MacOS, and changed the constants to match.
Sam Lantinga <slouken@libsdl.org>
parents:
655
diff
changeset
|
473 SDL_GL_GetAttribute( SDL_GL_MULTISAMPLESAMPLES, &value ); |
864e2d2a9a55
Merged in Ryan's multisample code for MacOS, and changed the constants to match.
Sam Lantinga <slouken@libsdl.org>
parents:
655
diff
changeset
|
474 printf( "SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, value ); |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
492
diff
changeset
|
475 } |
0 | 476 |
477 /* Set the window manager title bar */ | |
478 SDL_WM_SetCaption( "SDL GL test", "testgl" ); | |
479 | |
480 /* Set the gamma for the window */ | |
481 if ( gamma != 0.0 ) { | |
482 SDL_SetGamma(gamma, gamma, gamma); | |
483 } | |
484 | |
485 glViewport( 0, 0, w, h ); | |
486 glMatrixMode( GL_PROJECTION ); | |
487 glLoadIdentity( ); | |
488 | |
489 glOrtho( -2.0, 2.0, -2.0, 2.0, -20.0, 20.0 ); | |
490 | |
491 glMatrixMode( GL_MODELVIEW ); | |
492 glLoadIdentity( ); | |
493 | |
494 glEnable(GL_DEPTH_TEST); | |
495 | |
496 glDepthFunc(GL_LESS); | |
497 | |
498 glShadeModel(GL_SMOOTH); | |
499 | |
500 /* Loop until done. */ | |
501 start_time = SDL_GetTicks(); | |
502 frames = 0; | |
503 while( !done ) { | |
504 GLenum gl_error; | |
505 char* sdl_error; | |
506 SDL_Event event; | |
507 | |
508 /* Do our drawing, too. */ | |
509 glClearColor( 0.0, 0.0, 0.0, 1.0 ); | |
510 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | |
511 | |
512 glBegin( GL_QUADS ); | |
513 | |
514 #ifdef SHADED_CUBE | |
515 glColor3fv(color[0]); | |
516 glVertex3fv(cube[0]); | |
517 glColor3fv(color[1]); | |
518 glVertex3fv(cube[1]); | |
519 glColor3fv(color[2]); | |
520 glVertex3fv(cube[2]); | |
521 glColor3fv(color[3]); | |
522 glVertex3fv(cube[3]); | |
523 | |
524 glColor3fv(color[3]); | |
525 glVertex3fv(cube[3]); | |
526 glColor3fv(color[4]); | |
527 glVertex3fv(cube[4]); | |
528 glColor3fv(color[7]); | |
529 glVertex3fv(cube[7]); | |
530 glColor3fv(color[2]); | |
531 glVertex3fv(cube[2]); | |
532 | |
533 glColor3fv(color[0]); | |
534 glVertex3fv(cube[0]); | |
535 glColor3fv(color[5]); | |
536 glVertex3fv(cube[5]); | |
537 glColor3fv(color[6]); | |
538 glVertex3fv(cube[6]); | |
539 glColor3fv(color[1]); | |
540 glVertex3fv(cube[1]); | |
541 | |
542 glColor3fv(color[5]); | |
543 glVertex3fv(cube[5]); | |
544 glColor3fv(color[4]); | |
545 glVertex3fv(cube[4]); | |
546 glColor3fv(color[7]); | |
547 glVertex3fv(cube[7]); | |
548 glColor3fv(color[6]); | |
549 glVertex3fv(cube[6]); | |
550 | |
551 glColor3fv(color[5]); | |
552 glVertex3fv(cube[5]); | |
553 glColor3fv(color[0]); | |
554 glVertex3fv(cube[0]); | |
555 glColor3fv(color[3]); | |
556 glVertex3fv(cube[3]); | |
557 glColor3fv(color[4]); | |
558 glVertex3fv(cube[4]); | |
559 | |
560 glColor3fv(color[6]); | |
561 glVertex3fv(cube[6]); | |
562 glColor3fv(color[1]); | |
563 glVertex3fv(cube[1]); | |
564 glColor3fv(color[2]); | |
565 glVertex3fv(cube[2]); | |
566 glColor3fv(color[7]); | |
567 glVertex3fv(cube[7]); | |
1439
4d3bb026cd16
Fixed warnings in -pedantic mode
Sam Lantinga <slouken@libsdl.org>
parents:
1265
diff
changeset
|
568 #else /* flat cube */ |
0 | 569 glColor3f(1.0, 0.0, 0.0); |
570 glVertex3fv(cube[0]); | |
571 glVertex3fv(cube[1]); | |
572 glVertex3fv(cube[2]); | |
573 glVertex3fv(cube[3]); | |
574 | |
575 glColor3f(0.0, 1.0, 0.0); | |
576 glVertex3fv(cube[3]); | |
577 glVertex3fv(cube[4]); | |
578 glVertex3fv(cube[7]); | |
579 glVertex3fv(cube[2]); | |
580 | |
581 glColor3f(0.0, 0.0, 1.0); | |
582 glVertex3fv(cube[0]); | |
583 glVertex3fv(cube[5]); | |
584 glVertex3fv(cube[6]); | |
585 glVertex3fv(cube[1]); | |
586 | |
587 glColor3f(0.0, 1.0, 1.0); | |
588 glVertex3fv(cube[5]); | |
589 glVertex3fv(cube[4]); | |
590 glVertex3fv(cube[7]); | |
591 glVertex3fv(cube[6]); | |
592 | |
593 glColor3f(1.0, 1.0, 0.0); | |
594 glVertex3fv(cube[5]); | |
595 glVertex3fv(cube[0]); | |
596 glVertex3fv(cube[3]); | |
597 glVertex3fv(cube[4]); | |
598 | |
599 glColor3f(1.0, 0.0, 1.0); | |
600 glVertex3fv(cube[6]); | |
601 glVertex3fv(cube[1]); | |
602 glVertex3fv(cube[2]); | |
603 glVertex3fv(cube[7]); | |
604 #endif /* SHADED_CUBE */ | |
605 | |
606 glEnd( ); | |
607 | |
608 glMatrixMode(GL_MODELVIEW); | |
609 glRotatef(5.0, 1.0, 1.0, 1.0); | |
610 | |
611 /* Draw 2D logo onto the 3D display */ | |
612 if ( logo ) { | |
1654
0a53c90a37f9
Updated to 1.3.0, SDL_OPENGLBLIT is no longer supported
Sam Lantinga <slouken@libsdl.org>
parents:
1439
diff
changeset
|
613 DrawLogoTexture(); |
0 | 614 } |
933
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
615 if ( logocursor ) { |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
616 DrawLogoCursor(); |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
617 } |
0 | 618 |
619 SDL_GL_SwapBuffers( ); | |
620 | |
621 /* Check for error conditions. */ | |
622 gl_error = glGetError( ); | |
623 | |
624 if( gl_error != GL_NO_ERROR ) { | |
625 fprintf( stderr, "testgl: OpenGL error: %d\n", gl_error ); | |
626 } | |
627 | |
628 sdl_error = SDL_GetError( ); | |
629 | |
630 if( sdl_error[0] != '\0' ) { | |
631 fprintf(stderr, "testgl: SDL error '%s'\n", sdl_error); | |
632 SDL_ClearError(); | |
633 } | |
634 | |
635 /* Allow the user to see what's happening */ | |
636 if ( slowly ) { | |
637 SDL_Delay( 20 ); | |
638 } | |
639 | |
640 /* Check if there's a pending event. */ | |
641 while( SDL_PollEvent( &event ) ) { | |
642 done = HandleEvent(&event); | |
643 } | |
644 ++frames; | |
645 } | |
646 | |
647 /* Print out the frames per second */ | |
648 this_time = SDL_GetTicks(); | |
649 if ( this_time != start_time ) { | |
650 printf("%2.2f FPS\n", | |
651 ((float)frames/(this_time-start_time))*1000.0); | |
652 } | |
653 | |
492
c59692dcdce0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
363
diff
changeset
|
654 if ( global_image ) { |
c59692dcdce0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
363
diff
changeset
|
655 SDL_FreeSurface(global_image); |
c59692dcdce0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
363
diff
changeset
|
656 global_image = NULL; |
c59692dcdce0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
363
diff
changeset
|
657 } |
c59692dcdce0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
363
diff
changeset
|
658 if ( global_texture ) { |
c59692dcdce0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
363
diff
changeset
|
659 glDeleteTextures( 1, &global_texture ); |
c59692dcdce0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
363
diff
changeset
|
660 global_texture = 0; |
c59692dcdce0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
363
diff
changeset
|
661 } |
933
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
662 if ( cursor_texture ) { |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
663 glDeleteTextures( 1, &cursor_texture ); |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
664 cursor_texture = 0; |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
665 } |
492
c59692dcdce0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
363
diff
changeset
|
666 |
0 | 667 /* Destroy our GL context, etc. */ |
668 SDL_Quit( ); | |
669 return(0); | |
670 } | |
671 | |
672 int main(int argc, char *argv[]) | |
673 { | |
1439
4d3bb026cd16
Fixed warnings in -pedantic mode
Sam Lantinga <slouken@libsdl.org>
parents:
1265
diff
changeset
|
674 int i, logo, logocursor = 0; |
0 | 675 int numtests; |
676 int bpp = 0; | |
677 int slowly; | |
678 float gamma = 0.0; | |
492
c59692dcdce0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
363
diff
changeset
|
679 int noframe = 0; |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
492
diff
changeset
|
680 int fsaa = 0; |
0 | 681 |
682 logo = 0; | |
683 slowly = 0; | |
684 numtests = 1; | |
685 for ( i=1; argv[i]; ++i ) { | |
686 if ( strcmp(argv[i], "-twice") == 0 ) { | |
687 ++numtests; | |
688 } | |
689 if ( strcmp(argv[i], "-logo") == 0 ) { | |
690 logo = 1; | |
691 } | |
933
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
692 if ( strcmp(argv[i], "-logocursor") == 0 ) { |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
693 logocursor = 1; |
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
694 } |
0 | 695 if ( strcmp(argv[i], "-slow") == 0 ) { |
696 slowly = 1; | |
697 } | |
698 if ( strcmp(argv[i], "-bpp") == 0 ) { | |
699 bpp = atoi(argv[++i]); | |
700 } | |
701 if ( strcmp(argv[i], "-gamma") == 0 ) { | |
702 gamma = (float)atof(argv[++i]); | |
703 } | |
320
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
243
diff
changeset
|
704 if ( strcmp(argv[i], "-noframe") == 0 ) { |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
243
diff
changeset
|
705 noframe = 1; |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
243
diff
changeset
|
706 } |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
492
diff
changeset
|
707 if ( strcmp(argv[i], "-fsaa") == 0 ) { |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
492
diff
changeset
|
708 ++fsaa; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
492
diff
changeset
|
709 } |
0 | 710 if ( strncmp(argv[i], "-h", 2) == 0 ) { |
711 printf( | |
933
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
712 "Usage: %s [-twice] [-logo] [-logocursor] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa] [-fullscreen]\n", |
0 | 713 argv[0]); |
714 exit(0); | |
715 } | |
716 } | |
717 for ( i=0; i<numtests; ++i ) { | |
933
4272450dd8d0
Added an option to show the logo at the cursor position for debugging
Sam Lantinga <slouken@libsdl.org>
parents:
910
diff
changeset
|
718 RunGLTest(argc, argv, logo, logocursor, slowly, bpp, gamma, noframe, fsaa); |
0 | 719 } |
720 return 0; | |
721 } | |
722 | |
723 #else /* HAVE_OPENGL */ | |
724 | |
725 int main(int argc, char *argv[]) | |
726 { | |
727 printf("No OpenGL support on this system\n"); | |
728 return 1; | |
729 } | |
730 | |
731 #endif /* HAVE_OPENGL */ |