summaryrefslogtreecommitdiffstats
path: root/progs/glsl/bump.c
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-01-16 15:27:11 -0700
committerBrian <[email protected]>2007-01-16 15:27:11 -0700
commit271d504ed72548a44a2a6e3712a10c17f62e243c (patch)
treed8c825c9516e830d567c95014de146e595bbc39b /progs/glsl/bump.c
parent9d0ae967d42f968b4b41d6847e4d678930ebe8bf (diff)
draw a box, press 'a' to animate
Diffstat (limited to 'progs/glsl/bump.c')
-rw-r--r--progs/glsl/bump.c71
1 files changed, 67 insertions, 4 deletions
diff --git a/progs/glsl/bump.c b/progs/glsl/bump.c
index b71c3af970b..a6846acf7e4 100644
--- a/progs/glsl/bump.c
+++ b/progs/glsl/bump.c
@@ -34,18 +34,20 @@ struct uniform_info {
static struct uniform_info Uniforms[] = {
{ "LightPosition", 3, -1, { 0.57737, 0.57735, 0.57735, 0.0 } },
{ "SurfaceColor", 3, -1, { 0.8, 0.8, 0.2, 0 } },
- { "BumpDensity", 1, -1, { 16.0, 0, 0, 0 } },
- { "BumpSize", 1, -1, { 0.15, 0, 0, 0 } },
+ { "BumpDensity", 1, -1, { 10.0, 0, 0, 0 } },
+ { "BumpSize", 1, -1, { 0.125, 0, 0, 0 } },
{ "SpecularFactor", 1, -1, { 0.5, 0, 0, 0 } },
{ NULL, 0, 0, { 0, 0, 0, 0 } }
};
static GLint win = 0;
-static GLfloat xRot = 0.0f, yRot = 0.0f, zRot = 0.0f;
+static GLfloat xRot = 20.0f, yRot = 0.0f, zRot = 0.0f;
static GLuint tangentAttrib;
+static GLboolean Anim = GL_FALSE;
+
static void
CheckError(int line)
@@ -75,6 +77,63 @@ Square(GLfloat size)
static void
+Cube(GLfloat size)
+{
+ /* +X */
+ glPushMatrix();
+ glRotatef(90, 0, 1, 0);
+ glTranslatef(0, 0, size);
+ Square(size);
+ glPopMatrix();
+
+ /* -X */
+ glPushMatrix();
+ glRotatef(-90, 0, 1, 0);
+ glTranslatef(0, 0, size);
+ Square(size);
+ glPopMatrix();
+
+ /* +Y */
+ glPushMatrix();
+ glRotatef(90, 1, 0, 0);
+ glTranslatef(0, 0, size);
+ Square(size);
+ glPopMatrix();
+
+ /* -Y */
+ glPushMatrix();
+ glRotatef(-90, 1, 0, 0);
+ glTranslatef(0, 0, size);
+ Square(size);
+ glPopMatrix();
+
+
+ /* +Z */
+ glPushMatrix();
+ glTranslatef(0, 0, size);
+ Square(size);
+ glPopMatrix();
+
+ /* -Z */
+ glPushMatrix();
+ glRotatef(180, 0, 1, 0);
+ glTranslatef(0, 0, size);
+ Square(size);
+ glPopMatrix();
+
+}
+
+
+static void
+Idle(void)
+{
+ GLint t = glutGet(GLUT_ELAPSED_TIME);
+ yRot = t * 0.05;
+ glutPostRedisplay();
+}
+
+
+static void
Redisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -84,7 +143,7 @@ Redisplay(void)
glRotatef(yRot, 0.0f, 1.0f, 0.0f);
glRotatef(zRot, 0.0f, 0.0f, 1.0f);
- Square(2.0);
+ Cube(1.5);
glPopMatrix();
@@ -128,6 +187,10 @@ Key(unsigned char key, int x, int y)
(void) y;
switch(key) {
+ case 'a':
+ Anim = !Anim;
+ glutIdleFunc(Anim ? Idle : NULL);
+ break;
case 'z':
zRot += step;
break;