diff src/video/SDL_renderer_gl.c @ 1923:d4572b97b08f

Switch OpenGL contexts when switching render contexts. Query the maximum texture size and show the current render parameters.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 22 Jul 2006 19:51:48 +0000
parents 4905cac7a4bd
children 69217fdd2c0a
line wrap: on
line diff
--- a/src/video/SDL_renderer_gl.c	Sat Jul 22 19:03:31 2006 +0000
+++ b/src/video/SDL_renderer_gl.c	Sat Jul 22 19:51:48 2006 +0000
@@ -33,6 +33,7 @@
 /* OpenGL renderer implementation */
 
 static SDL_Renderer *GL_CreateRenderer(SDL_Window * window, Uint32 flags);
+static int GL_ActivateRenderer(SDL_Renderer * renderer);
 static int GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
 static int GL_SetTexturePalette(SDL_Renderer * renderer,
                                 SDL_Texture * texture,
@@ -147,6 +148,7 @@
         return NULL;
     }
 
+    renderer->ActivateRenderer = GL_ActivateRenderer;
     renderer->CreateTexture = GL_CreateTexture;
     renderer->SetTexturePalette = GL_SetTexturePalette;
     renderer->GetTexturePalette = GL_GetTexturePalette;
@@ -185,9 +187,8 @@
         renderer->info.flags |= SDL_Renderer_PresentVSync;
     }
 
-    /* FIXME: Add a function to make the rendering context current when selecting the renderer */
-
-    /* FIXME: Query maximum texture size */
+    glGetIntegerv(GL_MAX_TEXTURE_SIZE, &renderer->info.max_texture_width);
+    glGetIntegerv(GL_MAX_TEXTURE_SIZE, &renderer->info.max_texture_height);
 
     /* FIXME: Check for GL_ARB_texture_rectangle and GL_EXT_texture_rectangle */
 
@@ -209,6 +210,15 @@
     return renderer;
 }
 
+static int
+GL_ActivateRenderer(SDL_Renderer * renderer)
+{
+    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
+    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
+
+    return SDL_GL_MakeCurrent(window->id, data->context);
+}
+
 static __inline__ int
 power_of_2(int input)
 {