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

« back to all changes in this revision

Viewing changes to progs/trivial/vp-tri.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 void Init( void )
12
 
{
13
 
   GLint errno;
14
 
   GLuint prognum;
15
 
   
16
 
   static const char *prog1 =
17
 
      "!!ARBvp1.0\n"
18
 
      "MOV  result.color, vertex.color;\n"
19
 
/*       "MOV  result.color, {0,0,0,1};\n"  */
20
 
      "MOV  result.position, vertex.position;\n"
21
 
      "END\n";
22
 
 
23
 
 
24
 
   glGenProgramsARB(1, &prognum);
25
 
 
26
 
   glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum);
27
 
   glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
28
 
                      strlen(prog1), (const GLubyte *) prog1);
29
 
 
30
 
   assert(glIsProgramARB(prognum));
31
 
   errno = glGetError();
32
 
   printf("glGetError = %d\n", errno);
33
 
   if (errno != GL_NO_ERROR)
34
 
   {
35
 
      GLint errorpos;
36
 
 
37
 
      glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos);
38
 
      printf("errorpos: %d\n", errorpos);
39
 
      printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
40
 
   }
41
 
}
42
 
 
43
 
static void Display( void )
44
 
{
45
 
   glClearColor(0.3, 0.3, 0.3, 1);
46
 
   glClear( GL_COLOR_BUFFER_BIT  );
47
 
 
48
 
   glEnable(GL_VERTEX_PROGRAM_NV);
49
 
 
50
 
   glBegin(GL_TRIANGLES);
51
 
   glColor3f(0,0,1); 
52
 
   glVertex3f( 0.9, -0.9, 0.0);
53
 
   glColor3f(0,1,0); 
54
 
   glVertex3f( 0.9,  0.9, 0.0);
55
 
   glColor3f(1,0,0); 
56
 
   glVertex3f(-0.9,  0.0, 0.0);
57
 
   glEnd();
58
 
 
59
 
 
60
 
   glFlush(); 
61
 
}
62
 
 
63
 
 
64
 
static void Reshape( int width, int height )
65
 
{
66
 
   glViewport( 0, 0, width, height );
67
 
   glMatrixMode( GL_PROJECTION );
68
 
   glLoadIdentity();
69
 
   glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
70
 
   glMatrixMode( GL_MODELVIEW );
71
 
   glLoadIdentity();
72
 
   /*glTranslatef( 0.0, 0.0, -15.0 );*/
73
 
}
74
 
 
75
 
 
76
 
static void Key( unsigned char key, int x, int y )
77
 
{
78
 
   (void) x;
79
 
   (void) y;
80
 
   switch (key) {
81
 
      case 27:
82
 
         exit(0);
83
 
         break;
84
 
   }
85
 
   glutPostRedisplay();
86
 
}
87
 
 
88
 
 
89
 
 
90
 
 
91
 
int main( int argc, char *argv[] )
92
 
{
93
 
   glutInit( &argc, argv );
94
 
   glutInitWindowPosition( 0, 0 );
95
 
   glutInitWindowSize( 250, 250 );
96
 
   glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE );
97
 
   glutCreateWindow(argv[0]);
98
 
   glutReshapeFunc( Reshape );
99
 
   glutKeyboardFunc( Key );
100
 
   glutDisplayFunc( Display );
101
 
   Init();
102
 
   glutMainLoop();
103
 
   return 0;
104
 
}