Oolite
Loading...
Searching...
No Matches
OOSingleTextureMaterial.m
Go to the documentation of this file.
1/*
2
3OOSingleTextureMaterial.h
4
5
6Copyright (C) 2007-2013 Jens Ayton
7
8Permission is hereby granted, free of charge, to any person obtaining a copy
9of this software and associated documentation files (the "Software"), to deal
10in the Software without restriction, including without limitation the rights
11to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12copies of the Software, and to permit persons to whom the Software is
13furnished to do so, subject to the following conditions:
14
15The above copyright notice and this permission notice shall be included in all
16copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24SOFTWARE.
25
26*/
27
31#import "OOTexture.h"
32
33@implementation OOSingleTextureMaterial
34
35- (id)initWithName:(NSString*)name configuration:(NSDictionary*)configuration
36{
37 id texSpec = nil;
38
39 if (configuration != nil) {
40 texSpec = [configuration oo_textureSpecifierForKey:@"diffuse_map" defaultName:name];
41 } else {
42 texSpec = name;
43 }
44
45 return [self initWithName:name
47 configuration:configuration];
48}
49
50- (id)initWithName:(NSString*)name texture:(OOTexture*)texture configuration:(NSDictionary*)configuration
51{
52 if (name != nil && texture != nil) {
53 self = [super initWithName:name configuration:configuration];
54 if (self != nil) {
55 _texture = [texture retain];
56 }
57 } else {
58 DESTROY(self);
59 }
60
61 return self;
62}
63
64- (void)dealloc
65{
66 [self willDealloc];
67 [_texture release];
68
69 [super dealloc];
70}
71
73{
74 return [_texture description];
75}
76
77- (BOOL)doApply
78{
79 if (EXPECT_NOT(![super doApply]))
80 return NO;
81
83 return YES;
84}
85
86- (void)unapplyWithNext:(OOMaterial*)next
87{
88 if (![next isKindOfClass:[OOSingleTextureMaterial class]])
90 [super unapplyWithNext:next];
91}
92
97
99{
101}
102
107
108#ifdef OO_DEBUG_MONITOR_ENABLED
109- (NSSet*)allTextures
110{
111 return [NSSet setWithObject:_texture];
112}
113#endif
114
115@end
#define DESTROY(x)
#define EXPECT_NOT(x)
return nil
id initWithName:configuration:(NSString *name,[configuration] NSDictionary *configuration)
void unapplyWithNext:(OOMaterial *next)
void willDealloc()
Definition OOMaterial.m:131
id initWithName:texture:configuration:(NSString *name,[texture] OOTexture *texture,[configuration] NSDictionary *configuration)
void apply()
Definition OOTexture.m:258
BOOL isCubeMap()
Definition OOTexture.m:319
void applyNone()
Definition OOTexture.m:263
BOOL isFinishedLoading()
Definition OOTexture.m:282
void ensureFinishedLoading()
Definition OOTexture.m:278
id textureWithConfiguration:(id configuration)
Definition OOTexture.m:186