… | |
… | |
309 | printf ("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, |
309 | printf ("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, |
310 | value); |
310 | value); |
311 | } |
311 | } |
312 | |
312 | |
313 | /* Set the window manager title bar */ |
313 | /* Set the window manager title bar */ |
314 | SDL_WM_SetCaption ("SDL GL test", "testgl"); |
314 | SDL_WM_SetCaption ("libgender rendering test", "gendertest"); |
315 | |
315 | |
316 | /* Set the gamma for the window */ |
316 | /* Set the gamma for the window */ |
317 | if (gamma != 0.0) |
317 | if (gamma != 0.0) |
318 | SDL_SetGamma (gamma, gamma, gamma); |
318 | SDL_SetGamma (gamma, gamma, gamma); |
319 | |
319 | |
|
|
320 | camera.orig.x = camera.orig.y = camera.orig.z = 0; |
320 | camera.p = point (0, 0, 10); |
321 | camera.p = point (0, 0, 10); |
321 | camera.d = vec3 (0, 0, -1); |
322 | camera.d = vec3 (0, 0, -1); |
322 | camera.u = vec3 (0, 1, 0); |
323 | camera.u = vec3 (0, 1, 0); |
323 | camera.w = w; camera.h = h; |
324 | camera.w = w; camera.h = h; |
324 | camera.fov = 90; |
325 | camera.fov = 90; |
325 | |
326 | |
326 | glMatrixMode (GL_MODELVIEW); |
327 | glMatrixMode (GL_MODELVIEW); |
327 | glLoadIdentity (); |
328 | glLoadIdentity (); |
328 | |
329 | |
|
|
330 | //glEnable (GL_CULL_FACE); |
329 | glEnable (GL_DEPTH_TEST); |
331 | glEnable (GL_DEPTH_TEST); |
330 | |
|
|
331 | glDepthFunc (GL_LESS); |
332 | glDepthFunc (GL_LESS); |
332 | |
|
|
333 | glShadeModel (GL_SMOOTH); |
333 | glShadeModel (GL_SMOOTH); |
334 | |
334 | |
335 | glEnable (GL_LIGHTING); |
335 | glEnable (GL_LIGHTING); |
336 | |
|
|
337 | //GLfloat lightc[4] = { 1, 0.1, 0.1, 1 }; |
336 | //GLfloat lightc[4] = { 1, 0.1, 0.1, 1 }; |
338 | //glLightf (GL_LIGHT0, GL_QUADRATIC_ATTENUATION); |
337 | //glLightf (GL_LIGHT0, GL_QUADRATIC_ATTENUATION); |
339 | //glLightfv (GL_LIGHT0, GL_DIFFUSE, lightc); |
338 | //glLightfv (GL_LIGHT0, GL_DIFFUSE, lightc); |
340 | glEnable (GL_LIGHT0); |
339 | glEnable (GL_LIGHT0); |
341 | glEnable (GL_COLOR_MATERIAL); |
|
|
342 | |
340 | |
343 | /* Loop until done. */ |
341 | /* Loop until done. */ |
344 | start_time = SDL_GetTicks (); |
342 | start_time = SDL_GetTicks (); |
345 | frames = 0; |
343 | frames = 0; |
346 | while (!done) |
344 | while (!done) |
… | |
… | |
360 | lightp[3] = 1; |
358 | lightp[3] = 1; |
361 | glLightfv (GL_LIGHT0, GL_POSITION, lightp); |
359 | glLightfv (GL_LIGHT0, GL_POSITION, lightp); |
362 | |
360 | |
363 | #if 0 |
361 | #if 0 |
364 | static GLfloat ry; |
362 | static GLfloat ry; |
365 | ry += 0.03; |
363 | ry += 0.001; |
366 | v.d.x = cos (ry); |
364 | camera.d.x = cos (ry); |
367 | v.d.z = sin (ry); |
365 | camera.d.z = sin (ry); |
|
|
366 | //camera.d.y = sin (ry * 0.1); |
368 | #endif |
367 | #endif |
369 | |
368 | |
370 | draw_context c; |
369 | draw_context c (camera); |
371 | c.mode = draw_context::LIGHTED; |
370 | c.mode = draw_context::LIGHTED; |
372 | camera.draw (c); |
371 | camera.draw (c); |
373 | |
372 | |
374 | SDL_GL_SwapBuffers (); |
373 | SDL_GL_SwapBuffers (); |
|
|
374 | timer.frame (); |
375 | |
375 | |
376 | /* Check for error conditions. */ |
376 | /* Check for error conditions. */ |
377 | gl_error = glGetError (); |
377 | gl_error = glGetError (); |
378 | |
378 | |
379 | if (gl_error != GL_NO_ERROR) |
379 | if (gl_error != GL_NO_ERROR) |
… | |
… | |
431 | int slowly; |
431 | int slowly; |
432 | float gamma = 0.0; |
432 | float gamma = 0.0; |
433 | int noframe = 0; |
433 | int noframe = 0; |
434 | int fsaa = 0; |
434 | int fsaa = 0; |
435 | |
435 | |
|
|
436 | gl_matrix m(2); |
|
|
437 | m.translate (vec3 (2,3,4)); |
|
|
438 | |
436 | // load a entity |
439 | // load a entity |
|
|
440 | for (int i = 0; i < 7; i++) { |
437 | txtprt_parser p; |
441 | txtprt_parser p; |
|
|
442 | entity_anim *f = new entity_anim; |
438 | entity *e; |
443 | entity *e; |
439 | try { |
444 | try { |
440 | e = p.read ("test.blasc"); |
445 | e = p.read ("test.blasc"); |
441 | } catch (txtprt_i_exception & e) { |
446 | } catch (txtprt_i_exception & e) { |
442 | cout << "ERR: " << e.msg << endl; |
447 | cout << "ERR: " << e.msg << endl; |
443 | } |
448 | } |
|
|
449 | f->set (e); |
|
|
450 | f->m.translate (vec3 (i, -1, 0)); |
|
|
451 | f->vx = i * 10 + 5; |
|
|
452 | f->vy = i * 40 + 5; |
|
|
453 | f->vz = i * 60 + 5; |
444 | e->show (); |
454 | f->show (); |
|
|
455 | } |
445 | |
456 | |
446 | logo = 0; |
457 | logo = 0; |
447 | slowly = 0; |
458 | slowly = 0; |
448 | numtests = 1; |
459 | numtests = 1; |
449 | for (i = 1; argv[i]; ++i) |
460 | for (i = 1; argv[i]; ++i) |