~ubuntu-branches/ubuntu/oneiric/mesa-demos/oneiric

« back to all changes in this revision

Viewing changes to src/trivial/vp-unfilled.c

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2010-09-27 16:18:27 UTC
  • Revision ID: james.westby@ubuntu.com-20100927161827-1yfgolc1oy9sjhi8
Tags: upstream-8.0.1
ImportĀ upstreamĀ versionĀ 8.0.1

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
#include <GL/glew.h>
 
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.position, vertex.position;\n"
 
20
      "END\n";
 
21
 
 
22
   glGenProgramsARB(1, &prognum);
 
23
 
 
24
   glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum);
 
25
   glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
 
26
                      strlen(prog1), (const GLubyte *) prog1);
 
27
 
 
28
   assert(glIsProgramARB(prognum));
 
29
   errno = glGetError();
 
30
   printf("glGetError = %d\n", errno);
 
31
   if (errno != GL_NO_ERROR)
 
32
   {
 
33
      GLint errorpos;
 
34
 
 
35
      glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos);
 
36
      printf("errorpos: %d\n", errorpos);
 
37
      printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
 
38
   }
 
39
}
 
40
 
 
41
static void Display( void )
 
42
{
 
43
   glClearColor(0.3, 0.3, 0.3, 1);
 
44
   glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
 
45
   glPolygonMode(GL_FRONT, GL_LINE);
 
46
   glPolygonMode(GL_BACK, GL_POINT);
 
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 | GLUT_DEPTH );
 
97
   glutCreateWindow(argv[0]);
 
98
   glewInit();
 
99
   glutReshapeFunc( Reshape );
 
100
   glutKeyboardFunc( Key );
 
101
   glutDisplayFunc( Display );
 
102
   Init();
 
103
   glutMainLoop();
 
104
   return 0;
 
105
}