Mercurial > sdl-ios-xcode
changeset 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 |
files | src/video/SDL_renderer_gl.c src/video/SDL_sysvideo.h src/video/SDL_video.c test/common.c |
diffstat | 4 files changed, 31 insertions(+), 9 deletions(-) [+] |
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) {
--- a/src/video/SDL_sysvideo.h Sat Jul 22 19:03:31 2006 +0000 +++ b/src/video/SDL_sysvideo.h Sat Jul 22 19:51:48 2006 +0000 @@ -55,6 +55,7 @@ /* Define the SDL renderer structure */ struct SDL_Renderer { + int (*ActivateRenderer) (SDL_Renderer * renderer); int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture); int (*QueryTexturePixels) (SDL_Renderer * renderer, SDL_Texture * texture, void **pixels, int *pitch);
--- a/src/video/SDL_video.c Sat Jul 22 19:03:31 2006 +0000 +++ b/src/video/SDL_video.c Sat Jul 22 19:51:48 2006 +0000 @@ -1366,10 +1366,7 @@ window->renderer = SDL_CurrentDisplay.render_drivers[index].CreateRenderer(window, flags); - if (!window->renderer) { - return -1; - } - SDL_CurrentDisplay.current_renderer = window->renderer; + SDL_SelectRenderer(window->id); return 0; } @@ -1378,11 +1375,18 @@ SDL_SelectRenderer(SDL_WindowID windowID) { SDL_Window *window = SDL_GetWindowFromID(windowID); + SDL_Renderer *renderer; if (!window || !window->renderer) { return -1; } - SDL_CurrentDisplay.current_renderer = window->renderer; + renderer = window->renderer; + if (renderer && renderer->ActivateRenderer) { + if (renderer->ActivateRenderer(renderer) < 0) { + return -1; + } + } + SDL_CurrentDisplay.current_renderer = renderer; return 0; }
--- a/test/common.c Sat Jul 22 19:03:31 2006 +0000 +++ b/test/common.c Sat Jul 22 19:51:48 2006 +0000 @@ -610,7 +610,7 @@ if (n == 0) { fprintf(stderr, "No built-in render drivers\n"); } else { - fprintf(stderr, "Built-in render video drivers:\n"); + fprintf(stderr, "Built-in render drivers:\n"); for (i = 0; i < n; ++i) { SDL_GetRendererInfo(i, &info); PrintRenderer(&info); @@ -690,6 +690,13 @@ SDL_GetError()); return SDL_FALSE; } + if (state->verbose & VERBOSE_RENDER) { + SDL_RendererInfo info; + + fprintf(stderr, "Current renderer:\n"); + SDL_GetRendererInfo(-1, &info); + PrintRenderer(&info); + } } } SDL_SelectRenderer(state->windows[0]);