--- libgender/test.C 2004/10/10 20:22:33 1.59 +++ libgender/test.C 2004/10/21 21:20:09 1.68 @@ -3,6 +3,8 @@ #include #include +#include "opengl.h" + #include "SDL.h" #include "SDL_opengl.h" @@ -71,17 +73,11 @@ /* See what happened */ printf ("app %s ", event->active.gain ? "gained" : "lost"); if (event->active.state & SDL_APPACTIVE) - { - printf ("active "); - } + printf ("active "); else if (event->active.state & SDL_APPMOUSEFOCUS) - { - printf ("mouse "); - } + printf ("mouse "); else if (event->active.state & SDL_APPINPUTFOCUS) - { - printf ("input "); - } + printf ("input "); printf ("focus\n"); break; @@ -138,15 +134,15 @@ { int x, z, ry; - for (x = 0; x < 100; x++) + for (x = 0; x < 10; x++) { - for (z = 0; z < 100; z++) + for (z = 0; z < 10; z++) { - vector pts; - pts.push_back (vertex2d (point ( 0, 0, 0), vec3 (0, 1, 0), texc (0, 0))); - pts.push_back (vertex2d (point ( 0, 0, size), vec3 (0, 1, 0), texc (0, 1))); - pts.push_back (vertex2d (point (size, 0, size), vec3 (0, 1, 0), texc (1, 1))); - pts.push_back (vertex2d (point (size, 0, 0), vec3 (0, 1, 0), texc (1, 0))); + vector pts; + pts.push_back (vertex_t2f_n3f_v3f (point ( 0, 0, 0), vec3 (0, 1, 0), tex2 (0, 0))); + pts.push_back (vertex_t2f_n3f_v3f (point ( 0, 0, size), vec3 (0, 1, 0), tex2 (0, 1))); + pts.push_back (vertex_t2f_n3f_v3f (point (size, 0, size), vec3 (0, 1, 0), tex2 (1, 1))); + pts.push_back (vertex_t2f_n3f_v3f (point (size, 0, 0), vec3 (0, 1, 0), tex2 (1, 0))); geometry_quads *q = new geometry_quads; q->m = new simple_material; @@ -167,6 +163,23 @@ e->show (); } +void fisch (vec3 center, GLfloat radius, int depth) +{ + entity *planet = new entity (new geometry_sphere (radius)); + planet->move (center); + planet->show (); + + if (--depth) + { + GLfloat r2 = radius * .1F; + GLfloat r3 = radius + r2; + + fisch (center + vec3 (r3, 0, 0), r2, depth); + fisch (center + vec3 (0, 0, r3), r2, depth); + fisch (center + vec3 (-r3, 0, 0), r2, depth); + } +} + extern void draw_level (); int RunGLTest (int argc, char *argv[], @@ -178,7 +191,6 @@ int h = 480; int done = 0; int frames; - Uint32 start_time, this_time; Uint32 video_flags; int value; GLenum gl_error; @@ -284,6 +296,11 @@ if (gamma != 0.0) SDL_SetGamma (gamma, gamma, gamma); + entity *planet = new entity (new geometry_sphere (10)); + planet->move (vec3 (0, 0, -20)); + planet->show (); + +#if 1 for (int i = 0; i < 20; i++) { // load a entity @@ -303,9 +320,23 @@ e->show (); } + { + fisch (vec3 (0, 0, -2e9), 1e9, 8); + //entity *planet = new entity (new geometry_sphere (1e9)); + //planet->move (vec3 (0, 0, -1.5e9)); + //planet->show (); + } + + { + entity *planet = new entity (new geometry_sphere (4e15)); + planet->move (vec3 (0, 0, 1e17)); + planet->show (); + } + draw_floor (10, -500, -10, -1000); draw_level (); - draw_test_nurb (); + //draw_test_nurb (); +#endif //camera.orig.x = 108; camera.orig.y = 0; camera.orig.z = -368; camera.orig.x = 0; camera.orig.y = 0; camera.orig.z = 0; @@ -313,26 +344,17 @@ camera.d = vec3 (0, 0, -1); camera.u = vec3 (0, 1, 0); camera.w = w; camera.h = h; - camera.fov = 35; - camera.z_near = 1.; - - glMatrixMode (GL_MODELVIEW); - glLoadIdentity (); + camera.fov = 40.; glEnable (GL_CULL_FACE); - glEnable (GL_DEPTH_TEST); - - glShadeModel (GL_SMOOTH); - - glEnable (GL_LIGHTING); - glEnable (GL_LIGHT0); + glDisable (GL_ALPHA_TEST); + glDisable (GL_BLEND); init_shaders (); osama_material osa_mat; /* Loop until done. */ - start_time = SDL_GetTicks (); frames = 0; while (!done) @@ -352,25 +374,20 @@ camera.p = camera.p - camera.d * (camera_velocity_factor * timer.diff) * camera_velocity.z; camera.p = camera.p - camera.u * (camera_velocity_factor * timer.diff) * camera_velocity.y; - -#if 0 - static GLfloat ry; - ry += 0.001; - camera.d.x = cos (ry); - camera.d.z = sin (ry); - //camera.d.y = sin (ry * 0.1); -#endif osa_mat.begin (); camera.begin (); - camera.pass (view::DEPTH); - camera.pass (view::LIGHTED); + camera.render (view::DEPTH); + camera.render (view::POSTDEPTH); + camera.render (view::LIGHTED); camera.end (); SDL_GL_SwapBuffers (); timer.frame (); osa_mat.end (); + +#if 0 /* Check for error conditions. */ gl_error = glGetError (); @@ -386,6 +403,7 @@ /* Allow the user to see what's happening */ //SDL_Delay (40); +#endif /* Check if there's a pending event. */ while (SDL_PollEvent (&event)) @@ -395,14 +413,6 @@ ++frames; } - /* Print out the frames per second */ - this_time = SDL_GetTicks (); - if (this_time != start_time) - { - printf ("%2.2f FPS\n", - ((float) frames / (this_time - start_time)) * 1000.0); - } - if (global_image) { SDL_FreeSurface (global_image); @@ -429,6 +439,8 @@ int noframe = 0; int fsaa = 0; + shader::debdebdebdebug ();//D + logo = 0; slowly = 0; numtests = 1;