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

Comparing libgender/test.C (file contents):
Revision 1.21 by root, Mon Oct 4 23:44:53 2004 UTC vs.
Revision 1.22 by root, Tue Oct 5 02:14:06 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;
5 8
6#include "SDL.h" 9#include "SDL.h"
7 10
8#include "SDL_opengl.h" 11#include "SDL_opengl.h"
9 12
23/**********************************************************************/ 26/**********************************************************************/
24 27
25view camera; 28view camera;
26vec3 camera_velocity; 29vec3 camera_velocity;
27float camera_velocity_factor = 10; 30float camera_velocity_factor = 10;
31
32ShMatrix4x4f mvp, mv;
33ShPoint3f light_pv;
34ShProgram vsh, fsh;
35
36void
37init_shaders() {
38 {
39 vsh = SH_BEGIN_PROGRAM("gpu:vertex")
40 ShInputNormal3f normal;
41 ShInputPosition4f p;
42
43 ShOutputPoint4f ov;
44 ShOutputNormal3f on;
45 ShOutputVector3f lvv;
46 ShOutputPosition4f opd;
47
48 opd = mvp | p;
49 on = normalize(mv | normal);
50 ov = -normalize(mv | p);
51 lvv = normalize(lightPos - (mv | p)(0,1,2));
52 SH_END;
53 }
54 // declare and initialize diffuse color
55 ShColor3f kd = ShColor3f(0.5, 0.7, 0.9);
56 {
57 fsh = SH_BEGIN_PROGRAM("gpu:fragment")
58 ShInputVector4f v;
59 ShInputNormal3f n;
60 ShInputVector3f lvv;
61 ShInputPosition4f p;
62
63 ShOutputColor3f out;
64 out(0,1,2) = Globals::color * dot(normalize(n), normalize(lvv));
65
66
67 SH_END;
68 }
69}
70
28 71
29void 72void
30HotKey_ToggleFullScreen (void) 73HotKey_ToggleFullScreen (void)
31{ 74{
32 SDL_Surface *screen; 75 SDL_Surface *screen;
357 glMatrixMode (GL_MODELVIEW); 400 glMatrixMode (GL_MODELVIEW);
358 glLoadIdentity (); 401 glLoadIdentity ();
359 402
360 glEnable (GL_CULL_FACE); 403 glEnable (GL_CULL_FACE);
361 glEnable (GL_DEPTH_TEST); 404 glEnable (GL_DEPTH_TEST);
405 shInit();
406 shSetBackend("arb");
407 glEnable(GL_VERTEX_PROGRAM_ARB);
408 glEnable(GL_FRAGMENT_PROGRAM_ARB);
409
410 init_shaders();
411 shBind(vsh);
412 shBind(fsh);
362 glShadeModel (GL_SMOOTH); 413 glShadeModel (GL_SMOOTH);
363 414
364 glEnable (GL_LIGHTING); 415 glEnable (GL_LIGHTING);
365 //GLfloat lightc[4] = { 1, 0.1, 0.1, 1 }; 416 //GLfloat lightc[4] = { 1, 0.1, 0.1, 1 };
366 //glLightf (GL_LIGHT0, GL_QUADRATIC_ATTENUATION); 417 //glLightf (GL_LIGHT0, GL_QUADRATIC_ATTENUATION);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines