Mercurial > sdl-ios-xcode
comparison src/video/SDL_renderer_gl.c @ 1926:307355678142
Added SDL_GL_ExtensionSupported()
Use GL_ARB_texture_rectangle in the OpenGL renderer, if supported.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 22 Jul 2006 21:58:17 +0000 |
parents | 69217fdd2c0a |
children | aeb8263d377a |
comparison
equal
deleted
inserted
replaced
1925:411bfb37082b | 1926:307355678142 |
---|---|
95 }; | 95 }; |
96 | 96 |
97 typedef struct | 97 typedef struct |
98 { | 98 { |
99 SDL_GLContext context; | 99 SDL_GLContext context; |
100 SDL_bool GL_ARB_texture_rectangle_supported; | |
100 } GL_RenderData; | 101 } GL_RenderData; |
101 | 102 |
102 typedef struct | 103 typedef struct |
103 { | 104 { |
104 GLuint texture; | 105 GLuint texture; |
224 } | 225 } |
225 | 226 |
226 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &renderer->info.max_texture_width); | 227 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &renderer->info.max_texture_width); |
227 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &renderer->info.max_texture_height); | 228 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &renderer->info.max_texture_height); |
228 | 229 |
229 /* FIXME: Check for GL_ARB_texture_rectangle and GL_EXT_texture_rectangle */ | 230 if (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle") |
231 || SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle")) { | |
232 data->GL_ARB_texture_rectangle_supported = SDL_TRUE; | |
233 } | |
230 | 234 |
231 /* Set up parameters for rendering */ | 235 /* Set up parameters for rendering */ |
232 glDisable(GL_DEPTH_TEST); | 236 glDisable(GL_DEPTH_TEST); |
233 glDisable(GL_CULL_FACE); | 237 glDisable(GL_CULL_FACE); |
234 #ifdef USE_GL_TEXTURE_RECTANGLE | 238 if (data->GL_ARB_texture_rectangle_supported) { |
235 glEnable(GL_TEXTURE_RECTANGLE_ARB); | 239 glEnable(GL_TEXTURE_RECTANGLE_ARB); |
236 #else | 240 } else { |
237 glEnable(GL_TEXTURE_2D); | 241 glEnable(GL_TEXTURE_2D); |
238 #endif | 242 } |
239 glMatrixMode(GL_PROJECTION); | 243 glMatrixMode(GL_PROJECTION); |
240 glLoadIdentity(); | 244 glLoadIdentity(); |
241 glMatrixMode(GL_MODELVIEW); | 245 glMatrixMode(GL_MODELVIEW); |
242 glLoadIdentity(); | 246 glLoadIdentity(); |
243 glViewport(0, 0, window->w, window->h); | 247 glViewport(0, 0, window->w, window->h); |
367 | 371 |
368 texture->driverdata = data; | 372 texture->driverdata = data; |
369 | 373 |
370 glGetError(); | 374 glGetError(); |
371 glGenTextures(1, &data->texture); | 375 glGenTextures(1, &data->texture); |
372 #ifdef USE_GL_TEXTURE_RECTANGLE | 376 if (renderdata->GL_ARB_texture_rectangle_supported) { |
373 data->type = GL_TEXTURE_RECTANGLE_ARB; | 377 data->type = GL_TEXTURE_RECTANGLE_ARB; |
374 texture_w = texture->w; | 378 texture_w = texture->w; |
375 texture_h = texture->h; | 379 texture_h = texture->h; |
376 data->texw = (GLfloat) texture->w; | 380 data->texw = (GLfloat) texture->w; |
377 data->texh = (GLfloat) texture->h; | 381 data->texh = (GLfloat) texture->h; |
378 #else | 382 } else { |
379 data->type = GL_TEXTURE_2D; | 383 data->type = GL_TEXTURE_2D; |
380 texture_w = power_of_2(texture->w); | 384 texture_w = power_of_2(texture->w); |
381 texture_h = power_of_2(texture->h); | 385 texture_h = power_of_2(texture->h); |
382 data->texw = (GLfloat) texture->w / texture_w; | 386 data->texw = (GLfloat) texture->w / texture_w; |
383 data->texh = (GLfloat) texture->h / texture_h; | 387 data->texh = (GLfloat) texture->h / texture_h; |
384 #endif | 388 } |
385 data->format = format; | 389 data->format = format; |
386 data->formattype = type; | 390 data->formattype = type; |
387 glBindTexture(data->type, data->texture); | 391 glBindTexture(data->type, data->texture); |
388 glTexImage2D(data->type, 0, internalFormat, texture_w, texture_h, 0, | 392 glTexImage2D(data->type, 0, internalFormat, texture_w, texture_h, 0, |
389 format, type, NULL); | 393 format, type, NULL); |