Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vp-tri.c 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */
  2. #include <assert.h>
  3. #include <string.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <math.h>
  7. #include <GL/glew.h>
  8. #include <GL/glut.h>
  9. static void Init( void )
  10. {
  11. GLint errno;
  12. GLuint prognum;
  13. static const char *prog1 =
  14. "!!ARBvp1.0\n"
  15. "MOV result.color, vertex.color;\n"
  16. /* "MOV result.color, {0,0,0,1};\n" */
  17. "MOV result.position, vertex.position;\n"
  18. "END\n";
  19. glGenProgramsARB(1, &prognum);
  20. glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum);
  21. glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
  22. strlen(prog1), (const GLubyte *) prog1);
  23. assert(glIsProgramARB(prognum));
  24. errno = glGetError();
  25. printf("glGetError = %d\n", errno);
  26. if (errno != GL_NO_ERROR)
  27. {
  28. GLint errorpos;
  29. glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos);
  30. printf("errorpos: %d\n", errorpos);
  31. printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
  32. }
  33. }
  34. static void Display( void )
  35. {
  36. glClearColor(0.3, 0.3, 0.3, 1);
  37. glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
  38. glEnable(GL_VERTEX_PROGRAM_NV);
  39. glBegin(GL_TRIANGLES);
  40. glColor3f(0,0,.7);
  41. glVertex3f( 0.9, -0.9, -0.0);
  42. glColor3f(.8,0,0);
  43. glVertex3f( 0.9, 0.9, -0.0);
  44. glColor3f(0,.9,0);
  45. glVertex3f(-0.9, 0.0, -0.0);
  46. glEnd();
  47. glFlush();
  48. }
  49. static void Reshape( int width, int height )
  50. {
  51. glViewport( 0, 0, width, height );
  52. glMatrixMode( GL_PROJECTION );
  53. glLoadIdentity();
  54. glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
  55. glMatrixMode( GL_MODELVIEW );
  56. glLoadIdentity();
  57. /*glTranslatef( 0.0, 0.0, -15.0 );*/
  58. }
  59. static void Key( unsigned char key, int x, int y )
  60. {
  61. (void) x;
  62. (void) y;
  63. switch (key) {
  64. case 27:
  65. exit(0);
  66. break;
  67. }
  68. glutPostRedisplay();
  69. }
  70. int main( int argc, char *argv[] )
  71. {
  72. glutInit( &argc, argv );
  73. glutInitWindowPosition( 0, 0 );
  74. glutInitWindowSize( 250, 250 );
  75. glutInitDisplayMode( GLUT_DEPTH | GLUT_RGB | GLUT_SINGLE );
  76. glutCreateWindow(argv[0]);
  77. glewInit();
  78. glutReshapeFunc( Reshape );
  79. glutKeyboardFunc( Key );
  80. glutDisplayFunc( Display );
  81. Init();
  82. glutMainLoop();
  83. return 0;
  84. }