Clone of mesa.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

drawrange.c 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* Test rebasing */
  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. 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. glDrawRangeElements( GL_TRIANGLES, 1, 3, 3, GL_UNSIGNED_INT, indices );
  56. glFlush();
  57. }
  58. static void Reshape( int width, int height )
  59. {
  60. glViewport( 0, 0, width, height );
  61. glMatrixMode( GL_PROJECTION );
  62. glLoadIdentity();
  63. glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
  64. glMatrixMode( GL_MODELVIEW );
  65. glLoadIdentity();
  66. /*glTranslatef( 0.0, 0.0, -15.0 );*/
  67. }
  68. static void Key( unsigned char key, int x, int y )
  69. {
  70. (void) x;
  71. (void) y;
  72. switch (key) {
  73. case 27:
  74. exit(0);
  75. break;
  76. }
  77. glutPostRedisplay();
  78. }
  79. int main( int argc, char *argv[] )
  80. {
  81. glutInit( &argc, argv );
  82. glutInitWindowPosition( 0, 0 );
  83. glutInitWindowSize( 250, 250 );
  84. glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH );
  85. glutCreateWindow(argv[0]);
  86. glutReshapeFunc( Reshape );
  87. glutKeyboardFunc( Key );
  88. glutDisplayFunc( Display );
  89. Init();
  90. glutMainLoop();
  91. return 0;
  92. }