Line data Source code
1 0 : /* 2 : 3 : OOTextureInternal.h 4 : 5 : Subclass interface for OOTexture. 6 : 7 : 8 : Copyright (C) 2007-2013 Jens Ayton and contributors 9 : 10 : Permission is hereby granted, free of charge, to any person obtaining a copy 11 : of this software and associated documentation files (the "Software"), to deal 12 : in the Software without restriction, including without limitation the rights 13 : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 : copies of the Software, and to permit persons to whom the Software is 15 : furnished to do so, subject to the following conditions: 16 : 17 : The above copyright notice and this permission notice shall be included in all 18 : copies or substantial portions of the Software. 19 : 20 : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 : AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 : LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 : SOFTWARE. 27 : 28 : */ 29 : 30 : #import "OOTexture.h" 31 : #import "OOOpenGLExtensionManager.h" 32 : 33 : 34 : @interface OOTexture (SubclassInterface) 35 : 36 0 : - (void) addToCaches; 37 0 : - (void) removeFromCaches; // Must be called on -dealloc (while -cacheKey is still valid) for cacheable textures. 38 : 39 0 : + (OOTexture *) existingTextureForKey:(NSString *)key; 40 : 41 : @end 42 : 43 : 44 : @interface OOTexture (SubclassResponsibilities) 45 : 46 0 : - (void)apply; 47 0 : - (NSSize)dimensions; 48 : 49 : 50 0 : - (void) forceRebind; 51 : 52 : @end 53 : 54 : 55 : @interface OOTexture (SubclassOptional) 56 : 57 0 : - (void)ensureFinishedLoading; // Default: does nothing 58 0 : - (BOOL) isFinishedLoading; // Default: YES 59 0 : - (NSString *) cacheKey; // Default: nil 60 0 : - (BOOL) isRectangleTexture; // Default: NO 61 0 : - (BOOL) isCubeMap; // Default: NO 62 0 : - (NSSize)texCoordsScale; // Default: 1,1 63 0 : - (struct OOPixMap) copyPixMapRepresentation; // Default: kOONullPixMap 64 : 65 : @end 66 : 67 : 68 : /* OOGenerateTextureCacheKey() 69 : OOTextureCacheKeyForSpecifier() 70 : 71 : Generate texture cache keys of the form used by normal file-based textures. 72 : */ 73 0 : NSString *OOGenerateTextureCacheKey(NSString *directory, NSString *name, OOTextureFlags options, float anisotropy, float lodBias); 74 0 : NSString *OOTextureCacheKeyForSpecifier(id specifier); 75 : 76 : 77 0 : typedef struct OOTextureInfo 78 : { 79 0 : GLfloat anisotropyScale; 80 0 : unsigned anisotropyAvailable: 1, 81 0 : clampToEdgeAvailable: 1, 82 0 : clientStorageAvailable: 1, 83 0 : textureLODBiasAvailable: 1, 84 0 : rectangleTextureAvailable: 1, 85 0 : cubeMapAvailable: 1, 86 0 : textureMaxLevelAvailable: 1; 87 0 : } OOTextureInfo; 88 : 89 0 : extern OOTextureInfo gOOTextureInfo; 90 : 91 : 92 : #ifndef GL_EXT_texture_filter_anisotropic 93 : #warning GL_EXT_texture_filter_anisotropic unavailable -- are you using an up-to-date glext.h? 94 : #endif 95 : 96 : #ifndef GL_CLAMP_TO_EDGE 97 : #ifdef GL_SGIS_texture_edge_clamp 98 : #define GL_CLAMP_TO_EDGE GL_CLAMP_TO_EDGE_SGIS 99 : #else 100 : #warning GL_CLAMP_TO_EDGE (OpenGL 1.2) and GL_SGIS_texture_edge_clamp are unavailable -- are you using an up-to-date gl.h? 101 0 : #define GL_CLAMP_TO_EDGE GL_CLAMP 102 : #endif 103 : #endif 104 : 105 : #if defined(GL_APPLE_client_storage) && !OOTEXTURE_RELOADABLE 106 : #define OO_GL_CLIENT_STORAGE (1) 107 : #define EnableClientStorage() OOGL(glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE)) 108 : #else 109 0 : #define OO_GL_CLIENT_STORAGE (0) 110 0 : #define EnableClientStorage() do {} while (0) 111 : #endif 112 : 113 : 114 : #ifndef GL_TEXTURE_MAX_LEVEL 115 : #ifdef GL_TEXTURE_MAX_LEVEL_SGIS 116 : #define GL_TEXTURE_MAX_LEVEL GL_TEXTURE_MAX_LEVEL_SGIS 117 : #else 118 0 : #define GL_TEXTURE_MAX_LEVEL 0x813D 119 : #endif 120 : #endif 121 : 122 : 123 : #if OO_TEXTURE_CUBE_MAP 124 : #ifndef GL_TEXTURE_CUBE_MAP 125 : #define GL_TEXTURE_CUBE_MAP GL_TEXTURE_CUBE_MAP_ARB 126 : #define GL_TEXTURE_CUBE_MAP_POSITIVE_X GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 127 : #endif 128 : #endif 129 :