Advertisement
Guest User

Untitled

a guest
May 31st, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. SDL_Init(SDL_INIT_EVERYTHING);
  2. SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); // red: 8 bits
  3. SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); // green: 8 bits
  4. SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); // blue: 8 bits
  5. SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); // alpha: 8 bits
  6. SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32); // r + g + b + a = 32 bits
  7. SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
  8. graphWindow = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_OPENGL);
  9.  
  10. typedef struct {
  11. float r;
  12. float g;
  13. float b;
  14. float a;
  15. } Pixel;
  16.  
  17. // ...
  18.  
  19. void main(void) {
  20. Pixel *pixels;
  21. // ...
  22. pixels = malloc(width * height * sizeof(Pixel));
  23. // ...
  24.  
  25. glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
  26. glClear(GL_COLOR_BUFFER_BIT);
  27.  
  28. while (graphNotClosed) {
  29. glDrawPixels(width, height, GL_RGBA, GL_FLOAT, pixels);
  30. // do some number cruching and change some elements of array "pixels"
  31. // ...
  32. SDL_GL_SwapWindow(graphWindow);
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement