ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/test.C
(Generate patch)

Comparing libgender/test.C (file contents):
Revision 1.92 by root, Wed Nov 10 01:57:15 2004 UTC vs.
Revision 1.99 by root, Mon Feb 7 08:16:31 2005 UTC

1#include <stdlib.h> 1#include <stdlib.h>
2#include <stdio.h> 2#include <stdio.h>
3#include <string.h> 3#include <string.h>
4#include <math.h> 4#include <math.h>
5#include <list>
5 6
6#include "opengl.h" 7#include "opengl.h"
7 8
8#include "SDL.h" 9#include "SDL.h"
9#include "SDL_opengl.h" 10#include "SDL_opengl.h"
12static GLuint global_texture = 0; 13static GLuint global_texture = 0;
13 14
14#include "util.h" 15#include "util.h"
15#include "entity.h" 16#include "entity.h"
16#include "txtprt_import.h" 17#include "txtprt_import.h"
18#include "randlvl.h"
17 19
18bool doom3parse (const char *f); 20bool doom3parse (const char *f);
19 21
20#include "shader.h" 22#include "shader.h"
21 23
188 } 190 }
189} 191}
190 192
191extern void draw_level (); 193extern void draw_level ();
192 194
193octant *optimize (octant *o)//D 195std::list<entity_moveable *> moveables;
194{
195 if (!o)
196 return o;
197 196
198 for (int i = 8; --i; ) 197void perfom_moves ()
199 o->sub[i] = optimize (o->sub[i]); 198{
200 199 for (std::list<entity_moveable *>::iterator i = moveables.begin (); i != moveables.end (); ++i)
201 if (o->fill != 1 || o->size ()) 200 {
202 return o; 201 (*i)->perform_step (timer.diff);
203 202 }
204 printf ("skipped\n");
205
206 for (int i = 8; --i; )
207 if (o->sub[i])
208 return o->sub[i];
209
210 abort ();
211} 203}
212 204
213int 205int
214RunGLTest (int argc, char *argv[], 206RunGLTest (int argc, char *argv[],
215 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)
324 /* Set the gamma for the window */ 316 /* Set the gamma for the window */
325 if (gamma != 0.0) 317 if (gamma != 0.0)
326 SDL_SetGamma (gamma, gamma, gamma); 318 SDL_SetGamma (gamma, gamma, gamma);
327 319
328 testmat = new test_material; 320 testmat = new test_material;
321 testmat2 = new test_material2;
329 322
330 entity *planet = new entity (new geometry_sphere (testmat, 10)); 323 entity_moveable *planet = new entity_moveable (new geometry_sphere (testmat, 10));
331 planet->move (vec3 (0, 0, -20)); 324 planet->move (vec3 (0, 0, -20));
332 planet->show (); 325 planet->show ();
333 326
327 planet->v = vec3 (10, 0, 0);
328 moveables.push_back (planet);
329
334 doom3parse ("test.proc"); 330 doom3parse ("test.proc");
335
336 for (int i = 8; --i; )
337 world.sub[i] = optimize (world.sub[i]);//D
338 331
339 for (int i = 0; i < 20; i++) 332 for (int i = 0; i < 20; i++)
340 { 333 {
341 // load a entity 334 // load a entity
342 txtprt_parser p; 335 txtprt_parser p;
366 entity *planet = new entity (new geometry_sphere (testmat, 4e15)); 359 entity *planet = new entity (new geometry_sphere (testmat, 4e15));
367 planet->move (vec3 (0, 0, 1e17)); 360 planet->move (vec3 (0, 0, 1e17));
368 planet->show (); 361 planet->show ();
369 } 362 }
370 363
364 {
365 RandomBuilding r;
366 entity *randlvl = r.draw (1000, 1000, 200);
367 randlvl->move (vec3 (0, 0, 0));
368 randlvl->show ();
369
370 entity *randlvl2 = r.draw (1000, 10000, 1000);
371 randlvl2->move (vec3 (-20000, 0, 0));
372 randlvl2->show ();
373
374 entity *randlvl3 = r.draw (100, 30, 3);
375 randlvl3->move (vec3 (-1000, 0, 0));
376 randlvl3->show ();
377
378
379 entity *randlvl4 = r.draw (100, 1000000, 100000);
380 randlvl4->move (vec3 (0, -1001000, 0));
381 randlvl4->show ();
382 }
383
371 //draw_floor (10, -500, -10, -1000); 384 //draw_floor (10, -500, -10, -1000);
372 draw_level (); 385 draw_level ();
373 386
374#if 0 387#if 0
375 { 388 {
393 glDisable (GL_ALPHA_TEST); 406 glDisable (GL_ALPHA_TEST);
394 407
395 /* Loop until done. */ 408 /* Loop until done. */
396 frames = 0; 409 frames = 0;
397 410
398 linear_light mylight, mylight2; 411 linear_light mylight2;//mylight, mylight2;
399 412
400 mylight.radius = 100000; 413 // mylight.radius = 100000;
401 mylight.c = colour (1., 1, 1, 1.); 414 // mylight.c = colour (1., 1, 1, 1.);
402 mylight.intensity = 1.F; 415 // mylight.intensity = 1.F;
403 416
404 mylight2.radius = 100000; 417 mylight2.radius = 100000;
405 mylight2.c = colour (1., 0, 0, 1.); 418 mylight2.c = colour (1., 1., 1., 1.);
406 mylight2.intensity = 1.F; 419 mylight2.intensity = 1.F;
420 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;
407 422
408 pass_data pass_light (&mylight); 423 //pass_data pass_light (&mylight);
409 pass_data pass_light2 (&mylight2); 424 pass_data pass_light2 (&mylight2);
410 425
411 while (!done) 426 while (!done)
412 { 427 {
413 char *sdl_error; 428 char *sdl_error;
423 camera.u = cross (camera.d, right); 438 camera.u = cross (camera.d, right);
424 439
425 camera.p = camera.p - camera.d * (camera_velocity_factor * timer.diff) * camera_velocity.z; 440 camera.p = camera.p - camera.d * (camera_velocity_factor * timer.diff) * camera_velocity.z;
426 camera.p = camera.p - camera.u * (camera_velocity_factor * timer.diff) * camera_velocity.y; 441 camera.p = camera.p - camera.u * (camera_velocity_factor * timer.diff) * camera_velocity.y;
427 442
428 mylight.orig = camera.orig; 443 //mylight.orig = camera.orig;
429 mylight.p = camera.p; 444 //mylight.p = camera.p;
430 445
431 mylight2.orig = camera.orig; 446 mylight2.orig = camera.orig;
432 mylight2.p = camera.p + vec3 (sin (timer.now * 2) * 100, 1, cos (timer.now * 2) * 100); 447 mylight2.p = vec3 (sin (timer.now / 2) * 100000, 1, cos (timer.now / 2) * 100000);
433 448
434 //mylight.intensity = max (sinf (timer.now) + 1.2F, 0.2F); 449 //mylight.intensity = max (sinf (timer.now) + 1.2F, 0.2F);
435 450
436 camera.begin (); 451 camera.begin ();
437 camera.render (pass_depth); 452 camera.render (pass_depth);
438 camera.render (pass_postdepth); 453 camera.render (pass_postdepth);
439 camera.render (pass_light); 454 camera.render (pass_light2);
440 //camera.render (view::LIGHTED, pass_light2); 455 //camera.render (view::LIGHTED, pass_light2);
441 camera.end (); 456 camera.end ();
457
458 perfom_moves ();
442 459
443 SDL_GL_SwapBuffers (); 460 SDL_GL_SwapBuffers ();
444 timer.frame (); 461 timer.frame ();
445 462
446#if 0 463#if 0

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines