Updated tester:
#include <GL/gl.h> #include <SDL/SDL.h> #include <strings.h> #include <stdio.h>
int main(int argc, char **argv) { Uint32 i, mode, w, h;
if (argc != 2) goto usage;
SDL_Init(SDL_INIT_VIDEO);
if (strcmp(argv[1], "w") == 0) { mode = SDL_OPENGL; w = 800; h = 600; } else if (strcmp(argv[1], "f") == 0) { mode = SDL_OPENGL | SDL_FULLSCREEN; const SDL_VideoInfo *info = SDL_GetVideoInfo(); w = info->current_w; h = info->current_h; printf("Setting %dx%d fullscreen mode\n", w, h); } else { goto usage; }
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); SDL_SetVideoMode(w, h, 32, mode);
for (i = 0; i < 100; i++) { glClearColor(1, 1, 1, 1); glClear(GL_COLOR_BUFFER_BIT); SDL_GL_SwapBuffers(); glClearColor(0, 0, 0, 1); glClear(GL_COLOR_BUFFER_BIT); SDL_GL_SwapBuffers(); } return EXIT_SUCCESS;
usage: printf("Usage: %s [w|f]\n", argv[0]); return EXIT_FAILURE; }
// Compile with gcc test-gl.c -o test-gl -lSDL -lGL
Updated tester:
#include <GL/gl.h>
#include <SDL/SDL.h>
#include <strings.h>
#include <stdio.h>
int main(int argc, char **argv) {
Uint32 i, mode, w, h;
if (argc != 2)
goto usage;
SDL_Init( SDL_INIT_ VIDEO);
if (strcmp(argv[1], "w") == 0) {
mode = SDL_OPENGL;
w = 800;
h = 600;
} else if (strcmp(argv[1], "f") == 0) {
mode = SDL_OPENGL | SDL_FULLSCREEN;
const SDL_VideoInfo *info = SDL_GetVideoInfo();
w = info->current_w;
h = info->current_h;
printf("Setting %dx%d fullscreen mode\n", w, h);
} else {
goto usage;
}
SDL_GL_ SetAttribute( SDL_GL_ SWAP_CONTROL, 1); ode(w, h, 32, mode);
SDL_SetVideoM
for (i = 0; i < 100; i++) { GL_COLOR_ BUFFER_ BIT); GL_SwapBuffers( ); GL_COLOR_ BUFFER_ BIT); GL_SwapBuffers( );
glClearColor(1, 1, 1, 1);
glClear(
SDL_
glClearColor(0, 0, 0, 1);
glClear(
SDL_
}
return EXIT_SUCCESS;
usage:
printf("Usage: %s [w|f]\n", argv[0]);
return EXIT_FAILURE;
}
// Compile with gcc test-gl.c -o test-gl -lSDL -lGL