Fixed testgles on iOS (bug 1136)
authorSam Lantinga <slouken@libsdl.org>
Sun, 20 Feb 2011 14:16:11 -0800
changeset 536396799a165806
parent 5362 074fc8730031
child 5364 fec676157db5
Fixed testgles on iOS (bug 1136)
src/video/uikit/SDL_uikitopengles.m
test/common.c
test/testgles.c
     1.1 --- a/src/video/uikit/SDL_uikitopengles.m	Sun Feb 20 13:56:57 2011 -0800
     1.2 +++ b/src/video/uikit/SDL_uikitopengles.m	Sun Feb 20 14:16:11 2011 -0800
     1.3 @@ -40,7 +40,7 @@
     1.4         -Looking for the path to the OpenGL Library seems not to work in the iPhone Simulator.
     1.5         -We don't know that the path won't change in the future.
     1.6      */
     1.7 -    return SDL_LoadFunction(RTLD_DEFAULT, proc);
     1.8 +    return dlsym(RTLD_DEFAULT, proc);
     1.9  }
    1.10  
    1.11  /*
     2.1 --- a/test/common.c	Sun Feb 20 13:56:57 2011 -0800
     2.2 +++ b/test/common.c	Sun Feb 20 14:16:11 2011 -0800
     2.3 @@ -53,8 +53,6 @@
     2.4      state->gl_multisamplesamples = 0;
     2.5      state->gl_retained_backing = 1;
     2.6      state->gl_accelerated = -1;
     2.7 -    state->gl_major_version = 2;
     2.8 -    state->gl_minor_version = 1;
     2.9  
    2.10      return state;
    2.11  }
    2.12 @@ -590,8 +588,10 @@
    2.13                                  state->gl_accelerated);
    2.14          }
    2.15          SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, state->gl_retained_backing);
    2.16 -        SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, state->gl_major_version);
    2.17 -        SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, state->gl_minor_version);
    2.18 +        if (state->gl_major_version) {
    2.19 +            SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, state->gl_major_version);
    2.20 +            SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, state->gl_minor_version);
    2.21 +        }
    2.22  
    2.23          if (state->verbose & VERBOSE_MODES) {
    2.24              SDL_DisplayMode mode;
    2.25 @@ -712,6 +712,7 @@
    2.26                          SDL_GetError());
    2.27                  return SDL_FALSE;
    2.28              }
    2.29 +            SDL_GetWindowSize(state->windows[i], &state->window_w, &state->window_h);
    2.30  
    2.31              if (SDL_SetWindowDisplayMode(state->windows[i], &fullscreen_mode) < 0) {
    2.32                  fprintf(stderr, "Can't set up fullscreen display mode: %s\n",
     3.1 --- a/test/testgles.c	Sun Feb 20 13:56:57 2011 -0800
     3.2 +++ b/test/testgles.c	Sun Feb 20 14:16:11 2011 -0800
     3.3 @@ -177,7 +177,7 @@
     3.4          SDL_GL_SetSwapInterval(0);
     3.5      }
     3.6  
     3.7 -    SDL_GetCurrentDisplayMode(&mode);
     3.8 +    SDL_GetCurrentDisplayMode(0, &mode);
     3.9      printf("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format));
    3.10      printf("\n");
    3.11      printf("Vendor     : %s\n", glGetString(GL_VENDOR));
    3.12 @@ -243,6 +243,8 @@
    3.13  
    3.14      /* Set rendering settings for each context */
    3.15      for (i = 0; i < state->num_windows; ++i) {
    3.16 +        float aspectAdjust;
    3.17 +
    3.18          status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
    3.19          if (status) {
    3.20              printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
    3.21 @@ -251,10 +253,11 @@
    3.22              continue;
    3.23          }
    3.24  
    3.25 +        aspectAdjust = (4.0f / 3.0f) / ((float)state->window_w / state->window_h);
    3.26          glViewport(0, 0, state->window_w, state->window_h);
    3.27          glMatrixMode(GL_PROJECTION);
    3.28          glLoadIdentity();
    3.29 -        glOrthof(-2.0, 2.0, -2.0, 2.0, -20.0, 20.0);
    3.30 +        glOrthof(-2.0, 2.0, -2.0 * aspectAdjust, 2.0 * aspectAdjust, -20.0, 20.0);
    3.31          glMatrixMode(GL_MODELVIEW);
    3.32          glLoadIdentity();
    3.33          glEnable(GL_DEPTH_TEST);
    3.34 @@ -275,7 +278,7 @@
    3.35                  switch (event.window.event) {
    3.36                      case SDL_WINDOWEVENT_RESIZED:
    3.37                          for (i = 0; i < state->num_windows; ++i) {
    3.38 -                            if (event.window.windowID == state->windows[i]) {
    3.39 +                            if (event.window.windowID == SDL_GetWindowID(state->windows[i])) {
    3.40                                  status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
    3.41                                  if (status) {
    3.42                                      printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
    3.43 @@ -327,3 +330,5 @@
    3.44  }
    3.45  
    3.46  #endif /* HAVE_OPENGLES */
    3.47 +
    3.48 +/* vi: set ts=4 sw=4 expandtab: */