foo
[demo_prior] / src / part_whitted.c
index 7154abf..5b98ad6 100644 (file)
@@ -1,6 +1,7 @@
 #include "opengl.h"
 #include "demo.h"
 #include "part.h"
+#include "sdr.h"
 
 static int init(void);
 static void destroy(void);
@@ -10,10 +11,6 @@ static void draw(long tm);
 static void mbutton(int bn, int st, int x, int y);
 static void mmotion(int x, int y);
 
-static float cam_theta, cam_phi, cam_dist = 8;
-
-static int bnstate[8];
-static int mouse_x, mouse_y;
 
 static struct demo_part part = {
        "whitted",
@@ -26,6 +23,14 @@ static struct demo_part part = {
        mbutton, mmotion
 };
 
+static float cam_theta, cam_phi, cam_dist = 8;
+
+static int bnstate[8];
+static int mouse_x, mouse_y;
+
+static unsigned int sdr;
+
+
 void reg_whitted(void)
 {
        add_part(&part);
@@ -34,6 +39,9 @@ void reg_whitted(void)
 
 static int init(void)
 {
+       if(!(sdr = create_program_load("sdr/whitted.v.glsl", "sdr/whitted.p.glsl"))) {
+               return -1;
+       }
        return 0;
 }
 
@@ -53,16 +61,27 @@ static void draw(long tm)
 {
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
+       /*
        glTranslatef(0, 0, -cam_dist);
        glRotatef(cam_phi, 1, 0, 0);
        glRotatef(cam_theta, 0, 1, 0);
-
-       glEnable(GL_LIGHTING);
-       glEnable(GL_LIGHT0);
-
-       glFrontFace(GL_CW);
-       glutSolidTeapot(1.0);
-       glFrontFace(GL_CCW);
+       */
+       glRotatef(-cam_theta, 0, 1, 0);
+       glRotatef(-cam_phi, 1, 0, 0);
+       glTranslatef(0, 0, cam_dist);
+
+       glUseProgram(sdr);
+
+       glBegin(GL_QUADS);
+       glTexCoord2f(0, 0);
+       glVertex2f(-1, -1);
+       glTexCoord2f(1, 0);
+       glVertex2f(1, -1);
+       glTexCoord2f(1, 1);
+       glVertex2f(1, 1);
+       glTexCoord2f(0, 1);
+       glVertex2f(-1, 1);
+       glEnd();
 }
 
 static void mbutton(int bn, int st, int x, int y)