… | |
… | |
161 | int done = 0; |
161 | int done = 0; |
162 | int frames; |
162 | int frames; |
163 | Uint32 start_time, this_time; |
163 | Uint32 start_time, this_time; |
164 | Uint32 video_flags; |
164 | Uint32 video_flags; |
165 | int value; |
165 | int value; |
|
|
166 | GLenum gl_error; |
166 | |
167 | |
167 | if (SDL_Init (SDL_INIT_VIDEO) < 0) |
168 | if (SDL_Init (SDL_INIT_VIDEO) < 0) |
168 | { |
169 | { |
169 | fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); |
170 | fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); |
170 | exit (1); |
171 | exit (1); |
… | |
… | |
263 | |
264 | |
264 | /* Set the gamma for the window */ |
265 | /* Set the gamma for the window */ |
265 | if (gamma != 0.0) |
266 | if (gamma != 0.0) |
266 | SDL_SetGamma (gamma, gamma, gamma); |
267 | SDL_SetGamma (gamma, gamma, gamma); |
267 | |
268 | |
268 | // load a entity |
|
|
269 | for (int i = 0; i < 7; i++) |
269 | for (int i = 0; i < 70; i++) |
270 | { |
270 | { |
|
|
271 | // load a entity |
271 | txtprt_parser p; |
272 | txtprt_parser p; |
272 | entity_transform *f = new entity_transform; |
|
|
273 | entity *e; |
273 | entity *e; |
274 | try |
274 | try |
275 | { |
275 | { |
276 | e = p.read ("test.blasc"); |
276 | e = p.read ("test.blasc"); |
|
|
277 | } |
277 | } catch (txtprt_i_exception & e) |
278 | catch (txtprt_i_exception & e) |
278 | { |
279 | { |
279 | cout << "ERR: " << e.msg << endl; |
280 | cout << "ERR: " << e.msg << endl; |
280 | } |
281 | } |
|
|
282 | |
|
|
283 | entity_transform *f = new entity_transform; |
281 | f->set (e); |
284 | f->set (e); |
282 | f->update (matrix::translation (vec3 (0, -1, -i*5))); |
285 | f->update (matrix::translation (vec3 (i*5, -3, -i*10))); |
283 | f->show (); |
286 | f->show (); |
284 | } |
287 | } |
285 | |
288 | draw_some_random_funky_floor_dance_music (10, -500, -10, -1000); |
286 | camera.orig.x = camera.orig.y = camera.orig.z = 0; |
289 | camera.orig.x = camera.orig.y = camera.orig.z = 0; |
287 | camera.p = point (0, 0, 10); |
290 | camera.p = point (0, 0, 10); |
288 | camera.d = vec3 (0, 0, -1); |
291 | camera.d = vec3 (0, 0, -1); |
289 | camera.u = vec3 (0, 1, 0); |
292 | camera.u = vec3 (0, 1, 0); |
290 | camera.w = w; camera.h = h; |
293 | camera.w = w; camera.h = h; |
291 | camera.fov = 80; |
294 | camera.fov = 80; |
292 | |
295 | |
293 | glMatrixMode (GL_MODELVIEW); |
296 | glMatrixMode (GL_MODELVIEW); |
294 | glLoadIdentity (); |
297 | glLoadIdentity (); |
295 | |
298 | |
296 | //glEnable (GL_CULL_FACE); |
299 | glEnable (GL_CULL_FACE); |
297 | glEnable (GL_DEPTH_TEST); |
300 | glEnable (GL_DEPTH_TEST); |
298 | glEnable (GL_TEXTURE_2D); //texturing |
|
|
299 | |
301 | |
300 | glShadeModel (GL_SMOOTH); |
302 | glShadeModel (GL_SMOOTH); |
301 | |
303 | |
302 | glEnable (GL_LIGHTING); |
304 | glEnable (GL_LIGHTING); |
303 | //GLfloat lightc[4] = { 1, 0.1, 0.1, 1 }; |
|
|
304 | //glLightf (GL_LIGHT0, GL_QUADRATIC_ATTENUATION); |
|
|
305 | //glLightfv (GL_LIGHT0, GL_DIFFUSE, lightc); |
|
|
306 | glEnable (GL_LIGHT0); |
305 | glEnable (GL_LIGHT0); |
307 | |
306 | |
308 | cgc = cgCreateContext (); |
307 | cgc = cgCreateContext (); |
309 | |
308 | |
310 | vsh_profile = CG_PROFILE_ARBVP1; |
309 | vsh_profile = CG_PROFILE_ARBVP1; |
… | |
… | |
341 | |
340 | |
342 | /* Loop until done. */ |
341 | /* Loop until done. */ |
343 | start_time = SDL_GetTicks (); |
342 | start_time = SDL_GetTicks (); |
344 | frames = 0; |
343 | frames = 0; |
345 | |
344 | |
346 | |
|
|
347 | while (!done) |
345 | while (!done) |
348 | { |
346 | { |
349 | GLenum gl_error; |
|
|
350 | char *sdl_error; |
347 | char *sdl_error; |
351 | SDL_Event event; |
348 | SDL_Event event; |
352 | |
|
|
353 | glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
|
354 | |
349 | |
355 | camera.p.x += camera_velocity_factor * camera_velocity.x * timer.diff; |
350 | camera.p.x += camera_velocity_factor * camera_velocity.x * timer.diff; |
356 | camera.p.y += camera_velocity_factor * camera_velocity.y * timer.diff; |
351 | camera.p.y += camera_velocity_factor * camera_velocity.y * timer.diff; |
357 | camera.p.z += camera_velocity_factor * camera_velocity.z * timer.diff; |
352 | camera.p.z += camera_velocity_factor * camera_velocity.z * timer.diff; |
358 | |
353 | |
… | |
… | |
361 | camera.d.x = sin (camera_angle * 12 / 180.); |
356 | camera.d.x = sin (camera_angle * 12 / 180.); |
362 | |
357 | |
363 | cgGLSetParameter4f (lightpos, camera.p.x, camera.p.y, camera.p.z, 1); |
358 | cgGLSetParameter4f (lightpos, camera.p.x, camera.p.y, camera.p.z, 1); |
364 | |
359 | |
365 | glBindTexture (GL_TEXTURE_2D, t.texture); |
360 | glBindTexture (GL_TEXTURE_2D, t.texture); |
366 | cgGLEnableTextureParameter(g_Texture); // Enable the texture parameter |
361 | cgGLEnableTextureParameter (g_Texture); // Enable the texture parameter |
367 | |
362 | |
368 | #if 0 |
363 | #if 0 |
369 | static GLfloat ry; |
364 | static GLfloat ry; |
370 | ry += 0.001; |
365 | ry += 0.001; |
371 | camera.d.x = cos (ry); |
366 | camera.d.x = cos (ry); |
… | |
… | |
382 | timer.frame (); |
377 | timer.frame (); |
383 | |
378 | |
384 | /* Check for error conditions. */ |
379 | /* Check for error conditions. */ |
385 | gl_error = glGetError (); |
380 | gl_error = glGetError (); |
386 | |
381 | |
387 | if (gl_error != GL_NO_ERROR) |
|
|
388 | fprintf (stderr, "testgl: OpenGL error: %d\n", gl_error); |
382 | if (gl_error != GL_NO_ERROR) fprintf (stderr, "testgl: OpenGL error: %d\n", gl_error); |
389 | |
383 | |
390 | sdl_error = SDL_GetError (); |
384 | sdl_error = SDL_GetError (); |
391 | |
385 | |
392 | if (sdl_error[0] != '\0') |
386 | if (sdl_error[0] != '\0') |
393 | { |
387 | { |