comparison 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
comparison
equal deleted inserted replaced
1922:4905cac7a4bd 1923:d4572b97b08f
31 #include "SDL_yuv_sw_c.h" 31 #include "SDL_yuv_sw_c.h"
32 32
33 /* OpenGL renderer implementation */ 33 /* OpenGL renderer implementation */
34 34
35 static SDL_Renderer *GL_CreateRenderer(SDL_Window * window, Uint32 flags); 35 static SDL_Renderer *GL_CreateRenderer(SDL_Window * window, Uint32 flags);
36 static int GL_ActivateRenderer(SDL_Renderer * renderer);
36 static int GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); 37 static int GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
37 static int GL_SetTexturePalette(SDL_Renderer * renderer, 38 static int GL_SetTexturePalette(SDL_Renderer * renderer,
38 SDL_Texture * texture, 39 SDL_Texture * texture,
39 const SDL_Color * colors, int firstcolor, 40 const SDL_Color * colors, int firstcolor,
40 int ncolors); 41 int ncolors);
145 GL_DestroyRenderer(renderer); 146 GL_DestroyRenderer(renderer);
146 SDL_OutOfMemory(); 147 SDL_OutOfMemory();
147 return NULL; 148 return NULL;
148 } 149 }
149 150
151 renderer->ActivateRenderer = GL_ActivateRenderer;
150 renderer->CreateTexture = GL_CreateTexture; 152 renderer->CreateTexture = GL_CreateTexture;
151 renderer->SetTexturePalette = GL_SetTexturePalette; 153 renderer->SetTexturePalette = GL_SetTexturePalette;
152 renderer->GetTexturePalette = GL_GetTexturePalette; 154 renderer->GetTexturePalette = GL_GetTexturePalette;
153 renderer->UpdateTexture = GL_UpdateTexture; 155 renderer->UpdateTexture = GL_UpdateTexture;
154 renderer->LockTexture = GL_LockTexture; 156 renderer->LockTexture = GL_LockTexture;
183 } 185 }
184 if (SDL_GL_GetSwapInterval() > 0) { 186 if (SDL_GL_GetSwapInterval() > 0) {
185 renderer->info.flags |= SDL_Renderer_PresentVSync; 187 renderer->info.flags |= SDL_Renderer_PresentVSync;
186 } 188 }
187 189
188 /* FIXME: Add a function to make the rendering context current when selecting the renderer */ 190 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &renderer->info.max_texture_width);
189 191 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &renderer->info.max_texture_height);
190 /* FIXME: Query maximum texture size */
191 192
192 /* FIXME: Check for GL_ARB_texture_rectangle and GL_EXT_texture_rectangle */ 193 /* FIXME: Check for GL_ARB_texture_rectangle and GL_EXT_texture_rectangle */
193 194
194 /* Set up parameters for rendering */ 195 /* Set up parameters for rendering */
195 glDisable(GL_DEPTH_TEST); 196 glDisable(GL_DEPTH_TEST);
205 glLoadIdentity(); 206 glLoadIdentity();
206 glViewport(0, 0, window->w, window->h); 207 glViewport(0, 0, window->w, window->h);
207 glOrtho(0.0, (GLdouble) window->w, (GLdouble) window->h, 0.0, 0.0, 1.0); 208 glOrtho(0.0, (GLdouble) window->w, (GLdouble) window->h, 0.0, 0.0, 1.0);
208 209
209 return renderer; 210 return renderer;
211 }
212
213 static int
214 GL_ActivateRenderer(SDL_Renderer * renderer)
215 {
216 GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
217 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
218
219 return SDL_GL_MakeCurrent(window->id, data->context);
210 } 220 }
211 221
212 static __inline__ int 222 static __inline__ int
213 power_of_2(int input) 223 power_of_2(int input)
214 { 224 {