59static void OOBadOpenGLExtensionUsed(
void)
GCC_ATTR((noreturn, used));
63PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC)&OOBadOpenGLExtensionUsed;
64PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC)&OOBadOpenGLExtensionUsed;
65PFNGLUNIFORM1IARBPROC glUniform1iARB = (PFNGLUNIFORM1IARBPROC)&OOBadOpenGLExtensionUsed;
66PFNGLUNIFORM1FARBPROC glUniform1fARB = (PFNGLUNIFORM1FARBPROC)&OOBadOpenGLExtensionUsed;
67PFNGLUNIFORMMATRIX3FVARBPROC glUniformMatrix3fvARB = (PFNGLUNIFORMMATRIX3FVARBPROC)&OOBadOpenGLExtensionUsed;
68PFNGLUNIFORMMATRIX4FVARBPROC glUniformMatrix4fvARB = (PFNGLUNIFORMMATRIX4FVARBPROC)&OOBadOpenGLExtensionUsed;
69PFNGLUNIFORM4FVARBPROC glUniform4fvARB = (PFNGLUNIFORM4FVARBPROC)&OOBadOpenGLExtensionUsed;
70PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC)&OOBadOpenGLExtensionUsed;
71PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC)&OOBadOpenGLExtensionUsed;
72PFNGLGETINFOLOGARBPROC glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC)&OOBadOpenGLExtensionUsed;
73PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC)&OOBadOpenGLExtensionUsed;
74PFNGLATTACHOBJECTARBPROC glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC)&OOBadOpenGLExtensionUsed;
75PFNGLDELETEOBJECTARBPROC glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC)&OOBadOpenGLExtensionUsed;
76PFNGLLINKPROGRAMARBPROC glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC)&OOBadOpenGLExtensionUsed;
77PFNGLCOMPILESHADERARBPROC glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC)&OOBadOpenGLExtensionUsed;
78PFNGLSHADERSOURCEARBPROC glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC)&OOBadOpenGLExtensionUsed;
79PFNGLUNIFORM2FVARBPROC glUniform2fvARB = (PFNGLUNIFORM2FVARBPROC)&OOBadOpenGLExtensionUsed;
80PFNGLBINDATTRIBLOCATIONARBPROC glBindAttribLocationARB = (PFNGLBINDATTRIBLOCATIONARBPROC)&OOBadOpenGLExtensionUsed;
81PFNGLENABLEVERTEXATTRIBARRAYARBPROC glEnableVertexAttribArrayARB = (PFNGLENABLEVERTEXATTRIBARRAYARBPROC)&OOBadOpenGLExtensionUsed;
82PFNGLVERTEXATTRIBPOINTERARBPROC glVertexAttribPointerARB = (PFNGLVERTEXATTRIBPOINTERARBPROC)&OOBadOpenGLExtensionUsed;
83PFNGLDISABLEVERTEXATTRIBARRAYARBPROC glDisableVertexAttribArrayARB = (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC)&OOBadOpenGLExtensionUsed;
84PFNGLVALIDATEPROGRAMARBPROC glValidateProgramARB = (PFNGLVALIDATEPROGRAMARBPROC)&OOBadOpenGLExtensionUsed;
87#if OO_SHADERS || OO_MULTITEXTURE
88PFNGLACTIVETEXTUREARBPROC glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)&OOBadOpenGLExtensionUsed;
92PFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC)&OOBadOpenGLExtensionUsed;
96PFNGLGENBUFFERSARBPROC glGenBuffersARB = (PFNGLGENBUFFERSARBPROC)&OOBadOpenGLExtensionUsed;
97PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC)&OOBadOpenGLExtensionUsed;
98PFNGLBINDBUFFERARBPROC glBindBufferARB = (PFNGLBINDBUFFERARBPROC)&OOBadOpenGLExtensionUsed;
99PFNGLBUFFERDATAARBPROC glBufferDataARB = (PFNGLBUFFERDATAARBPROC)&OOBadOpenGLExtensionUsed;
103PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC)&OOBadOpenGLExtensionUsed;
104PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC)&OOBadOpenGLExtensionUsed;
105PFNGLGENRENDERBUFFERSEXTPROC glGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC)&OOBadOpenGLExtensionUsed;
106PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC)&OOBadOpenGLExtensionUsed;
107PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC)&OOBadOpenGLExtensionUsed;
108PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)&OOBadOpenGLExtensionUsed;
109PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)&OOBadOpenGLExtensionUsed;
110PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)&OOBadOpenGLExtensionUsed;
111PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC)&OOBadOpenGLExtensionUsed;
112PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC)&OOBadOpenGLExtensionUsed;
113PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)&OOBadOpenGLExtensionUsed;
114PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)&OOBadOpenGLExtensionUsed;
115PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)&OOBadOpenGLExtensionUsed;
116PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)&OOBadOpenGLExtensionUsed;
117PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)&OOBadOpenGLExtensionUsed;
118PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)&OOBadOpenGLExtensionUsed;
119PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)&OOBadOpenGLExtensionUsed;
120PFNGLGENVERTEXARRAYSPROC glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)&OOBadOpenGLExtensionUsed;
121PFNGLGENBUFFERSPROC glGenBuffers = (PFNGLGENBUFFERSPROC)&OOBadOpenGLExtensionUsed;
122PFNGLBINDVERTEXARRAYPROC glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)&OOBadOpenGLExtensionUsed;
123PFNGLBINDBUFFERPROC glBindBuffer = (PFNGLBINDBUFFERPROC)&OOBadOpenGLExtensionUsed;
124PFNGLBUFFERDATAPROC glBufferData = (PFNGLBUFFERDATAPROC)&OOBadOpenGLExtensionUsed;
125PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)&OOBadOpenGLExtensionUsed;
126PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)&OOBadOpenGLExtensionUsed;
127PFNGLUSEPROGRAMPROC glUseProgram = (PFNGLUSEPROGRAMPROC)&OOBadOpenGLExtensionUsed;
128PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)&OOBadOpenGLExtensionUsed;
129PFNGLUNIFORM1IPROC glUniform1i = (PFNGLUNIFORM1IPROC)&OOBadOpenGLExtensionUsed;
130PFNGLACTIVETEXTUREPROC glActiveTexture = (PFNGLACTIVETEXTUREPROC)&OOBadOpenGLExtensionUsed;
131PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC)&OOBadOpenGLExtensionUsed;
132PFNGLUNIFORM1FPROC glUniform1f = (PFNGLUNIFORM1FPROC)&OOBadOpenGLExtensionUsed;
133PFNGLUNIFORM2FVPROC glUniform2fv = (PFNGLUNIFORM2FVPROC)&OOBadOpenGLExtensionUsed;
134PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)&OOBadOpenGLExtensionUsed;
135PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)&OOBadOpenGLExtensionUsed;
136PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)&OOBadOpenGLExtensionUsed;
137PFNGLDELETEBUFFERSPROC glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)&OOBadOpenGLExtensionUsed;
138PFNGLDRAWBUFFERSPROC glDrawBuffers = (PFNGLDRAWBUFFERSPROC)&OOBadOpenGLExtensionUsed;
139PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)&OOBadOpenGLExtensionUsed;
140PFNGLTEXIMAGE2DMULTISAMPLEPROC glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC)&OOBadOpenGLExtensionUsed;
141PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)&OOBadOpenGLExtensionUsed;
142PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)&OOBadOpenGLExtensionUsed;
143PFNGLCLAMPCOLORPROC glClampColor = (PFNGLCLAMPCOLORPROC)&OOBadOpenGLExtensionUsed;
158@interface OOOpenGLExtensionManager (OOPrivate)
165- (void)checkVBOSupported;
169- (void)checkFBOSupported;
172#if GL_ARB_texture_env_combine
173- (void)checkTextureCombinersSupported;
176- (NSDictionary *) lookUpPerGPUSettingsWithVersionString:(NSString *)version extensionsString:(NSString *)extensionsStr;
183 NSArray *components = [extensionString componentsSeparatedByString:@" "];
184 NSMutableArray *result = [NSMutableArray arrayWithCapacity:[components count]];
185 NSEnumerator *extEnum =
nil;
186 NSString *extStr =
nil;
187 for (extEnum = [components objectEnumerator]; (extStr = [extEnum nextObject]); )
189 if ([extStr length] > 0) [result addObject:extStr];
202#if OOOPENGLEXTMGR_LOCK_SET_ACCESS
203 lock = [[NSLock alloc] init];
204 [lock setName:@"OOOpenGLExtensionManager extension set lock"];
216 const GLubyte *versionString = NULL, *curr = NULL;
222 NSString *extensionsStr = [NSString stringWithUTF8String:(char *)glGetString(GL_EXTENSIONS)];
223 extensions = [[NSSet alloc] initWithArray:ArrayOfExtensions(extensionsStr)];
225 vendor = [[NSString alloc] initWithUTF8String:(const char *)glGetString(GL_VENDOR)];
226 renderer = [[NSString alloc] initWithUTF8String:(const char *)glGetString(GL_RENDERER)];
228 versionString = glGetString(GL_VERSION);
229 if (versionString != NULL)
235 curr = versionString;
255 OOLog(
@"rendering.opengl.version",
@"OpenGL renderer version: %u.%u.%u (\"%s\
"). Vendor: \"%@\". Renderer: \"%@\".", major, minor, release, versionString, vendor, renderer);
256 OOLog(
@"rendering.opengl.extensions",
@"OpenGL extensions (%lu):\n%@", [extensions
count], [[extensions allObjects] componentsJoinedByString:
@", "]);
261 [NSException raise:@"OoliteOpenGLTooOldException"
262 format:@"Oolite requires at least OpenGL %u.%u. You have %u.%u (\"%s\").", kMinMajorVersion, kMinMinorVersion, major, minor, versionString];
265 NSString *versionStr = [[[NSString alloc] initWithUTF8String:(const char *)versionString] autorelease];
266 NSDictionary *gpuConfig = [
self lookUpPerGPUSettingsWithVersionString:versionStr extensionsString:extensionsStr];
269 [
self checkShadersSupported];
271 if (shadersAvailable)
274 defaultValue:
@"SHADERS_FULL"]);
276 defaultValue:
@"SHADERS_FULL"]);
279 shadersAvailable = NO;
281 OOLog(
kOOLogOpenGLShaderSupport,
@"Shaders will not be used (disallowed for GPU type \"%@\
").", [gpuConfig oo_stringForKey:
@"name" defaultValue:renderer]);
283 if (maximumShaderSetting < defaultShaderSetting)
285 defaultShaderSetting = maximumShaderSetting;
288 if (shadersAvailable)
299 GLint texImageUnitOverride = [gpuConfig oo_intForKey:@"texture_image_units" defaultValue:textureImageUnitCount];
300 if (texImageUnitOverride < textureImageUnitCount) textureImageUnitCount =
MAX(texImageUnitOverride, 0);
304 [
self checkVBOSupported];
307 [
self checkFBOSupported];
310 [
self checkTextureCombinersSupported];
311 GLint texUnitOverride = [gpuConfig oo_intForKey:@"texture_units" defaultValue:textureUnitCount];
312 if (texUnitOverride < textureUnitCount) textureUnitCount =
MAX(texUnitOverride, 0);
315 usePointSmoothing = [gpuConfig oo_boolForKey:@"smooth_points" defaultValue:YES];
316 useLineSmoothing = [gpuConfig oo_boolForKey:@"smooth_lines" defaultValue:YES];
317 useDustShader = [gpuConfig oo_boolForKey:@"use_dust_shader" defaultValue:YES];
325#if OOOPENGLEXTMGR_LOCK_SET_ACCESS
344- (BOOL)haveExtension:(NSString *)extension
347#if OOOPENGLEXTMGR_LOCK_SET_ACCESS
351 BOOL result = [extensions containsObject:extension];
353#if OOOPENGLEXTMGR_LOCK_SET_ACCESS
361- (BOOL)shadersSupported
364 return shadersAvailable;
371- (BOOL)shadersForceDisabled
374 return shadersForceDisabled;
415- (GLint)textureImageUnitCount
418 return textureImageUnitCount;
445- (BOOL)textureCombinersSupported
448 return textureCombinersSupported;
455- (GLint)textureUnitCount
458 return textureUnitCount;
465- (NSUInteger)majorVersionNumber
471- (NSUInteger)minorVersionNumber
477- (NSUInteger)releaseVersionNumber
483- (void)getVersionMajor:(
unsigned *)outMajor minor:(
unsigned *)outMinor release:(
unsigned *)outRelease
485 if (outMajor != NULL) *outMajor = major;
486 if (outMinor != NULL) *outMinor = minor;
487 if (outRelease != NULL) *outRelease = release;
491- (BOOL) versionIsAtLeastMajor:(
unsigned)maj minor:(
unsigned)min
493 return major > maj || (major == maj && minor >= min);
497- (NSString *) vendorString
503- (NSString *) rendererString
509- (BOOL) usePointSmoothing
511 return usePointSmoothing;
515- (BOOL) useLineSmoothing
517 return useLineSmoothing;
521- (BOOL) useDustShader
523 return useDustShader;
534 const GLubyte *curr = *ioString;
536 while (
'0' <= *curr && *curr <=
'9')
538 result = result * 10 + *curr++ -
'0';
546@implementation OOOpenGLExtensionManager (OOPrivate)
557 shadersAvailable = NO;
558 shadersForceDisabled = NO;
565 NSArray *arguments = [[NSProcessInfo processInfo] arguments];
566 NSEnumerator *argEnum =
nil;
569 for (argEnum = [arguments objectEnumerator]; (arg = [argEnum nextObject]); )
571 if ([arg isEqual:
@"-noshaders"] || [arg isEqual:
@"--noshaders"])
573 shadersForceDisabled = YES;
579 NSString *
const requiredExtension[] =
581 @"GL_ARB_shading_language_100",
582 @"GL_ARB_fragment_shader",
583 @"GL_ARB_vertex_shader",
584 @"GL_ARB_multitexture",
585 @"GL_ARB_shader_objects",
588 NSString *
const *required = NULL;
590 for (required = requiredExtension; *required !=
nil; ++required)
592 if (![
self haveExtension:*required])
600 glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC)wglGetProcAddress(
"glGetObjectParameterivARB");
601 glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC)wglGetProcAddress(
"glCreateShaderObjectARB");
602 glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC)wglGetProcAddress(
"glGetInfoLogARB");
603 glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC)wglGetProcAddress(
"glCreateProgramObjectARB");
604 glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC)wglGetProcAddress(
"glAttachObjectARB");
605 glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC)wglGetProcAddress(
"glDeleteObjectARB");
606 glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC)wglGetProcAddress(
"glLinkProgramARB");
607 glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC)wglGetProcAddress(
"glCompileShaderARB");
608 glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC)wglGetProcAddress(
"glShaderSourceARB");
609 glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC)wglGetProcAddress(
"glUseProgramObjectARB");
610 glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)wglGetProcAddress(
"glActiveTextureARB");
611 glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC)wglGetProcAddress(
"glGetUniformLocationARB");
612 glUniform1iARB = (PFNGLUNIFORM1IARBPROC)wglGetProcAddress(
"glUniform1iARB");
613 glUniform1fARB = (PFNGLUNIFORM1FARBPROC)wglGetProcAddress(
"glUniform1fARB");
614 glUniformMatrix3fvARB = (PFNGLUNIFORMMATRIX3FVARBPROC)wglGetProcAddress(
"glUniformMatrix3fvARB");
615 glUniformMatrix4fvARB = (PFNGLUNIFORMMATRIX4FVARBPROC)wglGetProcAddress(
"glUniformMatrix4fvARB");
616 glUniform4fvARB = (PFNGLUNIFORM4FVARBPROC)wglGetProcAddress(
"glUniform4fvARB");
617 glUniform2fvARB = (PFNGLUNIFORM2FVARBPROC)wglGetProcAddress(
"glUniform2fvARB");
618 glBindAttribLocationARB = (PFNGLBINDATTRIBLOCATIONARBPROC)wglGetProcAddress(
"glBindAttribLocationARB");
619 glEnableVertexAttribArrayARB = (PFNGLENABLEVERTEXATTRIBARRAYARBPROC)wglGetProcAddress(
"glEnableVertexAttribArrayARB");
620 glVertexAttribPointerARB = (PFNGLVERTEXATTRIBPOINTERARBPROC)wglGetProcAddress(
"glVertexAttribPointerARB");
621 glDisableVertexAttribArrayARB = (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC)wglGetProcAddress(
"glDisableVertexAttribArrayARB");
622 glValidateProgramARB = (PFNGLVALIDATEPROGRAMARBPROC)wglGetProcAddress(
"glValidateProgramARB");
625 glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &textureImageUnitCount);
627 shadersAvailable = YES;
633- (void)checkVBOSupported
637 if ([
self versionIsAtLeastMajor:1 minor:5] || [
self haveExtension:
@"GL_ARB_vertex_buffer_object"])
645 glGenBuffersARB = (PFNGLGENBUFFERSARBPROC)wglGetProcAddress(
"glGenBuffersARB");
646 glDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC)wglGetProcAddress(
"glDeleteBuffersARB");
647 glBindBufferARB = (PFNGLBINDBUFFERARBPROC)wglGetProcAddress(
"glBindBufferARB");
648 glBufferDataARB = (PFNGLBUFFERDATAARBPROC)wglGetProcAddress(
"glBufferDataARB");
656- (void)checkFBOSupported
660 if ([
self haveExtension:
@"GL_EXT_framebuffer_object"])
668 glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC)wglGetProcAddress(
"glGenFramebuffersEXT");
669 glBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC)wglGetProcAddress(
"glBindFramebufferEXT");
670 glGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC)wglGetProcAddress(
"glGenRenderbuffersEXT");
671 glBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC)wglGetProcAddress(
"glBindRenderbufferEXT");
672 glRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC)wglGetProcAddress(
"glRenderbufferStorageEXT");
673 glFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)wglGetProcAddress(
"glFramebufferRenderbufferEXT");
674 glFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)wglGetProcAddress(
"glFramebufferTexture2DEXT");
675 glCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)wglGetProcAddress(
"glCheckFramebufferStatusEXT");
676 glDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC)wglGetProcAddress(
"glDeleteFramebuffersEXT");
677 glDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC)wglGetProcAddress(
"glDeleteRenderbuffersEXT");
678 glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)wglGetProcAddress(
"glGenRenderbuffers");
679 glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)wglGetProcAddress (
"glBindRenderbuffer" );
680 glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)wglGetProcAddress (
"glRenderbufferStorage" );
681 glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)wglGetProcAddress (
"glGenFramebuffers" );
682 glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)wglGetProcAddress (
"glBindFramebuffer" );
683 glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)wglGetProcAddress (
"glFramebufferRenderbuffer" );
684 glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)wglGetProcAddress (
"glFramebufferTexture2D" );
685 glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)wglGetProcAddress (
"glGenVertexArrays" );
686 glGenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress (
"glGenBuffers" );
687 glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)wglGetProcAddress (
"glBindVertexArray" );
688 glBindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress (
"glBindBuffer" );
689 glBufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress (
"glBufferData" );
690 glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)wglGetProcAddress (
"glVertexAttribPointer" );
691 glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress (
"glEnableVertexAttribArray" );
692 glUseProgram = (PFNGLUSEPROGRAMPROC) wglGetProcAddress (
"glUseProgram" );
693 glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)wglGetProcAddress (
"glGetUniformLocation" );
694 glUniform1i = (PFNGLUNIFORM1IPROC)wglGetProcAddress (
"glUniform1i" );
695 glActiveTexture = (PFNGLACTIVETEXTUREPROC)wglGetProcAddress (
"glActiveTexture" );
696 glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC)wglGetProcAddress (
"glBlendFuncSeparate" );
697 glUniform1f = (PFNGLUNIFORM1FPROC)wglGetProcAddress (
"glUniform1f" );
698 glUniform2fv = (PFNGLUNIFORM2FVPROC)wglGetProcAddress (
"glUniform2fv" );
699 glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)wglGetProcAddress (
"glDeleteRenderbuffer" );
700 glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)wglGetProcAddress (
"glDeleteFramebuffers" );
701 glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)wglGetProcAddress (
"glDeleteVertexArrays" );
702 glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress (
"glDeleteBuffers" );
703 glDrawBuffers = (PFNGLDRAWBUFFERSPROC)wglGetProcAddress (
"glDrawBuffers" );
704 glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)wglGetProcAddress (
"glCheckFramebufferStatus" );
705 glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC)wglGetProcAddress (
"glTexImage2DMultisample" );
706 glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)wglGetProcAddress (
"glRenderbufferStorageMultisample" );
707 glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)wglGetProcAddress (
"glBlitFramebuffer" );
708 glClampColor = (PFNGLCLAMPCOLORPROC)wglGetProcAddress (
"glClampColor" );
716- (void)checkTextureCombinersSupported
718 textureCombinersSupported = [
self haveExtension:@"GL_ARB_texture_env_combine"];
720 if (textureCombinersSupported)
722 OOGL(glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &textureUnitCount));
726 glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)wglGetProcAddress(
"glActiveTextureARB");
728 glClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC)wglGetProcAddress(
"glClientActiveTextureARB");
733 textureUnitCount = 1;
743 if (regexps ==
nil)
return YES;
744 if ([regexps isKindOfClass:[NSString
class]])
746 return [string oo_matchesRegularExpression:regexps];
748 if ([regexps isKindOfClass:[NSArray
class]])
750 NSEnumerator *regexpEnum =
nil;
751 NSString *regexp =
nil;
753 for (regexpEnum = [regexps objectEnumerator]; (regexp = [regexpEnum nextObject]); )
755 if (
EXPECT_NOT(![regexp isKindOfClass:[NSString
class]]))
761 if (![
string oo_matchesRegularExpression:regexp])
return NO;
775 NSDictionary *configurations = context;
776 NSDictionary *dictA = [configurations oo_dictionaryForKey:keyA];
777 NSDictionary *dictB = [configurations oo_dictionaryForKey:keyB];
778 double precedenceA = [dictA oo_doubleForKey:@"precedence" defaultValue:1];
779 double precedenceB = [dictB oo_doubleForKey:@"precedence" defaultValue:1];
781 if (precedenceA > precedenceB)
return NSOrderedAscending;
782 if (precedenceA < precedenceB)
return NSOrderedDescending;
784 return [keyA caseInsensitiveCompare:keyB];
788- (NSDictionary *) lookUpPerGPUSettingsWithVersionString:(NSString *)versionStr extensionsString:(NSString *)extensionsStr
794 NSArray *keys = [[configurations allKeys] sortedArrayUsingFunction:CompareGPUSettingsByPriority context:configurations];
796 NSEnumerator *keyEnum =
nil;
798 NSDictionary *config =
nil;
800 for (keyEnum = [keys objectEnumerator]; (key = [keyEnum nextObject]); )
802 config = [configurations oo_dictionaryForKey:key];
805 NSDictionary *match = [config oo_dictionaryForKey:@"match"];
806 NSString *expr =
nil;
808 expr = [match objectForKey:@"vendor"];
811 expr = [match oo_stringForKey:@"renderer"];
814 expr = [match oo_stringForKey:@"version"];
817 expr = [match oo_stringForKey:@"extensions"];
820 OOLog(
@"rendering.opengl.gpuSpecific",
@"Matched GPU configuration \"%@\
".", key);
824 return [NSDictionary dictionary];
830@implementation OOOpenGLExtensionManager (Singleton)
839+ (id)allocWithZone:(NSZone *)inZone
850- (id)copyWithZone:(NSZone *)inZone
862- (NSUInteger)retainCount
882static void OOBadOpenGLExtensionUsed(
void)
884 OOLog(
@"rendering.opengl.badExtension",
@"***** An uninitialized OpenGL extension function has been called, terminating. This is a serious error, please report it. *****");
OOShaderSetting OOShaderSettingFromString(NSString *string)
static OODebugMonitor * sSingleton
#define OOLog(class, format,...)
static NSString *const kOOLogOpenGLShaderSupport
static OOOpenGLExtensionManager * sSingleton
static NSArray * ArrayOfExtensions(NSString *extensionString)
static unsigned IntegerFromString(const GLubyte **ioString)
static BOOL CheckRegExps(NSString *string, id regexps)
NSComparisonResult CompareGPUSettingsByPriority(id a, id b, void *context)
void checkShadersSupported()
NSDictionary * dictionaryFromFilesNamed:inFolder:andMerge:(NSString *fileName,[inFolder] NSString *folderName,[andMerge] BOOL mergeFiles)