comparison src/video/SDL_renderer_gl.c @ 5145:c8e049de174c

Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
author Sam Lantinga <slouken@libsdl.org>
date Tue, 01 Feb 2011 12:19:46 -0800
parents 31e7f523ab3d
children ad50b3db78bd
comparison
equal deleted inserted replaced
5144:31e7f523ab3d 5145:c8e049de174c
110 110
111 SDL_RenderDriver GL_RenderDriver = { 111 SDL_RenderDriver GL_RenderDriver = {
112 GL_CreateRenderer, 112 GL_CreateRenderer,
113 { 113 {
114 "opengl", 114 "opengl",
115 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD | 115 (SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED),
116 SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED),
117 15, 116 15,
118 { 117 {
119 SDL_PIXELFORMAT_INDEX1LSB, 118 SDL_PIXELFORMAT_INDEX1LSB,
120 SDL_PIXELFORMAT_INDEX1MSB, 119 SDL_PIXELFORMAT_INDEX1MSB,
121 SDL_PIXELFORMAT_INDEX8, 120 SDL_PIXELFORMAT_INDEX8,
250 GL_CreateRenderer(SDL_Window * window, Uint32 flags) 249 GL_CreateRenderer(SDL_Window * window, Uint32 flags)
251 { 250 {
252 SDL_Renderer *renderer; 251 SDL_Renderer *renderer;
253 GL_RenderData *data; 252 GL_RenderData *data;
254 GLint value; 253 GLint value;
255 int doublebuffer;
256 254
257 /* Render directly to the window, unless we're compositing */ 255 /* Render directly to the window, unless we're compositing */
258 #ifndef __MACOSX__ 256 #ifndef __MACOSX__
259 if (flags & SDL_RENDERER_SINGLEBUFFER) { 257 if (flags & SDL_RENDERER_SINGLEBUFFER) {
260 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0); 258 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0);
302 renderer->DestroyRenderer = GL_DestroyRenderer; 300 renderer->DestroyRenderer = GL_DestroyRenderer;
303 renderer->info = GL_RenderDriver.info; 301 renderer->info = GL_RenderDriver.info;
304 renderer->window = window; 302 renderer->window = window;
305 renderer->driverdata = data; 303 renderer->driverdata = data;
306 304
307 renderer->info.flags = 305 renderer->info.flags = SDL_RENDERER_ACCELERATED;
308 (SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED);
309 306
310 if (GL_LoadFunctions(data) < 0) { 307 if (GL_LoadFunctions(data) < 0) {
311 GL_DestroyRenderer(renderer); 308 GL_DestroyRenderer(renderer);
312 return NULL; 309 return NULL;
313 } 310 }
333 } else { 330 } else {
334 SDL_GL_SetSwapInterval(0); 331 SDL_GL_SetSwapInterval(0);
335 } 332 }
336 if (SDL_GL_GetSwapInterval() > 0) { 333 if (SDL_GL_GetSwapInterval() > 0) {
337 renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; 334 renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
338 }
339
340 if (SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &doublebuffer) == 0) {
341 if (!doublebuffer) {
342 renderer->info.flags |= SDL_RENDERER_SINGLEBUFFER;
343 }
344 } 335 }
345 336
346 data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); 337 data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
347 renderer->info.max_texture_width = value; 338 renderer->info.max_texture_width = value;
348 data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); 339 data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);