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.

lineloop-elts.c 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* Test rebasing */
  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. GLfloat verts[][4] = {
  10. { 0.9, -0.9, 0.0, 1.0 },
  11. { 0.9, 0.9, 0.0, 1.0 },
  12. { -0.9, 0.9, 0.0, 1.0 },
  13. { -0.9, -0.9, 0.0, 1.0 },
  14. };
  15. GLubyte color[][4] = {
  16. { 0x00, 0x00, 0xff, 0x00 },
  17. { 0x00, 0xff, 0x00, 0x00 },
  18. { 0xff, 0x00, 0x00, 0x00 },
  19. { 0xff, 0xff, 0xff, 0x00 },
  20. };
  21. GLuint indices[] = { 1, 2, 3 };
  22. static void Init( void )
  23. {
  24. GLint errno;
  25. GLuint prognum;
  26. static const char *prog1 =
  27. "!!ARBvp1.0\n"
  28. "MOV result.color, vertex.color;\n"
  29. "MOV result.position, vertex.position;\n"
  30. "END\n";
  31. glGenProgramsARB(1, &prognum);
  32. glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum);
  33. glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
  34. strlen(prog1), (const GLubyte *) prog1);
  35. assert(glIsProgramARB(prognum));
  36. errno = glGetError();
  37. printf("glGetError = %d\n", errno);
  38. if (errno != GL_NO_ERROR)
  39. {
  40. GLint errorpos;
  41. glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos);
  42. printf("errorpos: %d\n", errorpos);
  43. printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
  44. }
  45. glEnableClientState( GL_VERTEX_ARRAY );
  46. glEnableClientState( GL_COLOR_ARRAY );
  47. glVertexPointer( 3, GL_FLOAT, sizeof(verts[0]), verts );
  48. glColorPointer( 4, GL_UNSIGNED_BYTE, 0, color );
  49. }
  50. static void Display( void )
  51. {
  52. glClearColor(0.3, 0.3, 0.3, 1);
  53. glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
  54. glEnable(GL_VERTEX_PROGRAM_NV);
  55. /* Should have min_index == 1, maybe force a rebase:
  56. */
  57. glDrawElements( GL_LINE_LOOP, 3, GL_UNSIGNED_INT, indices );
  58. glFlush();
  59. }
  60. static void Reshape( int width, int height )
  61. {
  62. glViewport( 0, 0, width, height );
  63. glMatrixMode( GL_PROJECTION );
  64. glLoadIdentity();
  65. glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
  66. glMatrixMode( GL_MODELVIEW );
  67. glLoadIdentity();
  68. /*glTranslatef( 0.0, 0.0, -15.0 );*/
  69. }
  70. static void Key( unsigned char key, int x, int y )
  71. {
  72. (void) x;
  73. (void) y;
  74. switch (key) {
  75. case 27:
  76. exit(0);
  77. break;
  78. }
  79. glutPostRedisplay();
  80. }
  81. int main( int argc, char *argv[] )
  82. {
  83. glutInit( &argc, argv );
  84. glutInitWindowPosition( 0, 0 );
  85. glutInitWindowSize( 250, 250 );
  86. glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH );
  87. glutCreateWindow(argv[0]);
  88. glewInit();
  89. glutReshapeFunc( Reshape );
  90. glutKeyboardFunc( Key );
  91. glutDisplayFunc( Display );
  92. Init();
  93. glutMainLoop();
  94. return 0;
  95. }