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

Comparing libgender/test.C (file contents):
Revision 1.26 by root, Tue Oct 5 03:39:47 2004 UTC vs.
Revision 1.27 by root, Tue Oct 5 06:03:16 2004 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 <sh/sh.hpp>
6
7using namespace SH;
8 5
9#include "SDL.h" 6#include "SDL.h"
10
11#include "SDL_opengl.h" 7#include "SDL_opengl.h"
12
13/* Undefine this if you want a flat cube instead of a rainbow cube */
14#define SHADED_CUBE
15
16/* Define this to be the name of the logo image to use with -logo */
17#define LOGO_FILE "icon.bmp"
18 8
19static SDL_Surface *global_image = NULL; 9static SDL_Surface *global_image = NULL;
20static GLuint global_texture = 0; 10static GLuint global_texture = 0;
21 11
22#include "entity.h" 12#include "entity.h"
26/**********************************************************************/ 16/**********************************************************************/
27 17
28view camera; 18view camera;
29vec3 camera_velocity; 19vec3 camera_velocity;
30float camera_velocity_factor = 10; 20float camera_velocity_factor = 10;
31
32ShColor3f color = ShColor3f(.5, 0.9, 0.2);
33ShPoint3f lightPos = ShPoint3f(0.0, 0.0, 10.0);
34ShMatrix4x4f mvp;
35ShProgram vsh, fsh;
36
37void
38init_shaders ()
39{
40 {
41 vsh = SH_BEGIN_PROGRAM ("gpu:vertex")
42 ShInputNormal3f normal;
43 ShInputPosition4f p;
44
45 ShOutputPoint4f ov;
46 ShOutputNormal3f on;
47 ShOutputVector3f lvv;
48 ShOutputPosition4f opd;
49
50 opd = mvp | p;
51 on = normalize (mvp | normal);
52 ov = -normalize (mvp | p);
53 lvv = normalize (lightPos - (mvp | p) (0, 1, 2));
54 SH_END;
55 }
56
57 // declare and initialize diffuse color
58 ShColor3f kd = ShColor3f (0.5, 0.7, 0.9);
59
60 {
61 fsh = SH_BEGIN_PROGRAM ("gpu:fragment")
62 ShInputVector4f v;
63 ShInputNormal3f n;
64 ShInputVector3f lvv;
65 ShInputPosition4f p;
66
67 ShOutputColor3f out;
68 out (0, 1, 2) = color * dot (normalize (n), normalize (lvv));
69 SH_END;
70 }
71}
72 21
73void 22void
74HotKey_ToggleFullScreen (void) 23HotKey_ToggleFullScreen (void)
75{ 24{
76 SDL_Surface *screen; 25 SDL_Surface *screen;
401 glMatrixMode (GL_MODELVIEW); 350 glMatrixMode (GL_MODELVIEW);
402 glLoadIdentity (); 351 glLoadIdentity ();
403 352
404 glEnable (GL_CULL_FACE); 353 glEnable (GL_CULL_FACE);
405 glEnable (GL_DEPTH_TEST); 354 glEnable (GL_DEPTH_TEST);
406 shInit();
407 shSetBackend("arb");
408 glEnable(GL_VERTEX_PROGRAM_ARB); 355 glEnable(GL_VERTEX_PROGRAM_ARB);
409 glEnable(GL_FRAGMENT_PROGRAM_ARB); 356 glEnable(GL_FRAGMENT_PROGRAM_ARB);
410 357
411 init_shaders();
412 shBind(vsh);
413 shBind(fsh);
414 glShadeModel (GL_SMOOTH); 358 glShadeModel (GL_SMOOTH);
415 359
416 glEnable (GL_LIGHTING); 360 glEnable (GL_LIGHTING);
417 //GLfloat lightc[4] = { 1, 0.1, 0.1, 1 }; 361 //GLfloat lightc[4] = { 1, 0.1, 0.1, 1 };
418 //glLightf (GL_LIGHT0, GL_QUADRATIC_ATTENUATION); 362 //glLightf (GL_LIGHT0, GL_QUADRATIC_ATTENUATION);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines