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-line-clip.c 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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.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. glEnable(GL_VERTEX_PROGRAM_NV);
  38. #if 0
  39. glBegin(GL_LINES);
  40. glColor3f(0,0,1);
  41. glVertex3f( 0.75, -0.75, 0.0);
  42. glColor3f(0,1,0);
  43. glVertex3f( 0.75, 0.75, 0.0);
  44. glColor3f(0,1,0);
  45. glVertex3f( 0.75, 0.75, 0.0);
  46. glColor3f(1,0,0);
  47. glVertex3f(-1.75, 0.0, 0.0);
  48. glEnd();
  49. #else
  50. glBegin(GL_LINE_STRIP);
  51. glColor3f(0,0,1);
  52. glVertex3f( 0.75, -0.75, 0.0);
  53. glColor3f(0,1,0);
  54. glVertex3f( 0.75, 0.75, 0.0);
  55. glColor3f(1,0,0);
  56. glVertex3f(-1.75, 0.0, 0.0);
  57. glEnd();
  58. #endif
  59. glFlush();
  60. }
  61. static void Reshape( int width, int height )
  62. {
  63. glViewport( 0, 0, width, height );
  64. glMatrixMode( GL_PROJECTION );
  65. glLoadIdentity();
  66. glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
  67. glMatrixMode( GL_MODELVIEW );
  68. glLoadIdentity();
  69. /*glTranslatef( 0.0, 0.0, -15.0 );*/
  70. }
  71. static void Key( unsigned char key, int x, int y )
  72. {
  73. (void) x;
  74. (void) y;
  75. switch (key) {
  76. case 27:
  77. exit(0);
  78. break;
  79. }
  80. glutPostRedisplay();
  81. }
  82. int main( int argc, char *argv[] )
  83. {
  84. glutInit( &argc, argv );
  85. glutInitWindowPosition( 0, 0 );
  86. glutInitWindowSize( 250, 250 );
  87. glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH );
  88. glutCreateWindow(argv[0]);
  89. glewInit();
  90. glutReshapeFunc( Reshape );
  91. glutKeyboardFunc( Key );
  92. glutDisplayFunc( Display );
  93. Init();
  94. glutMainLoop();
  95. return 0;
  96. }