Comment 125 for bug 755841

Revision history for this message
In , Baughn (sveina) wrote :

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