Line data Source code
1 0 : /* 2 : 3 : OOMaterial.h 4 : 5 : A material which can be applied to an OpenGL object, or more accurately, to 6 : the current OpenGL render state. 7 : 8 : This is an abstract class; actual materials should be subclasses. 9 : 10 : Currently, only shader materials are supported. Direct use of textures should 11 : also be replaced with an OOMaterial subclass. 12 : 13 : 14 : Copyright (C) 2007-2013 Jens Ayton and contributors 15 : 16 : Permission is hereby granted, free of charge, to any person obtaining a copy 17 : of this software and associated documentation files (the "Software"), to deal 18 : in the Software without restriction, including without limitation the rights 19 : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 20 : copies of the Software, and to permit persons to whom the Software is 21 : furnished to do so, subject to the following conditions: 22 : 23 : The above copyright notice and this permission notice shall be included in all 24 : copies or substantial portions of the Software. 25 : 26 : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 27 : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 28 : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 29 : AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 30 : LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 31 : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 : SOFTWARE. 33 : 34 : */ 35 : 36 : #import <Foundation/Foundation.h> 37 : #import "OOOpenGL.h" 38 : #import "OOWeakReference.h" 39 : #import "OOOpenGLExtensionManager.h" 40 : 41 : 42 0 : @interface OOMaterial: NSObject 43 : 44 : // Called once at startup (by -[Universe init]). 45 0 : + (void) setUp; 46 : 47 : 48 0 : - (NSString *) name; 49 : 50 : // Make this the current material. 51 0 : - (void) apply; 52 : 53 : /* Make no material the current material, tearing down anything set up by the 54 : current material. 55 : */ 56 0 : + (void) applyNone; 57 : 58 : /* Get current material. 59 : */ 60 0 : + (OOMaterial *) current; 61 : 62 : /* Ensure material is ready to be used in a display list. This is not 63 : required before using a material directly. 64 : */ 65 0 : - (void) ensureFinishedLoading; 66 0 : - (BOOL) isFinishedLoading; 67 : 68 : // Only used by shader material, but defined for all materials for convenience. 69 0 : - (void) setBindingTarget:(id<OOWeakReferenceSupport>)target; 70 : 71 : // True if material wants three-component cube map texture coordinates. 72 0 : - (BOOL) wantsNormalsAsTextureCoordinates; 73 : 74 : #if OO_MULTITEXTURE 75 : // Nasty hack: number of texture units for which the drawable should set its basic texture coordinates. 76 : - (NSUInteger) countOfTextureUnitsWithBaseCoordinates; 77 : #endif 78 : 79 : #ifndef NDEBUG 80 0 : - (NSSet *) allTextures; 81 : #endif 82 : 83 : @end 84 : 85 : 86 : @interface OOMaterial (OOSubclassInterface) 87 : 88 : // Subclass responsibilities - don't call directly. 89 0 : - (BOOL) doApply; // Override instead of -apply 90 0 : - (void) unapplyWithNext:(OOMaterial *)next; 91 : 92 : // Call at top of dealloc 93 0 : - (void) willDealloc; 94 : 95 : @end