sam8641

Untitled

Aug 9th, 2012
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. // Save as test1.cpp and compile with:
  2. // gcc -I../libsdl/SDL -lSDL -lGL -o test1 test1.cpp
  3.  
  4. // run and compare this test with software rendering
  5. // ./test1
  6. // LIBGL_ALWAYS_SOFTWARE=1 ./test1
  7.  
  8. // red, yellow, pink, and white lines should show.
  9. // The problem with Nouveau: only red and yellow lines are shown
  10. // This problem occurs on GL_SHORT or GL_FLOAT, but not GL_INT
  11.  
  12. // Hardware: NV44 [GeForce 6200SE TurboCache (TM)] (rev a1)
  13.  
  14. #include <SDL/SDL.h>
  15. #include <SDL/SDL_opengl.h>
  16. #include <unistd.h>
  17.  
  18. int main(int argc, char **argv)
  19. {
  20. SDL_Init(SDL_INIT_VIDEO);
  21. SDL_Surface *screen = SDL_SetVideoMode(512, 384, 0, SDL_OPENGL);
  22.  
  23. glScalef(1.0 / 32768, 1.0 / 32768, 1);
  24.  
  25. const int array1size = 32;
  26. short array1[array1size];
  27.  
  28. for(int i=0; i < array1size; i++)
  29. {
  30. array1[i] = i * 23565 + 25782 + i * i * 2357;
  31. }
  32.  
  33. while(true)
  34. {
  35. usleep(20000);
  36. SDL_Event event;
  37. while(SDL_PollEvent(&event))
  38. {
  39. switch(event.type)
  40. {
  41. case SDL_QUIT:
  42. SDL_Quit();
  43. return 0;
  44. break;
  45. }
  46. }
  47.  
  48. for(int i=0; i < array1size; i++)
  49. array1[i] += 20 + i * 4;
  50.  
  51.  
  52. glVertexPointer(2, GL_SHORT, 0, array1);
  53.  
  54. //int array2[array1size];
  55. //for(int i=0; i < array1size; i++)
  56. // array2[i] = array1[i];
  57. //glVertexPointer(2, GL_INT, 0, array2);
  58.  
  59. glClear(GL_COLOR_BUFFER_BIT);
  60. glEnableClientState(GL_VERTEX_ARRAY);
  61. for(int i=0; i < array1size/2; i += 4)
  62. {
  63. glColor3ub(255,i & 4 ? 255 : 0,i & 8 ? 255 : 0);
  64. glDrawArrays(GL_LINE_LOOP, i, 4);
  65. }
  66. //glDrawArrays(GL_LINE_LOOP, 0, array1size / 2);
  67. glDisableClientState(GL_VERTEX_ARRAY);
  68. SDL_GL_SwapBuffers();
  69.  
  70. }
  71. return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment