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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /* $Id: cva.c,v 1.1 2000/11/01 03:14:12 gareth Exp $ */
  2. /*
  3. * Trivial CVA test, good for testing driver fastpaths (especially
  4. * indexed vertex buffers if they are supported).
  5. *
  6. * Gareth Hughes
  7. * November 2000
  8. */
  9. #include <stdlib.h>
  10. #include <stdio.h>
  11. #include <string.h>
  12. #define GL_GLEXT_LEGACY
  13. #include <GL/glut.h>
  14. GLfloat verts[][4] = {
  15. { 0.25, 0.25, 0.0, 0.0 },
  16. { 0.75, 0.25, 0.0, 0.0 },
  17. { 0.25, 0.75, 0.0, 0.0 },
  18. };
  19. GLubyte color[][4] = {
  20. { 0xff, 0x00, 0x00, 0x00 },
  21. { 0x00, 0xff, 0x00, 0x00 },
  22. { 0x00, 0x00, 0xff, 0x00 },
  23. };
  24. GLuint indices[] = { 0, 1, 2 };
  25. GLboolean compiled = GL_TRUE;
  26. void init( void )
  27. {
  28. glClearColor( 0.0, 0.0, 0.0, 0.0 );
  29. glShadeModel( GL_SMOOTH );
  30. glEnable( GL_DEPTH_TEST );
  31. glEnableClientState( GL_VERTEX_ARRAY );
  32. glEnableClientState( GL_COLOR_ARRAY );
  33. glMatrixMode( GL_PROJECTION );
  34. glLoadIdentity();
  35. glOrtho( 0.0, 1.0, 0.0, 1.0, -1.0, 1.0 );
  36. glMatrixMode( GL_MODELVIEW );
  37. glVertexPointer( 3, GL_FLOAT, sizeof(verts[0]), verts );
  38. glColorPointer( 4, GL_UNSIGNED_BYTE, 0, color );
  39. #ifdef GL_EXT_compiled_vertex_array
  40. if ( compiled ) {
  41. glLockArraysEXT( 0, 3 );
  42. }
  43. #endif
  44. }
  45. void display( void )
  46. {
  47. glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
  48. glDrawElements( GL_TRIANGLES, 3, GL_UNSIGNED_INT, indices );
  49. glFlush();
  50. }
  51. void keyboard( unsigned char key, int x, int y )
  52. {
  53. switch ( key ) {
  54. case 27:
  55. exit( 0 );
  56. break;
  57. }
  58. }
  59. int main( int argc, char **argv )
  60. {
  61. char *string;
  62. glutInit( &argc, argv );
  63. glutInitDisplayMode( GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH );
  64. glutInitWindowSize( 250, 250 );
  65. glutInitWindowPosition( 100, 100 );
  66. glutCreateWindow( "CVA Test" );
  67. /* Make sure the server supports GL 1.2 vertex arrays.
  68. */
  69. string = (char *) glGetString( GL_VERSION );
  70. if ( !strstr( string, "1.2" ) ) {
  71. fprintf( stderr, "This program requires OpenGL 1.2 vertex arrays.\n" );
  72. exit( -1 );
  73. }
  74. /* See if the server supports compiled vertex arrays.
  75. */
  76. string = (char *) glGetString( GL_EXTENSIONS );
  77. if ( !strstr( string, "GL_EXT_compiled_vertex_array" ) ) {
  78. fprintf( stderr, "Compiled vertex arrays not supported by this renderer.\n" );
  79. compiled = GL_FALSE;
  80. }
  81. init();
  82. glutDisplayFunc( display );
  83. glutKeyboardFunc( keyboard );
  84. glutMainLoop();
  85. return 0;
  86. }