summaryrefslogtreecommitdiffstats
path: root/progs/trivial/tri-clip.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2009-02-10 16:44:02 -0700
committerBrian Paul <[email protected]>2009-02-10 16:44:02 -0700
commit5340b6dff73a0a23531ce2a5f28fba8303adab6e (patch)
treeb141fc3648568dd8b941c966059e6ed32a8bd0ad /progs/trivial/tri-clip.c
parent9fd26daec24f21dbe17afcb2e2ab272667ee9a69 (diff)
parentee4c921b65fb76998711f3c40330505cbc49a0e0 (diff)
Merge commit 'origin/gallium-master-merge'
This is the big merge of the gallium-0.2 branch into master. gallium-master-merge was just the staging area for it. Both gallium-0.2 and gallium-master-merge are considered closed now. Conflicts: progs/demos/Makefile src/mesa/main/state.c src/mesa/main/texenvprogram.c
Diffstat (limited to 'progs/trivial/tri-clip.c')
-rw-r--r--progs/trivial/tri-clip.c45
1 files changed, 33 insertions, 12 deletions
diff --git a/progs/trivial/tri-clip.c b/progs/trivial/tri-clip.c
index bf48533adcc..f30445cdba1 100644
--- a/progs/trivial/tri-clip.c
+++ b/progs/trivial/tri-clip.c
@@ -28,26 +28,21 @@
#include <GL/glut.h>
-#define CI_OFFSET_1 16
-#define CI_OFFSET_2 32
+static GLenum doubleBuffer;
+static GLfloat Xpos = 0, Ypos = 0;
-GLenum doubleBuffer;
-
static void Init(void)
{
fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
-
- glClearColor(0.0, 0.0, 1.0, 0.0);
+ glClearColor(0.0, 0.0, 1.0, 0.0);
}
static void Reshape(int width, int height)
{
-
glViewport(0, 0, (GLint)width, (GLint)height);
-
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
@@ -56,21 +51,45 @@ static void Reshape(int width, int height)
static void Key(unsigned char key, int x, int y)
{
-
switch (key) {
case 27:
exit(1);
default:
return;
}
-
glutPostRedisplay();
}
+static void
+SpecialKey(int key, int x, int y)
+{
+ const GLfloat step = 0.25;
+ (void) x;
+ (void) y;
+ switch (key) {
+ case GLUT_KEY_UP:
+ Ypos += step;
+ break;
+ case GLUT_KEY_DOWN:
+ Ypos -= step;
+ break;
+ case GLUT_KEY_LEFT:
+ Xpos -= step;
+ break;
+ case GLUT_KEY_RIGHT:
+ Xpos += step;
+ break;
+ }
+ glutPostRedisplay();
+}
+
static void Draw(void)
{
glClear(GL_COLOR_BUFFER_BIT);
+ glPushMatrix();
+ glTranslatef(Xpos, Ypos, 0);
+
glBegin(GL_TRIANGLES);
glColor3f(0,0,.7);
glVertex3f( 0.9, -0.9, -30.0);
@@ -80,12 +99,13 @@ static void Draw(void)
glVertex3f(-1.9, 0.0, -30.0);
glEnd();
+ glPopMatrix();
+
glFlush();
if (doubleBuffer) {
glutSwapBuffers();
}
-
}
static GLenum Args(int argc, char **argv)
@@ -131,7 +151,8 @@ int main(int argc, char **argv)
glutReshapeFunc(Reshape);
glutKeyboardFunc(Key);
+ glutSpecialFunc(SpecialKey);
glutDisplayFunc(Draw);
glutMainLoop();
- return 0;
+ return 0;
}