Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SDL_Init(SDL_INIT_EVERYTHING);
- SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); // red: 8 bits
- SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); // green: 8 bits
- SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); // blue: 8 bits
- SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); // alpha: 8 bits
- SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32); // r + g + b + a = 32 bits
- SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
- graphWindow = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_OPENGL);
- typedef struct {
- float r;
- float g;
- float b;
- float a;
- } Pixel;
- // ...
- void main(void) {
- Pixel *pixels;
- // ...
- pixels = malloc(width * height * sizeof(Pixel));
- // ...
- glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
- glClear(GL_COLOR_BUFFER_BIT);
- while (graphNotClosed) {
- glDrawPixels(width, height, GL_RGBA, GL_FLOAT, pixels);
- // do some number cruching and change some elements of array "pixels"
- // ...
- SDL_GL_SwapWindow(graphWindow);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement