~ubuntu-branches/ubuntu/quantal/mesa/quantal

« back to all changes in this revision

Viewing changes to progs/tests/vptest3.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2007-02-21 12:44:07 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: james.westby@ubuntu.com-20070221124407-rgcacs32mycrtadl
ImportĀ upstreamĀ versionĀ 6.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */
2
 
 
3
 
#include <assert.h>
4
 
#include <string.h>
5
 
#include <stdio.h>
6
 
#include <stdlib.h>
7
 
#include <math.h>
8
 
#define GL_GLEXT_PROTOTYPES
9
 
#include <GL/glut.h>
10
 
 
11
 
static float Zrot = 0.0;
12
 
 
13
 
 
14
 
static void Display( void )
15
 
{
16
 
   glClearColor(0.3, 0.3, 0.3, 1);
17
 
   glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
18
 
 
19
 
   glEnable(GL_VERTEX_PROGRAM_NV);
20
 
 
21
 
   glLoadIdentity();
22
 
   glRotatef(Zrot, 0, 0, 1);
23
 
 
24
 
   glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 0, GL_MODELVIEW, GL_IDENTITY_NV);
25
 
   glPushMatrix();
26
 
 
27
 
   glVertexAttrib3fNV(3, 1, 0.5, 0.25);
28
 
   glBegin(GL_TRIANGLES);
29
 
#if 1
30
 
   glVertexAttrib3fNV(3, 1.0, 0.0, 0.0);
31
 
   glVertexAttrib2fNV(0, -0.5, -0.5);
32
 
   glVertexAttrib3fNV(3, 0.0, 1.0, 0.0);
33
 
   glVertexAttrib2fNV(0, 0.5, -0.5);
34
 
   glVertexAttrib3fNV(3, 0.0, 0.0, 1.0);
35
 
   glVertexAttrib2fNV(0, 0,  0.5);
36
 
#else
37
 
   glVertex2f( -1, -1);
38
 
   glVertex2f( 1, -1);
39
 
   glVertex2f( 0,  1);
40
 
#endif
41
 
   glEnd();
42
 
 
43
 
   glPopMatrix();
44
 
 
45
 
   glutSwapBuffers();
46
 
}
47
 
 
48
 
 
49
 
static void Reshape( int width, int height )
50
 
{
51
 
   glViewport( 0, 0, width, height );
52
 
   glMatrixMode( GL_PROJECTION );
53
 
   glLoadIdentity();
54
 
   /*   glFrustum( -2.0, 2.0, -2.0, 2.0, 5.0, 25.0 );*/
55
 
   glOrtho(-2.0, 2.0, -2.0, 2.0, -2.0, 2.0 );
56
 
   glMatrixMode( GL_MODELVIEW );
57
 
   glLoadIdentity();
58
 
   /*glTranslatef( 0.0, 0.0, -15.0 );*/
59
 
}
60
 
 
61
 
 
62
 
static void Key( unsigned char key, int x, int y )
63
 
{
64
 
   (void) x;
65
 
   (void) y;
66
 
   switch (key) {
67
 
      case 'z':
68
 
         Zrot -= 5.0;
69
 
         break;
70
 
      case 'Z':
71
 
         Zrot += 5.0;
72
 
         break;
73
 
      case 27:
74
 
         exit(0);
75
 
         break;
76
 
   }
77
 
   glutPostRedisplay();
78
 
}
79
 
 
80
 
 
81
 
static void Init( void )
82
 
{
83
 
   static const char *prog1 =
84
 
      "!!VP1.0\n"
85
 
      "MOV  o[COL0], v[COL0];\n"
86
 
#if 0
87
 
      "MOV   o[HPOS], v[OPOS];\n"
88
 
#else
89
 
      "DP4  o[HPOS].x, v[OPOS], c[0];\n"
90
 
      "DP4  o[HPOS].y, v[OPOS], c[1];\n"
91
 
      "DP4  o[HPOS].z, v[OPOS], c[2];\n"
92
 
      "DP4  o[HPOS].w, v[OPOS], c[3];\n"
93
 
#endif
94
 
      "END\n";
95
 
 
96
 
   glLoadProgramNV(GL_VERTEX_PROGRAM_NV, 1,
97
 
                   strlen(prog1),
98
 
                   (const GLubyte *) prog1);
99
 
   assert(glIsProgramNV(1));
100
 
 
101
 
   glBindProgramNV(GL_VERTEX_PROGRAM_NV, 1);
102
 
 
103
 
   printf("glGetError = %d\n", (int) glGetError());
104
 
}
105
 
 
106
 
 
107
 
int main( int argc, char *argv[] )
108
 
{
109
 
   glutInit( &argc, argv );
110
 
   glutInitWindowPosition( 0, 0 );
111
 
   glutInitWindowSize( 250, 250 );
112
 
   glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
113
 
   glutCreateWindow(argv[0]);
114
 
   glutReshapeFunc( Reshape );
115
 
   glutKeyboardFunc( Key );
116
 
   glutDisplayFunc( Display );
117
 
   Init();
118
 
   glutMainLoop();
119
 
   return 0;
120
 
}