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