Clone of mesa.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

vp-unfilled.c 2.2KB

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