| 1 |
root |
1.1 |
#include <stdlib.h> |
| 2 |
|
|
#include <stdio.h> |
| 3 |
|
|
#include <string.h> |
| 4 |
|
|
#include <math.h> |
| 5 |
|
|
|
| 6 |
|
|
#include "SDL.h" |
| 7 |
|
|
|
| 8 |
|
|
#include "SDL_opengl.h" |
| 9 |
|
|
|
| 10 |
|
|
/* Undefine this if you want a flat cube instead of a rainbow cube */ |
| 11 |
|
|
#define SHADED_CUBE |
| 12 |
|
|
|
| 13 |
|
|
/* Define this to be the name of the logo image to use with -logo */ |
| 14 |
|
|
#define LOGO_FILE "icon.bmp" |
| 15 |
|
|
|
| 16 |
|
|
static SDL_Surface *global_image = NULL; |
| 17 |
|
|
static GLuint global_texture = 0; |
| 18 |
|
|
|
| 19 |
root |
1.2 |
#include "entity.h" |
| 20 |
|
|
|
| 21 |
root |
1.4 |
#include "txtprt_import.h" |
| 22 |
|
|
|
| 23 |
root |
1.1 |
/**********************************************************************/ |
| 24 |
|
|
|
| 25 |
root |
1.6 |
view camera; |
| 26 |
|
|
|
| 27 |
root |
1.1 |
void |
| 28 |
|
|
HotKey_ToggleFullScreen (void) |
| 29 |
|
|
{ |
| 30 |
|
|
SDL_Surface *screen; |
| 31 |
|
|
|
| 32 |
|
|
screen = SDL_GetVideoSurface (); |
| 33 |
|
|
if (SDL_WM_ToggleFullScreen (screen)) |
| 34 |
root |
1.5 |
printf ("Toggled fullscreen mode - now %s\n", |
| 35 |
|
|
(screen->flags & SDL_FULLSCREEN) ? "fullscreen" : "windowed"); |
| 36 |
root |
1.1 |
else |
| 37 |
root |
1.5 |
printf ("Unable to toggle fullscreen mode\n"); |
| 38 |
root |
1.1 |
} |
| 39 |
|
|
|
| 40 |
|
|
void |
| 41 |
|
|
HotKey_ToggleGrab (void) |
| 42 |
|
|
{ |
| 43 |
|
|
SDL_GrabMode mode; |
| 44 |
|
|
|
| 45 |
|
|
printf ("Ctrl-G: toggling input grab!\n"); |
| 46 |
|
|
mode = SDL_WM_GrabInput (SDL_GRAB_QUERY); |
| 47 |
|
|
if (mode == SDL_GRAB_ON) |
| 48 |
root |
1.5 |
printf ("Grab was on\n"); |
| 49 |
root |
1.1 |
else |
| 50 |
root |
1.5 |
printf ("Grab was off\n"); |
| 51 |
root |
1.1 |
|
| 52 |
|
|
mode = SDL_WM_GrabInput (mode ? SDL_GRAB_OFF : SDL_GRAB_ON); |
| 53 |
|
|
if (mode == SDL_GRAB_ON) |
| 54 |
root |
1.5 |
printf ("Grab is now on\n"); |
| 55 |
root |
1.1 |
else |
| 56 |
root |
1.5 |
printf ("Grab is now off\n"); |
| 57 |
root |
1.1 |
} |
| 58 |
|
|
|
| 59 |
|
|
void |
| 60 |
|
|
HotKey_Iconify (void) |
| 61 |
|
|
{ |
| 62 |
|
|
printf ("Ctrl-Z: iconifying window!\n"); |
| 63 |
|
|
SDL_WM_IconifyWindow (); |
| 64 |
|
|
} |
| 65 |
|
|
|
| 66 |
|
|
int |
| 67 |
|
|
HandleEvent (SDL_Event * event) |
| 68 |
|
|
{ |
| 69 |
|
|
int done; |
| 70 |
|
|
|
| 71 |
|
|
done = 0; |
| 72 |
|
|
switch (event->type) |
| 73 |
|
|
{ |
| 74 |
|
|
case SDL_ACTIVEEVENT: |
| 75 |
|
|
/* See what happened */ |
| 76 |
|
|
printf ("app %s ", event->active.gain ? "gained" : "lost"); |
| 77 |
|
|
if (event->active.state & SDL_APPACTIVE) |
| 78 |
|
|
{ |
| 79 |
|
|
printf ("active "); |
| 80 |
|
|
} |
| 81 |
|
|
else if (event->active.state & SDL_APPMOUSEFOCUS) |
| 82 |
|
|
{ |
| 83 |
|
|
printf ("mouse "); |
| 84 |
|
|
} |
| 85 |
|
|
else if (event->active.state & SDL_APPINPUTFOCUS) |
| 86 |
|
|
{ |
| 87 |
|
|
printf ("input "); |
| 88 |
|
|
} |
| 89 |
|
|
|
| 90 |
|
|
printf ("focus\n"); |
| 91 |
|
|
break; |
| 92 |
|
|
|
| 93 |
|
|
case SDL_KEYDOWN: |
| 94 |
root |
1.6 |
|
| 95 |
|
|
if (event->key.keysym.sym == SDLK_UP) |
| 96 |
|
|
camera.p.z -= 1; |
| 97 |
|
|
if (event->key.keysym.sym == SDLK_DOWN) |
| 98 |
|
|
camera.p.z += 1; |
| 99 |
|
|
if (event->key.keysym.sym == SDLK_LEFT) |
| 100 |
|
|
camera.p.x -= 1; |
| 101 |
|
|
if (event->key.keysym.sym == SDLK_RIGHT) |
| 102 |
|
|
camera.p.x += 1; |
| 103 |
|
|
|
| 104 |
root |
1.1 |
if (event->key.keysym.sym == SDLK_ESCAPE) |
| 105 |
root |
1.6 |
done = 1; |
| 106 |
root |
1.1 |
|
| 107 |
|
|
if ((event->key.keysym.sym == SDLK_g) && |
| 108 |
|
|
(event->key.keysym.mod & KMOD_CTRL)) |
| 109 |
root |
1.6 |
HotKey_ToggleGrab (); |
| 110 |
root |
1.1 |
|
| 111 |
|
|
if ((event->key.keysym.sym == SDLK_z) && |
| 112 |
|
|
(event->key.keysym.mod & KMOD_CTRL)) |
| 113 |
root |
1.6 |
HotKey_Iconify (); |
| 114 |
root |
1.1 |
|
| 115 |
|
|
if ((event->key.keysym.sym == SDLK_RETURN) && |
| 116 |
|
|
(event->key.keysym.mod & KMOD_ALT)) |
| 117 |
root |
1.6 |
HotKey_ToggleFullScreen (); |
| 118 |
root |
1.1 |
|
| 119 |
|
|
break; |
| 120 |
|
|
|
| 121 |
|
|
case SDL_QUIT: |
| 122 |
|
|
done = 1; |
| 123 |
|
|
break; |
| 124 |
|
|
} |
| 125 |
|
|
|
| 126 |
|
|
return (done); |
| 127 |
|
|
} |
| 128 |
|
|
|
| 129 |
|
|
/* Quick utility function for texture creation */ |
| 130 |
|
|
static int |
| 131 |
|
|
power_of_two (int input) |
| 132 |
|
|
{ |
| 133 |
|
|
int value = 1; |
| 134 |
|
|
|
| 135 |
|
|
while (value < input) |
| 136 |
|
|
{ |
| 137 |
|
|
value <<= 1; |
| 138 |
|
|
} |
| 139 |
|
|
return value; |
| 140 |
|
|
} |
| 141 |
|
|
|
| 142 |
|
|
GLuint |
| 143 |
|
|
SDL_GL_LoadTexture (SDL_Surface * surface, GLfloat * texcoord) |
| 144 |
|
|
{ |
| 145 |
|
|
GLuint texture; |
| 146 |
|
|
int w, h; |
| 147 |
|
|
SDL_Surface *image; |
| 148 |
|
|
SDL_Rect area; |
| 149 |
|
|
Uint32 saved_flags; |
| 150 |
|
|
Uint8 saved_alpha; |
| 151 |
|
|
|
| 152 |
|
|
/* Use the surface width and height expanded to powers of 2 */ |
| 153 |
|
|
w = power_of_two (surface->w); |
| 154 |
|
|
h = power_of_two (surface->h); |
| 155 |
|
|
texcoord[0] = 0.0f; /* Min X */ |
| 156 |
|
|
texcoord[1] = 0.0f; /* Min Y */ |
| 157 |
|
|
texcoord[2] = (GLfloat) surface->w / w; /* Max X */ |
| 158 |
|
|
texcoord[3] = (GLfloat) surface->h / h; /* Max Y */ |
| 159 |
|
|
|
| 160 |
|
|
image = SDL_CreateRGBSurface (SDL_SWSURFACE, w, h, 32, |
| 161 |
|
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */ |
| 162 |
|
|
0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 |
| 163 |
|
|
#else |
| 164 |
|
|
0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF |
| 165 |
|
|
#endif |
| 166 |
|
|
); |
| 167 |
|
|
if (image == NULL) |
| 168 |
|
|
{ |
| 169 |
|
|
return 0; |
| 170 |
|
|
} |
| 171 |
|
|
|
| 172 |
|
|
/* Save the alpha blending attributes */ |
| 173 |
|
|
saved_flags = surface->flags & (SDL_SRCALPHA | SDL_RLEACCELOK); |
| 174 |
|
|
saved_alpha = surface->format->alpha; |
| 175 |
|
|
if ((saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA) |
| 176 |
|
|
{ |
| 177 |
|
|
SDL_SetAlpha (surface, 0, 0); |
| 178 |
|
|
} |
| 179 |
|
|
|
| 180 |
|
|
/* Copy the surface into the GL texture image */ |
| 181 |
|
|
area.x = 0; |
| 182 |
|
|
area.y = 0; |
| 183 |
|
|
area.w = surface->w; |
| 184 |
|
|
area.h = surface->h; |
| 185 |
|
|
SDL_BlitSurface (surface, &area, image, &area); |
| 186 |
|
|
|
| 187 |
|
|
/* Restore the alpha blending attributes */ |
| 188 |
|
|
if ((saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA) |
| 189 |
|
|
{ |
| 190 |
|
|
SDL_SetAlpha (surface, saved_flags, saved_alpha); |
| 191 |
|
|
} |
| 192 |
|
|
|
| 193 |
|
|
/* Create an OpenGL texture for the image */ |
| 194 |
|
|
glGenTextures (1, &texture); |
| 195 |
|
|
glBindTexture (GL_TEXTURE_2D, texture); |
| 196 |
|
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 197 |
|
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 198 |
|
|
glTexImage2D (GL_TEXTURE_2D, |
| 199 |
|
|
0, |
| 200 |
|
|
GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels); |
| 201 |
|
|
SDL_FreeSurface (image); /* No longer needed */ |
| 202 |
|
|
|
| 203 |
|
|
return texture; |
| 204 |
|
|
} |
| 205 |
|
|
|
| 206 |
|
|
int |
| 207 |
|
|
RunGLTest (int argc, char *argv[], |
| 208 |
|
|
int logo, int slowly, int bpp, float gamma, int noframe, int fsaa) |
| 209 |
|
|
{ |
| 210 |
|
|
int i; |
| 211 |
|
|
int rgb_size[3]; |
| 212 |
|
|
int w = 640; |
| 213 |
|
|
int h = 480; |
| 214 |
|
|
int done = 0; |
| 215 |
|
|
int frames; |
| 216 |
|
|
Uint32 start_time, this_time; |
| 217 |
root |
1.2 |
Uint32 video_flags; |
| 218 |
root |
1.1 |
int value; |
| 219 |
|
|
|
| 220 |
|
|
if (SDL_Init (SDL_INIT_VIDEO) < 0) |
| 221 |
|
|
{ |
| 222 |
|
|
fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); |
| 223 |
|
|
exit (1); |
| 224 |
|
|
} |
| 225 |
|
|
|
| 226 |
|
|
/* See if we should detect the display depth */ |
| 227 |
|
|
if (bpp == 0) |
| 228 |
|
|
{ |
| 229 |
|
|
if (SDL_GetVideoInfo ()->vfmt->BitsPerPixel <= 8) |
| 230 |
root |
1.3 |
bpp = 8; |
| 231 |
root |
1.1 |
else |
| 232 |
root |
1.3 |
bpp = 16; /* More doesn't seem to work */ |
| 233 |
root |
1.1 |
} |
| 234 |
|
|
|
| 235 |
root |
1.2 |
video_flags = SDL_OPENGL; |
| 236 |
|
|
|
| 237 |
root |
1.1 |
for (i = 1; argv[i]; ++i) |
| 238 |
root |
1.3 |
if (strcmp (argv[1], "-fullscreen") == 0) |
| 239 |
|
|
video_flags |= SDL_FULLSCREEN; |
| 240 |
root |
1.1 |
|
| 241 |
|
|
if (noframe) |
| 242 |
root |
1.3 |
video_flags |= SDL_NOFRAME; |
| 243 |
root |
1.1 |
|
| 244 |
|
|
/* Initialize the display */ |
| 245 |
|
|
switch (bpp) |
| 246 |
|
|
{ |
| 247 |
|
|
case 8: |
| 248 |
|
|
rgb_size[0] = 3; |
| 249 |
|
|
rgb_size[1] = 3; |
| 250 |
|
|
rgb_size[2] = 2; |
| 251 |
|
|
break; |
| 252 |
root |
1.3 |
|
| 253 |
root |
1.1 |
case 15: |
| 254 |
|
|
case 16: |
| 255 |
|
|
rgb_size[0] = 5; |
| 256 |
|
|
rgb_size[1] = 5; |
| 257 |
|
|
rgb_size[2] = 5; |
| 258 |
|
|
break; |
| 259 |
root |
1.3 |
|
| 260 |
root |
1.1 |
default: |
| 261 |
|
|
rgb_size[0] = 8; |
| 262 |
|
|
rgb_size[1] = 8; |
| 263 |
|
|
rgb_size[2] = 8; |
| 264 |
|
|
break; |
| 265 |
|
|
} |
| 266 |
|
|
SDL_GL_SetAttribute (SDL_GL_RED_SIZE, rgb_size[0]); |
| 267 |
|
|
SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, rgb_size[1]); |
| 268 |
|
|
SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, rgb_size[2]); |
| 269 |
|
|
SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 16); |
| 270 |
|
|
SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
| 271 |
root |
1.3 |
|
| 272 |
root |
1.1 |
if (fsaa) |
| 273 |
|
|
{ |
| 274 |
|
|
SDL_GL_SetAttribute (SDL_GL_MULTISAMPLEBUFFERS, 1); |
| 275 |
|
|
SDL_GL_SetAttribute (SDL_GL_MULTISAMPLESAMPLES, fsaa); |
| 276 |
|
|
} |
| 277 |
root |
1.3 |
|
| 278 |
root |
1.1 |
if (SDL_SetVideoMode (w, h, bpp, video_flags) == NULL) |
| 279 |
|
|
{ |
| 280 |
|
|
fprintf (stderr, "Couldn't set GL mode: %s\n", SDL_GetError ()); |
| 281 |
|
|
SDL_Quit (); |
| 282 |
|
|
exit (1); |
| 283 |
|
|
} |
| 284 |
|
|
|
| 285 |
|
|
printf ("Screen BPP: %d\n", SDL_GetVideoSurface ()->format->BitsPerPixel); |
| 286 |
|
|
printf ("\n"); |
| 287 |
|
|
printf ("Vendor : %s\n", glGetString (GL_VENDOR)); |
| 288 |
|
|
printf ("Renderer : %s\n", glGetString (GL_RENDERER)); |
| 289 |
|
|
printf ("Version : %s\n", glGetString (GL_VERSION)); |
| 290 |
|
|
printf ("Extensions : %s\n", glGetString (GL_EXTENSIONS)); |
| 291 |
|
|
printf ("\n"); |
| 292 |
|
|
|
| 293 |
|
|
SDL_GL_GetAttribute (SDL_GL_RED_SIZE, &value); |
| 294 |
|
|
printf ("SDL_GL_RED_SIZE: requested %d, got %d\n", rgb_size[0], value); |
| 295 |
|
|
SDL_GL_GetAttribute (SDL_GL_GREEN_SIZE, &value); |
| 296 |
|
|
printf ("SDL_GL_GREEN_SIZE: requested %d, got %d\n", rgb_size[1], value); |
| 297 |
|
|
SDL_GL_GetAttribute (SDL_GL_BLUE_SIZE, &value); |
| 298 |
|
|
printf ("SDL_GL_BLUE_SIZE: requested %d, got %d\n", rgb_size[2], value); |
| 299 |
|
|
SDL_GL_GetAttribute (SDL_GL_DEPTH_SIZE, &value); |
| 300 |
|
|
printf ("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value); |
| 301 |
|
|
SDL_GL_GetAttribute (SDL_GL_DOUBLEBUFFER, &value); |
| 302 |
|
|
printf ("SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value); |
| 303 |
root |
1.3 |
|
| 304 |
root |
1.1 |
if (fsaa) |
| 305 |
|
|
{ |
| 306 |
|
|
SDL_GL_GetAttribute (SDL_GL_MULTISAMPLEBUFFERS, &value); |
| 307 |
|
|
printf ("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); |
| 308 |
|
|
SDL_GL_GetAttribute (SDL_GL_MULTISAMPLESAMPLES, &value); |
| 309 |
|
|
printf ("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, |
| 310 |
|
|
value); |
| 311 |
|
|
} |
| 312 |
|
|
|
| 313 |
|
|
/* Set the window manager title bar */ |
| 314 |
root |
1.12 |
SDL_WM_SetCaption ("libgender rendering test", "gendertest"); |
| 315 |
root |
1.1 |
|
| 316 |
|
|
/* Set the gamma for the window */ |
| 317 |
|
|
if (gamma != 0.0) |
| 318 |
root |
1.3 |
SDL_SetGamma (gamma, gamma, gamma); |
| 319 |
root |
1.1 |
|
| 320 |
root |
1.6 |
camera.p = point (0, 0, 10); |
| 321 |
|
|
camera.d = vec3 (0, 0, -1); |
| 322 |
|
|
camera.u = vec3 (0, 1, 0); |
| 323 |
|
|
camera.w = w; camera.h = h; |
| 324 |
|
|
camera.fov = 90; |
| 325 |
root |
1.1 |
|
| 326 |
|
|
glMatrixMode (GL_MODELVIEW); |
| 327 |
|
|
glLoadIdentity (); |
| 328 |
|
|
|
| 329 |
root |
1.12 |
//glEnable (GL_CULL_FACE); |
| 330 |
root |
1.1 |
glEnable (GL_DEPTH_TEST); |
| 331 |
|
|
glDepthFunc (GL_LESS); |
| 332 |
root |
1.11 |
glShadeModel (GL_SMOOTH); |
| 333 |
root |
1.6 |
|
| 334 |
root |
1.3 |
glEnable (GL_LIGHTING); |
| 335 |
root |
1.9 |
//GLfloat lightc[4] = { 1, 0.1, 0.1, 1 }; |
| 336 |
root |
1.6 |
//glLightf (GL_LIGHT0, GL_QUADRATIC_ATTENUATION); |
| 337 |
root |
1.9 |
//glLightfv (GL_LIGHT0, GL_DIFFUSE, lightc); |
| 338 |
root |
1.6 |
glEnable (GL_LIGHT0); |
| 339 |
root |
1.1 |
|
| 340 |
|
|
/* Loop until done. */ |
| 341 |
|
|
start_time = SDL_GetTicks (); |
| 342 |
|
|
frames = 0; |
| 343 |
|
|
while (!done) |
| 344 |
|
|
{ |
| 345 |
|
|
GLenum gl_error; |
| 346 |
|
|
char *sdl_error; |
| 347 |
|
|
SDL_Event event; |
| 348 |
|
|
|
| 349 |
|
|
/* Do our drawing, too. */ |
| 350 |
|
|
glClearColor (0.0, 0.0, 0.0, 1.0); |
| 351 |
|
|
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
| 352 |
|
|
|
| 353 |
root |
1.6 |
GLfloat lightp[4]; |
| 354 |
|
|
lightp[0] = camera.p.x; |
| 355 |
|
|
lightp[1] = camera.p.y; |
| 356 |
|
|
lightp[2] = camera.p.z; |
| 357 |
|
|
lightp[3] = 1; |
| 358 |
|
|
glLightfv (GL_LIGHT0, GL_POSITION, lightp); |
| 359 |
|
|
|
| 360 |
root |
1.5 |
#if 0 |
| 361 |
root |
1.3 |
static GLfloat ry; |
| 362 |
root |
1.5 |
ry += 0.03; |
| 363 |
root |
1.3 |
v.d.x = cos (ry); |
| 364 |
|
|
v.d.z = sin (ry); |
| 365 |
root |
1.5 |
#endif |
| 366 |
root |
1.1 |
|
| 367 |
root |
1.3 |
draw_context c; |
| 368 |
root |
1.9 |
c.mode = draw_context::LIGHTED; |
| 369 |
root |
1.6 |
camera.draw (c); |
| 370 |
root |
1.1 |
|
| 371 |
|
|
SDL_GL_SwapBuffers (); |
| 372 |
|
|
|
| 373 |
|
|
/* Check for error conditions. */ |
| 374 |
|
|
gl_error = glGetError (); |
| 375 |
|
|
|
| 376 |
|
|
if (gl_error != GL_NO_ERROR) |
| 377 |
root |
1.3 |
fprintf (stderr, "testgl: OpenGL error: %d\n", gl_error); |
| 378 |
root |
1.1 |
|
| 379 |
|
|
sdl_error = SDL_GetError (); |
| 380 |
|
|
|
| 381 |
|
|
if (sdl_error[0] != '\0') |
| 382 |
|
|
{ |
| 383 |
|
|
fprintf (stderr, "testgl: SDL error '%s'\n", sdl_error); |
| 384 |
|
|
SDL_ClearError (); |
| 385 |
|
|
} |
| 386 |
|
|
|
| 387 |
|
|
/* Allow the user to see what's happening */ |
| 388 |
root |
1.9 |
//SDL_Delay (20); |
| 389 |
root |
1.1 |
|
| 390 |
|
|
/* Check if there's a pending event. */ |
| 391 |
|
|
while (SDL_PollEvent (&event)) |
| 392 |
|
|
{ |
| 393 |
|
|
done = HandleEvent (&event); |
| 394 |
|
|
} |
| 395 |
|
|
++frames; |
| 396 |
|
|
} |
| 397 |
|
|
|
| 398 |
|
|
/* Print out the frames per second */ |
| 399 |
|
|
this_time = SDL_GetTicks (); |
| 400 |
|
|
if (this_time != start_time) |
| 401 |
|
|
{ |
| 402 |
|
|
printf ("%2.2f FPS\n", |
| 403 |
|
|
((float) frames / (this_time - start_time)) * 1000.0); |
| 404 |
|
|
} |
| 405 |
|
|
|
| 406 |
|
|
if (global_image) |
| 407 |
|
|
{ |
| 408 |
|
|
SDL_FreeSurface (global_image); |
| 409 |
|
|
global_image = NULL; |
| 410 |
|
|
} |
| 411 |
|
|
if (global_texture) |
| 412 |
|
|
{ |
| 413 |
|
|
glDeleteTextures (1, &global_texture); |
| 414 |
|
|
global_texture = 0; |
| 415 |
|
|
} |
| 416 |
|
|
|
| 417 |
|
|
/* Destroy our GL context, etc. */ |
| 418 |
|
|
SDL_Quit (); |
| 419 |
|
|
return (0); |
| 420 |
|
|
} |
| 421 |
|
|
|
| 422 |
|
|
int |
| 423 |
|
|
main (int argc, char *argv[]) |
| 424 |
|
|
{ |
| 425 |
|
|
int i, logo; |
| 426 |
|
|
int numtests; |
| 427 |
|
|
int bpp = 0; |
| 428 |
|
|
int slowly; |
| 429 |
|
|
float gamma = 0.0; |
| 430 |
|
|
int noframe = 0; |
| 431 |
|
|
int fsaa = 0; |
| 432 |
root |
1.4 |
|
| 433 |
|
|
// load a entity |
| 434 |
root |
1.12 |
for (int i = 0; i < 1; i++) { |
| 435 |
root |
1.4 |
txtprt_parser p; |
| 436 |
root |
1.8 |
entity *e; |
| 437 |
root |
1.4 |
try { |
| 438 |
root |
1.5 |
e = p.read ("test.blasc"); |
| 439 |
root |
1.4 |
} catch (txtprt_i_exception & e) { |
| 440 |
|
|
cout << "ERR: " << e.msg << endl; |
| 441 |
|
|
} |
| 442 |
root |
1.12 |
e->orig.x += i; |
| 443 |
|
|
e->orig.y += i; |
| 444 |
|
|
e->orig.z += i; |
| 445 |
root |
1.8 |
e->show (); |
| 446 |
root |
1.12 |
printf ("load entity %p -> %p\n", e, e->content ()); |
| 447 |
|
|
} |
| 448 |
root |
1.1 |
|
| 449 |
|
|
logo = 0; |
| 450 |
|
|
slowly = 0; |
| 451 |
|
|
numtests = 1; |
| 452 |
|
|
for (i = 1; argv[i]; ++i) |
| 453 |
|
|
{ |
| 454 |
|
|
if (strcmp (argv[i], "-twice") == 0) |
| 455 |
|
|
{ |
| 456 |
|
|
++numtests; |
| 457 |
|
|
} |
| 458 |
|
|
if (strcmp (argv[i], "-slow") == 0) |
| 459 |
|
|
{ |
| 460 |
|
|
slowly = 1; |
| 461 |
|
|
} |
| 462 |
|
|
if (strcmp (argv[i], "-bpp") == 0) |
| 463 |
|
|
{ |
| 464 |
|
|
bpp = atoi (argv[++i]); |
| 465 |
|
|
} |
| 466 |
|
|
if (strcmp (argv[i], "-gamma") == 0) |
| 467 |
|
|
{ |
| 468 |
|
|
gamma = (float) atof (argv[++i]); |
| 469 |
|
|
} |
| 470 |
|
|
if (strcmp (argv[i], "-noframe") == 0) |
| 471 |
|
|
{ |
| 472 |
|
|
noframe = 1; |
| 473 |
|
|
} |
| 474 |
|
|
if (strcmp (argv[i], "-fsaa") == 0) |
| 475 |
|
|
{ |
| 476 |
|
|
++fsaa; |
| 477 |
|
|
} |
| 478 |
|
|
if (strncmp (argv[i], "-h", 2) == 0) |
| 479 |
|
|
{ |
| 480 |
|
|
printf |
| 481 |
|
|
("Usage: %s [-twice] [-logo] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa]\n", |
| 482 |
|
|
argv[0]); |
| 483 |
|
|
exit (0); |
| 484 |
|
|
} |
| 485 |
|
|
} |
| 486 |
|
|
for (i = 0; i < numtests; ++i) |
| 487 |
|
|
{ |
| 488 |
|
|
RunGLTest (argc, argv, logo, slowly, bpp, gamma, noframe, fsaa); |
| 489 |
|
|
} |
| 490 |
|
|
return 0; |
| 491 |
|
|
} |