comparison src/video/SDL_video.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 861bc36f0ab3
comparison
equal deleted inserted replaced
1925:411bfb37082b 1926:307355678142
29 #include "SDL_pixels_c.h" 29 #include "SDL_pixels_c.h"
30 #include "SDL_renderer_gl.h" 30 #include "SDL_renderer_gl.h"
31 #include "SDL_renderer_sw.h" 31 #include "SDL_renderer_sw.h"
32 #include "../events/SDL_sysevents.h" 32 #include "../events/SDL_sysevents.h"
33 #include "../events/SDL_events_c.h" 33 #include "../events/SDL_events_c.h"
34
35 #if SDL_VIDEO_OPENGL
36 #include "SDL_opengl.h"
37
38 /* On Windows, windows.h defines CreateWindow */
39 #ifdef CreateWindow
40 #undef CreateWindow
41 #endif
42 #endif /* SDL_VIDEO_OPENGL */
34 43
35 /* Available video drivers */ 44 /* Available video drivers */
36 static VideoBootStrap *bootstrap[] = { 45 static VideoBootStrap *bootstrap[] = {
37 #if SDL_VIDEO_DRIVER_QUARTZ 46 #if SDL_VIDEO_DRIVER_QUARTZ
38 &QZ_bootstrap, 47 &QZ_bootstrap,
2060 } 2069 }
2061 } else { 2070 } else {
2062 SDL_SetError("No dynamic GL support in video driver"); 2071 SDL_SetError("No dynamic GL support in video driver");
2063 } 2072 }
2064 return func; 2073 return func;
2074 }
2075
2076 SDL_bool
2077 SDL_GL_ExtensionSupported(const char *extension)
2078 {
2079 #if SDL_VIDEO_OPENGL
2080 const GLubyte *(APIENTRY * glGetStringFunc) (GLenum);
2081 const char *extensions;
2082 const char *start;
2083 const char *where, *terminator;
2084
2085 /* Extension names should not have spaces. */
2086 where = SDL_strchr(extension, ' ');
2087 if (where || *extension == '\0') {
2088 return SDL_FALSE;
2089 }
2090
2091 /* See if there's an environment variable override */
2092 start = SDL_getenv(extension);
2093 if (start && *start == '0') {
2094 return SDL_FALSE;
2095 }
2096
2097 /* Lookup the available extensions */
2098 glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
2099 if (glGetStringFunc) {
2100 extensions = (const char *) glGetStringFunc(GL_EXTENSIONS);
2101 } else {
2102 extensions = NULL;
2103 }
2104 if (!extensions) {
2105 return SDL_FALSE;
2106 }
2107
2108 /* It takes a bit of care to be fool-proof about parsing the
2109 * OpenGL extensions string. Don't be fooled by sub-strings,
2110 * etc. */
2111
2112 start = extensions;
2113
2114 for (;;) {
2115 where = SDL_strstr(start, extension);
2116 if (!where)
2117 break;
2118
2119 terminator = where + SDL_strlen(extension);
2120 if (where == start || *(where - 1) == ' ')
2121 if (*terminator == ' ' || *terminator == '\0')
2122 return SDL_TRUE;
2123
2124 start = terminator;
2125 }
2126 return SDL_FALSE;
2127 #else
2128 return SDL_FALSE;
2129 #endif
2065 } 2130 }
2066 2131
2067 int 2132 int
2068 SDL_GL_SetAttribute(SDL_GLattr attr, int value) 2133 SDL_GL_SetAttribute(SDL_GLattr attr, int value)
2069 { 2134 {