… | |
… | |
206 | RunGLTest (int argc, char *argv[], |
206 | RunGLTest (int argc, char *argv[], |
207 | int logo, int slowly, int bpp, float gamma, int noframe, int fsaa) |
207 | int logo, int slowly, int bpp, float gamma, int noframe, int fsaa) |
208 | { |
208 | { |
209 | int i; |
209 | int i; |
210 | int rgb_size[3]; |
210 | int rgb_size[3]; |
211 | int w = 640; |
211 | int w = 800; |
212 | int h = 480; |
212 | int h = 600; |
213 | int done = 0; |
213 | int done = 0; |
214 | int frames; |
214 | int frames; |
215 | Uint32 video_flags; |
215 | Uint32 video_flags; |
216 | int value; |
216 | int value; |
217 | GLenum gl_error; |
217 | GLenum gl_error; |
218 | |
218 | |
219 | if (SDL_Init (SDL_INIT_VIDEO) < 0) |
219 | if (SDL_Init (SDL_INIT_VIDEO) < 0) |
220 | { |
220 | { |
221 | fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); |
221 | fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); |
222 | exit (1); |
222 | exit (1); |
… | |
… | |
264 | } |
264 | } |
265 | |
265 | |
266 | SDL_GL_SetAttribute (SDL_GL_RED_SIZE, rgb_size[0]); |
266 | SDL_GL_SetAttribute (SDL_GL_RED_SIZE, rgb_size[0]); |
267 | SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, rgb_size[1]); |
267 | SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, rgb_size[1]); |
268 | SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, rgb_size[2]); |
268 | SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, rgb_size[2]); |
|
|
269 | SDL_GL_SetAttribute (SDL_GL_ALPHA_SIZE, 0); |
269 | SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 24); |
270 | SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 24); |
270 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
271 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
271 | |
272 | |
272 | if (fsaa) |
273 | if (fsaa) |
273 | { |
274 | { |
… | |
… | |
294 | printf ("SDL_GL_RED_SIZE: requested %d, got %d\n", rgb_size[0], value); |
295 | printf ("SDL_GL_RED_SIZE: requested %d, got %d\n", rgb_size[0], value); |
295 | SDL_GL_GetAttribute (SDL_GL_GREEN_SIZE, &value); |
296 | SDL_GL_GetAttribute (SDL_GL_GREEN_SIZE, &value); |
296 | printf ("SDL_GL_GREEN_SIZE: requested %d, got %d\n", rgb_size[1], value); |
297 | printf ("SDL_GL_GREEN_SIZE: requested %d, got %d\n", rgb_size[1], value); |
297 | SDL_GL_GetAttribute (SDL_GL_BLUE_SIZE, &value); |
298 | SDL_GL_GetAttribute (SDL_GL_BLUE_SIZE, &value); |
298 | printf ("SDL_GL_BLUE_SIZE: requested %d, got %d\n", rgb_size[2], value); |
299 | printf ("SDL_GL_BLUE_SIZE: requested %d, got %d\n", rgb_size[2], value); |
|
|
300 | SDL_GL_GetAttribute (SDL_GL_ALPHA_SIZE, &value); |
|
|
301 | printf ("SDL_GL_ALPHA_SIZE: requested ?, got %d\n", value); |
299 | SDL_GL_GetAttribute (SDL_GL_DEPTH_SIZE, &value); |
302 | SDL_GL_GetAttribute (SDL_GL_DEPTH_SIZE, &value); |
300 | printf ("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value); |
303 | printf ("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value); |
301 | SDL_GL_GetAttribute (SDL_GL_DOUBLEBUFFER, &value); |
304 | SDL_GL_GetAttribute (SDL_GL_DOUBLEBUFFER, &value); |
302 | printf ("SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value); |
305 | printf ("SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value); |
303 | |
306 | |
… | |
… | |
316 | /* Set the gamma for the window */ |
319 | /* Set the gamma for the window */ |
317 | if (gamma != 0.0) |
320 | if (gamma != 0.0) |
318 | SDL_SetGamma (gamma, gamma, gamma); |
321 | SDL_SetGamma (gamma, gamma, gamma); |
319 | |
322 | |
320 | testmat = new test_material; |
323 | testmat = new test_material; |
321 | testmat2 = new test_material2; |
324 | testmat2 = new mat_gouraud_shaded (colour (1, 1, 0)); |
|
|
325 | testmat3 = new mat_timed (); |
|
|
326 | debugmat = new mat_debug (); |
322 | |
327 | |
|
|
328 | #if 1 |
323 | entity_moveable *planet = new entity_moveable (new geometry_sphere (testmat, 10)); |
329 | entity_moveable *planet = new entity_moveable (new geometry_sphere (testmat2, 10)); |
324 | planet->move (vec3 (0, 0, -20)); |
330 | planet->move (vec3 (0, 0, -20)); |
325 | planet->show (); |
331 | planet->show (); |
326 | |
332 | |
327 | planet->v = vec3 (10, 0, 0); |
333 | planet->v = vec3 (10, 0, 0); |
328 | moveables.push_back (planet); |
334 | moveables.push_back (planet); |
|
|
335 | #endif |
329 | |
336 | |
330 | doom3parse ("test.proc"); |
337 | doom3parse ("test.proc"); |
331 | |
338 | |
|
|
339 | skybox sb ( |
|
|
340 | "textures/skybox_mystery/1.jpg", |
|
|
341 | "textures/skybox_mystery/2.jpg", |
|
|
342 | "textures/skybox_mystery/3.jpg", |
|
|
343 | "textures/skybox_mystery/4.jpg", |
|
|
344 | "textures/skybox_mystery/5.jpg", |
|
|
345 | "textures/skybox_mystery/6.jpg" |
|
|
346 | ); |
|
|
347 | world_skybox = &sb; |
|
|
348 | |
332 | for (int i = 0; i < 20; i++) |
349 | for (int i = 0; i <= 0; i++) |
333 | { |
350 | { |
334 | // load a entity |
351 | // load a entity |
335 | txtprt_parser p; |
352 | txtprt_parser p; |
336 | geometry *g; |
353 | geometry *g; |
337 | try |
354 | try |
… | |
… | |
346 | entity *e = new entity (g); |
363 | entity *e = new entity (g); |
347 | e->move (vec3 (i*5, -3, -i*10)); |
364 | e->move (vec3 (i*5, -3, -i*10)); |
348 | e->show (); |
365 | e->show (); |
349 | } |
366 | } |
350 | |
367 | |
|
|
368 | #if 1 |
351 | { |
369 | { |
352 | fisch (vec3 (0, 0, -2e9), 1e9, 8); |
370 | fisch (vec3 (0, 0, -2e9), 1e9, 8); |
353 | //entity *planet = new entity (new geometry_sphere (1e9)); |
371 | //entity *planet = new entity (new geometry_sphere (1e9)); |
354 | //planet->move (vec3 (0, 0, -1.5e9)); |
372 | //planet->move (vec3 (0, 0, -1.5e9)); |
355 | //planet->show (); |
373 | //planet->show (); |
356 | } |
374 | } |
357 | |
375 | |
358 | { |
376 | { |
359 | entity *planet = new entity (new geometry_sphere (testmat, 4e15)); |
377 | entity *planet = new entity (new geometry_sphere (testmat3, 4e15)); |
360 | planet->move (vec3 (0, 0, 1e17)); |
378 | planet->move (vec3 (0, 0, 1e17)); |
361 | planet->show (); |
379 | planet->show (); |
362 | } |
380 | } |
363 | |
381 | |
364 | { |
382 | { |
… | |
… | |
380 | randlvl4->move (vec3 (0, -1001000, 0)); |
398 | randlvl4->move (vec3 (0, -1001000, 0)); |
381 | randlvl4->show (); |
399 | randlvl4->show (); |
382 | } |
400 | } |
383 | |
401 | |
384 | //draw_floor (10, -500, -10, -1000); |
402 | //draw_floor (10, -500, -10, -1000); |
|
|
403 | #endif |
385 | draw_level (); |
404 | draw_level (); |
386 | |
405 | |
387 | #if 0 |
406 | #if 0 |
388 | { |
407 | { |
389 | geometry_heightfield *hf = new geometry_heightfield (100000., 100000.); |
408 | geometry_heightfield *hf = new geometry_heightfield (100000., 100000.); |
… | |
… | |
413 | // mylight.radius = 100000; |
432 | // mylight.radius = 100000; |
414 | // mylight.c = colour (1., 1, 1, 1.); |
433 | // mylight.c = colour (1., 1, 1, 1.); |
415 | // mylight.intensity = 1.F; |
434 | // mylight.intensity = 1.F; |
416 | |
435 | |
417 | mylight2.radius = 100000; |
436 | mylight2.radius = 100000; |
418 | mylight2.c = colour (1., 1., 1., 1.); |
437 | mylight2.c = colour (0., 1., 1., 1.); |
419 | mylight2.intensity = 1.F; |
438 | mylight2.intensity = 1.F; |
420 | mylight2.orig.x = 0; mylight2.orig.y = 0; mylight2.orig.z = 0; |
439 | mylight2.orig.x = 0; mylight2.orig.y = 0; mylight2.orig.z = 0; |
421 | mylight2.p.x = 0; mylight2.p.y = 0; mylight2.p.z = 0; |
440 | mylight2.p.x = 0; mylight2.p.y = 0; mylight2.p.z = 0; |
422 | |
441 | |
423 | //pass_data pass_light (&mylight); |
442 | //pass_data pass_light (&mylight); |
… | |
… | |
442 | |
461 | |
443 | //mylight.orig = camera.orig; |
462 | //mylight.orig = camera.orig; |
444 | //mylight.p = camera.p; |
463 | //mylight.p = camera.p; |
445 | |
464 | |
446 | mylight2.orig = camera.orig; |
465 | mylight2.orig = camera.orig; |
447 | mylight2.p = vec3 (sin (timer.now / 2) * 100000, 1, cos (timer.now / 2) * 100000); |
466 | //mylight2.p = vec3 (sin (timer.now / 2) * 100000, 1, cos (timer.now / 2) * 100000); |
448 | |
467 | |
449 | //mylight.intensity = max (sinf (timer.now) + 1.2F, 0.2F); |
468 | //mylight.intensity = max (sinf (timer.now) + 1.2F, 0.2F); |
450 | |
469 | |
451 | camera.begin (); |
470 | camera.begin (); |
452 | camera.render (pass_depth); |
471 | camera.render (pass_depth); |
… | |
… | |
481 | /* Check if there's a pending event. */ |
500 | /* Check if there's a pending event. */ |
482 | while (SDL_PollEvent (&event)) |
501 | while (SDL_PollEvent (&event)) |
483 | done = HandleEvent (&event); |
502 | done = HandleEvent (&event); |
484 | |
503 | |
485 | ++frames; |
504 | ++frames; |
|
|
505 | |
|
|
506 | //printf ("planet %p\n", planet);//D |
486 | } |
507 | } |
487 | |
508 | |
488 | if (global_image) |
509 | if (global_image) |
489 | { |
510 | { |
490 | SDL_FreeSurface (global_image); |
511 | SDL_FreeSurface (global_image); |