Oolite
Loading...
Searching...
No Matches
OOConcreteTexture Class Reference

#include <OOConcreteTexture.h>

Inheritance diagram for OOConcreteTexture:
Collaboration diagram for OOConcreteTexture:

Instance Methods

(id) - initWithLoader:key:options:anisotropy:lodBias:
(id) - initWithPath:key:options:anisotropy:lodBias:
(void) - dealloc [implementation]
(NSString *) - descriptionComponents [implementation]
(NSString *) - shortDescriptionComponents [implementation]
(void) - apply [implementation]
(void) - ensureFinishedLoading [implementation]
(BOOL) - isFinishedLoading [implementation]
(NSString *) - cacheKey [implementation]
(NSSize) - dimensions [implementation]
(NSSize) - originalDimensions [implementation]
(BOOL) - isMipMapped [implementation]
(struct OOPixMap) - copyPixMapRepresentation [implementation]
(BOOL) - isRectangleTexture [implementation]
(BOOL) - isCubeMap [implementation]
(NSSize) - texCoordsScale [implementation]
(GLint) - glTextureName [implementation]
(void) - setUpTexture [implementation]
(void) - uploadTexture [implementation]
(void) - uploadTextureDataWithMipMap:format: [implementation]
(GLenum) - glTextureTarget [implementation]
(BOOL) - isReloadable [implementation]
(void) - forceRebind [implementation]
Instance Methods inherited from OOTexture
(id) - init [implementation]
(void) - addToCaches [implementation]
(void) - removeFromCaches [implementation]
Instance Methods inherited from OOWeakRefObject
(id) - weakSelf
(id) - weakRetain [implementation]
(void) - weakRefDied: [implementation]
Instance Methods inherited from <OOWeakReferenceSupport>
(id) - OO_RETURNS_RETAINED

Private Attributes

NSString * _path
NSString * _key
uint8_t _loaded: 1
uint8_t _uploaded: 1
uint8_t _valid: 1
uint8_t _mipLevels
OOTextureLoader * _loader
void * _bytes
GLuint _textureName
uint32_t _width
uint32_t _height
uint32_t _originalWidth
uint32_t _originalHeight
OOTextureDataFormat _format
uint32_t _options

Additional Inherited Members

Class Methods inherited from OOTexture
(id) + textureWithName:inFolder:options:anisotropy:lodBias:
(id) + textureWithName:inFolder:
(id) + textureWithConfiguration:
(id) + textureWithConfiguration:extraOptions:
(id) + nullTexture
(id) + textureWithGenerator:
(id) + textureWithGenerator:enqueue:
(void) + applyNone
(void) + clearCache
(void) + rebindAllTextures
(OOTexture *) + existingTextureForKey: [implementation]
(void) + checkExtensions [implementation]
Protected Attributes inherited from OOWeakRefObject
OOWeakReference * weakSelf

Detailed Description

Definition at line 38 of file OOConcreteTexture.h.

Method Documentation

◆ apply

- (void) apply
implementation

Reimplemented from OOTexture.

Definition at line 225 of file OOConcreteTexture.m.

226{
228
229 if (EXPECT_NOT(!_loaded))
230 [self setUpTexture];
231 else if (EXPECT_NOT(!_uploaded))
232 [self uploadTexture];
233 else
234 OOGL(glBindTexture([self glTextureTarget], _textureName));
235
236#if GL_EXT_texture_lod_bias
238 OOGL(glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, _lodBias));
239#endif
240}
#define EXPECT_NOT(x)
#define OO_ENTER_OPENGL()
#define OOGL(statement)
Definition OOOpenGL.h:262
OOTextureInfo gOOTextureInfo
Definition OOTexture.m:97
unsigned textureLODBiasAvailable

References _loaded, _textureName, _uploaded, apply, EXPECT_NOT, glTextureTarget, gOOTextureInfo, OO_ENTER_OPENGL, OOGL, setUpTexture, and uploadTexture.

Referenced by apply.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cacheKey

- (NSString *) cacheKey
implementation

Reimplemented from OOTexture.

Definition at line 253 of file OOConcreteTexture.m.

254{
255 return _key;
256}

References _key, and cacheKey.

Referenced by cacheKey.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copyPixMapRepresentation

- (struct OOPixMap) copyPixMapRepresentation
implementation

Reimplemented from OOTexture.

Definition at line 279 of file OOConcreteTexture.m.

280{
281 [self ensureFinishedLoading];
282
284
285 if (_bytes != NULL) {
286 // If possible, just copy our existing buffer.
288 px = OODuplicatePixMap(px, 0);
289 }
290#if OOTEXTURE_RELOADABLE
291 else {
292 // Otherwise, read it back from OpenGL.
294
295 GLenum format, internalFormat, type;
296 if (!DecodeFormat(_format, _options, &format, &internalFormat, &type)) {
297 return kOONullPixMap;
298 }
299
300 if (![self isCubeMap]) {
301
303 if (!OOIsValidPixMap(px))
304 return kOONullPixMap;
305
306 glGetTexImage(GL_TEXTURE_2D, 0, format, type, px.pixels);
307 }
308#if OO_TEXTURE_CUBE_MAP
309 else {
310 px = OOAllocatePixMap(_width, _width * 6, _format, 0, 0);
311 if (!OOIsValidPixMap(px))
312 return kOONullPixMap;
313 uint8_t* pixels = px.pixels;
314
315 unsigned i;
316 for (i = 0; i < 6; i++) {
317 glGetTexImage(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, format, type, pixels);
319 }
320 }
321#endif
322 }
323#endif
324
325 return px;
326}
static BOOL DecodeFormat(OOTextureDataFormat format, uint32_t options, GLenum *outFormat, GLenum *outInternalFormat, GLenum *outType)
unsigned short OOPixMapBytesPerPixelForFormat(OOPixMapFormat format) PURE_FUNC
Definition OOPixMap.m:195
const OOPixMap kOONullPixMap
Definition OOPixMap.m:30
OOPixMap OOAllocatePixMap(OOPixMapDimension width, OOPixMapDimension height, OOPixMapFormat format, size_t rowBytes, size_t bufferSize)
Definition OOPixMap.m:66
OOPixMap OOMakePixMap(void *pixels, OOPixMapDimension width, OOPixMapDimension height, OOPixMapFormat format, size_t rowBytes, size_t bufferSize)
Definition OOPixMap.m:44
BOOL OOIsValidPixMap(OOPixMap pixMap)
Definition OOPixMap.m:39
OOPixMap OODuplicatePixMap(OOPixMap srcPixMap, size_t desiredSize)
Definition OOPixMap.m:89
struct OOPixMap OOPixMap
OOTextureDataFormat _format
void * pixels
Definition OOPixMap.h:44

References _bytes, _format, _height, _options, _width, copyPixMapRepresentation, DecodeFormat(), ensureFinishedLoading, isCubeMap, kOONullPixMap, OO_ENTER_OPENGL, OOAllocatePixMap(), OODuplicatePixMap(), OOIsValidPixMap(), OOMakePixMap(), OOPixMapBytesPerPixelForFormat(), and OOPixMap::pixels.

Referenced by copyPixMapRepresentation.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dealloc

- (void) dealloc
implementation

Reimplemented from OOTexture.

Definition at line 130 of file OOConcreteTexture.m.

131{
132#ifdef OO_DEBUG_MONITOR_ENABLED
133 OOLog(_trace ? @"texture.allocTrace.dealloc" : @"texture.dealloc", @"Deallocating and uncaching texture %p", self);
134#endif
135
136#if OOTEXTURE_RELOADABLE
137 DESTROY(_path);
138#endif
139
140 if (_loaded) {
141 if (_textureName != 0) {
143 OOGL(glDeleteTextures(1, &_textureName));
144 _textureName = 0;
145 }
146 free(_bytes);
147 _bytes = NULL;
148 }
149
150#ifndef OOTEXTURE_NO_CACHE
151 [self removeFromCaches];
152 [_key autorelease];
153 _key = nil;
154#endif
155
157
158#ifdef OO_DEBUG_MONITOR_ENABLED
159 DESTROY(_name);
160#endif
161
162 [super dealloc];
163}
#define DESTROY(x)
#define OOLog(class, format,...)
Definition OOLogging.h:84
return nil
OOTextureLoader * _loader

References _bytes, _key, _loaded, _loader, _path, _textureName, dealloc, OOTexture::dealloc, DESTROY, nil, OO_ENTER_OPENGL, OOGL, OOLog, and OOTexture::removeFromCaches.

Referenced by dealloc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ descriptionComponents

- (NSString *) descriptionComponents
implementation

Definition at line 165 of file OOConcreteTexture.m.

166{
167 NSString* stateDesc = nil;
168
169 if (_loaded) {
170 if (_valid) {
171 stateDesc = [NSString stringWithFormat:@"%u x %u", _width, _height];
172 } else {
173 stateDesc = @"LOAD ERROR";
174 }
175 } else {
176 stateDesc = @"loading";
177 }
178
179 return [NSString stringWithFormat:@"%@, %@", _key, stateDesc];
180}

References _loaded, _valid, descriptionComponents, and nil.

Referenced by descriptionComponents.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dimensions

- (NSSize) dimensions
implementation

Reimplemented from OOTexture.

Definition at line 258 of file OOConcreteTexture.m.

259{
260 [self ensureFinishedLoading];
261
262 return NSMakeSize(_width, _height);
263}

References _height, _width, dimensions, and ensureFinishedLoading.

Referenced by dimensions.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ensureFinishedLoading

- (void) ensureFinishedLoading
implementation

Reimplemented from OOTexture.

Definition at line 242 of file OOConcreteTexture.m.

243{
244 if (!_loaded)
245 [self setUpTexture];
246}

References _loaded, ensureFinishedLoading, and setUpTexture.

Referenced by copyPixMapRepresentation, dimensions, ensureFinishedLoading, glTextureName, isMipMapped, originalDimensions, and texCoordsScale.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ forceRebind

- (void) forceRebind
implementation

Reimplemented from OOTexture.

Provided by category OOConcreteTexture(Private).

Definition at line 573 of file OOConcreteTexture.m.

574{
575 if (_loaded && _uploaded && _valid) {
577
578 _uploaded = NO;
579 OOGL(glDeleteTextures(1, &_textureName));
580 _textureName = 0;
581
582#if OOTEXTURE_RELOADABLE
583 if ([self isReloadable]) {
584 OOLog(@"texture.reload", @"Reloading texture %@", self);
585
586 free(_bytes);
587 _bytes = NULL;
588 _loaded = NO;
589 _uploaded = NO;
590 _valid = NO;
591
592 _loader = [[OOTextureLoader loaderWithPath:_path options:_options] retain];
593 }
594#endif
595 }
596}
id loaderWithPath:options:(NSString *path,[options] uint32_t options)

◆ glTextureName

- (GLint) glTextureName
implementation

Reimplemented from OOTexture.

Definition at line 370 of file OOConcreteTexture.m.

371{
372 [self ensureFinishedLoading];
373
374 return _textureName;
375}

References _textureName, ensureFinishedLoading, and glTextureName.

Referenced by glTextureName.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ glTextureTarget

- (GLenum) glTextureTarget
implementation

Provided by category OOConcreteTexture(Private).

Definition at line 562 of file OOConcreteTexture.m.

563{
564 GLenum texTarget = GL_TEXTURE_2D;
565#if OO_TEXTURE_CUBE_MAP
566 if (_isCubeMap) {
567 texTarget = GL_TEXTURE_CUBE_MAP;
568 }
569#endif
570 return texTarget;
571}

Referenced by apply, and OOConcreteTexture(Private)::uploadTexture.

Here is the caller graph for this function:

◆ initWithLoader:key:options:anisotropy:lodBias:

- (id) initWithLoader: (OOTextureLoader*) loader
key: (NSString*) key
options: (uint32_t) options
anisotropy: (GLfloat) anisotropy
lodBias: (GLfloat) lodBias 

Definition at line 71 of file OOConcreteTexture.m.

71 :(OOTextureLoader*)loader
72 key:(NSString*)key
73 options:(uint32_t)options
74 anisotropy:(GLfloat)anisotropy
75 lodBias:(GLfloat)lodBias
76{
77 if (loader == nil) {
78 [self release];
79 return nil;
80 }
81
82 self = [super init];
83 if (EXPECT_NOT(self == nil))
84 return nil;
85
86 _loader = [loader retain];
87 _options = options;
88
89#if GL_EXT_texture_filter_anisotropic
90 _anisotropy = OOClamp_0_1_f(anisotropy) * gOOTextureInfo.anisotropyScale;
91#endif
92#if GL_EXT_texture_lod_bias
93 _lodBias = lodBias;
94#endif
95
96#ifdef OO_DEBUG_MONITOR_ENABLED
97 if ([loader isKindOfClass:[OOTextureGenerator class]]) {
98 _name = [[NSString alloc] initWithFormat:@"<%@>", [loader class]];
99 }
100#endif
101
102 _key = [key copy];
103
104 [self addToCaches];
105
106 return self;
107}
OOINLINE float OOClamp_0_1_f(float value) INLINE_CONST_FUNC

References _key, _loader, _options, OOTexture::addToCaches, EXPECT_NOT, gOOTextureInfo, OOTexture::init, nil, and OOClamp_0_1_f().

Here is the call graph for this function:

◆ initWithPath:key:options:anisotropy:lodBias:

- (id) initWithPath: (NSString*) path
key: (NSString*) key
options: (uint32_t) options
anisotropy: (float) anisotropy
lodBias: (GLfloat) lodBias 

Definition at line 109 of file OOConcreteTexture.m.

109 :(NSString*)path
110 key:(NSString*)key
111 options:(uint32_t)options
112 anisotropy:(float)anisotropy
113 lodBias:(GLfloat)lodBias
114{
115 OOTextureLoader* loader = [OOTextureLoader loaderWithPath:path options:options];
116 if (loader == nil) {
117 [self release];
118 return nil;
119 }
120
121 if ((self = [self initWithLoader:loader key:key options:options anisotropy:anisotropy lodBias:lodBias])) {
122#if OOTEXTURE_RELOADABLE
123 _path = [path retain];
124#endif
125 }
126
127 return self;
128}

References _path, OOTextureLoader::loaderWithPath:options:, and nil.

Here is the call graph for this function:

◆ isCubeMap

- (BOOL) isCubeMap
implementation

Reimplemented from OOTexture.

Definition at line 337 of file OOConcreteTexture.m.

338{
339#if OO_TEXTURE_CUBE_MAP
340 return _isCubeMap;
341#else
342 return NO;
343#endif
344}

References isCubeMap.

Referenced by copyPixMapRepresentation, and isCubeMap.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isFinishedLoading

- (BOOL) isFinishedLoading
implementation

Reimplemented from OOTexture.

Definition at line 248 of file OOConcreteTexture.m.

249{
250 return _loaded || [_loader isReady];
251}

References _loaded, isFinishedLoading, and OOTextureLoader::isReady.

Referenced by isFinishedLoading.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isMipMapped

- (BOOL) isMipMapped
implementation

Reimplemented from OOTexture.

Definition at line 272 of file OOConcreteTexture.m.

273{
274 [self ensureFinishedLoading];
275
276 return _mipLevels != 0;
277}

References _mipLevels, ensureFinishedLoading, and isMipMapped.

Referenced by isMipMapped.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isRectangleTexture

- (BOOL) isRectangleTexture
implementation

Reimplemented from OOTexture.

Definition at line 328 of file OOConcreteTexture.m.

329{
330#if GL_EXT_texture_rectangle
331 return _isRectTexture;
332#else
333 return NO;
334#endif
335}

References isRectangleTexture.

Referenced by isRectangleTexture.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isReloadable

- (BOOL) isReloadable
implementation

Provided by category OOConcreteTexture(Private).

Definition at line 600 of file OOConcreteTexture.m.

601{
602 return _path != nil;
603}

◆ originalDimensions

- (NSSize) originalDimensions
implementation

Reimplemented from OOTexture.

Definition at line 265 of file OOConcreteTexture.m.

266{
267 [self ensureFinishedLoading];
268
269 return NSMakeSize(_originalWidth, _originalHeight);
270}

References _originalHeight, _originalWidth, ensureFinishedLoading, and originalDimensions.

Referenced by originalDimensions.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setUpTexture

- (void) setUpTexture
implementation

Provided by category OOConcreteTexture(Private).

Definition at line 381 of file OOConcreteTexture.m.

382{
383 OOPixMap pm;
384
385 // This will block until loading is completed, if necessary.
386 if ([_loader getResult:&pm format:&_format originalWidth:&_originalWidth originalHeight:&_originalHeight]) {
387 _bytes = pm.pixels;
388 _width = pm.width;
389 _height = pm.height;
390
391#if OO_TEXTURE_CUBE_MAP
393 _isCubeMap = YES;
394 }
395#endif
396
397#if defined(OO_DEBUG_MONITOR_ENABLED) && OOTEXTURE_RELOADABLE
398 if (_trace) {
399 static unsigned dumpID = 0;
400 NSString* name = [NSString stringWithFormat:@"tex dump %u \"%@\"", ++dumpID, [self name]];
401 OOLog(@"texture.trace.dump", @"Dumped traced texture %@ to \'%@.png\'", self, name);
402 OODumpPixMap(pm, name);
403 }
404#endif
405
406 [self uploadTexture];
407 } else {
408 _textureName = 0;
409 _valid = NO;
410 _uploaded = YES;
411 }
412
413 _loaded = YES;
414
416}
void OODumpPixMap(OOPixMap pixMap, NSString *name)
Definition OOPixMap.m:140
@ kOOTextureAllowCubeMap
Definition OOTexture.h:61
OOPixMapDimension height
Definition OOPixMap.h:45
OOPixMapDimension width
Definition OOPixMap.h:45
unsigned cubeMapAvailable

Referenced by apply, and ensureFinishedLoading.

Here is the caller graph for this function:

◆ shortDescriptionComponents

- (NSString *) shortDescriptionComponents
implementation

Definition at line 182 of file OOConcreteTexture.m.

183{
184 return _key;
185}

References _key, and shortDescriptionComponents.

Referenced by shortDescriptionComponents.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ texCoordsScale

- (NSSize) texCoordsScale
implementation

Reimplemented from OOTexture.

Definition at line 346 of file OOConcreteTexture.m.

347{
348#if GL_EXT_texture_rectangle
349 if (_loaded) {
350 if (!_isRectTexture) {
351 return NSMakeSize(1.0f, 1.0f);
352 } else {
353 return NSMakeSize(_width, _height);
354 }
355 } else {
356 // Not loaded
358 return NSMakeSize(1.0f, 1.0f);
359 } else {
360 // Finishing may clear the rectangle texture flag (if the texture turns out to be POT)
361 [self ensureFinishedLoading];
362 return [self texCoordsScale];
363 }
364 }
365#else
366 return NSMakeSize(1.0f, 1.0f);
367#endif
368}
@ kOOTextureAllowRectTexture
Definition OOTexture.h:57

References _height, _loaded, _options, _width, ensureFinishedLoading, kOOTextureAllowRectTexture, and texCoordsScale.

Referenced by texCoordsScale.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uploadTexture

- (void) uploadTexture
implementation

Provided by category OOConcreteTexture(Private).

Definition at line 418 of file OOConcreteTexture.m.

419{
420 GLint filter;
421 BOOL mipMap = NO;
422
424
425 if (!_uploaded) {
426 GLenum texTarget = [self glTextureTarget];
427
428 OOGL(glGenTextures(1, &_textureName));
429 OOGL(glBindTexture(texTarget, _textureName));
430
431 // Select wrap mode
432 GLint clampMode = gOOTextureInfo.clampToEdgeAvailable ? GL_CLAMP_TO_EDGE : GL_CLAMP;
433 GLint wrapS = (_options & kOOTextureRepeatS) ? GL_REPEAT : clampMode;
434 GLint wrapT = (_options & kOOTextureRepeatT) ? GL_REPEAT : clampMode;
435
436#if OO_TEXTURE_CUBE_MAP
437 if (texTarget == GL_TEXTURE_CUBE_MAP) {
438 wrapS = wrapT = clampMode;
439 OOGL(glTexParameteri(texTarget, GL_TEXTURE_WRAP_R, clampMode));
440 }
441#endif
442
443 OOGL(glTexParameteri(texTarget, GL_TEXTURE_WRAP_S, wrapS));
444 OOGL(glTexParameteri(texTarget, GL_TEXTURE_WRAP_T, wrapT));
445
446 // Select min filter
448 if (filter == kOOTextureMinFilterNearest)
449 filter = GL_NEAREST;
450 else if (filter == kOOTextureMinFilterMipMap) {
451 mipMap = YES;
452 filter = GL_LINEAR_MIPMAP_LINEAR;
453 } else
454 filter = GL_LINEAR;
455 OOGL(glTexParameteri(texTarget, GL_TEXTURE_MIN_FILTER, filter));
456
457#if GL_EXT_texture_filter_anisotropic
458 if (gOOTextureInfo.anisotropyAvailable && mipMap && 1.0 < _anisotropy) {
459 OOGL(glTexParameterf(texTarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, _anisotropy));
460 }
461#endif
462
463 // Select mag filter
465 if (filter == kOOTextureMagFilterNearest)
466 filter = GL_NEAREST;
467 else
468 filter = GL_LINEAR;
469 OOGL(glTexParameteri(texTarget, GL_TEXTURE_MAG_FILTER, filter));
470
471 // if (gOOTextureInfo.clientStorageAvailable) EnableClientStorage();
472
473 if (texTarget == GL_TEXTURE_2D) {
474 [self uploadTextureDataWithMipMap:mipMap format:_format];
475 OOLog(@"texture.upload", @"Uploaded texture %u (%ux%u pixels, %@)", _textureName, _width, _height, _key);
476 }
477#if OO_TEXTURE_CUBE_MAP
478 else if (texTarget == GL_TEXTURE_CUBE_MAP) {
479 [self uploadTextureCubeMapDataWithMipMap:mipMap format:_format];
480 OOLog(@"texture.upload", @"Uploaded cube map texture %u (%ux%ux6 pixels, %@)", _textureName, _width, _width, _key);
481 }
482#endif
483 else {
484 [NSException raise:NSInternalInconsistencyException format:@"Unhandled texture target 0x%X.", texTarget];
485 }
486
487 _valid = YES;
488 _uploaded = YES;
489
490#if OOTEXTURE_RELOADABLE
491 if ([self isReloadable]) {
492 free(_bytes);
493 _bytes = NULL;
494 }
495#endif
496 }
497}
#define GL_CLAMP_TO_EDGE
@ kOOTextureRepeatS
Definition OOTexture.h:55
@ kOOTextureMagFilterMask
Definition OOTexture.h:73
@ kOOTextureMinFilterMask
Definition OOTexture.h:72
@ kOOTextureRepeatT
Definition OOTexture.h:56
@ kOOTextureMinFilterMipMap
Definition OOTexture.h:48
@ kOOTextureMagFilterNearest
Definition OOTexture.h:50
@ kOOTextureMinFilterNearest
Definition OOTexture.h:46
unsigned anisotropyAvailable
unsigned clampToEdgeAvailable

Referenced by apply, and OOConcreteTexture(Private)::setUpTexture.

Here is the caller graph for this function:

◆ uploadTextureDataWithMipMap:format:

- (void) uploadTextureDataWithMipMap: (BOOL) mipMap
format: (OOTextureDataFormat) format 
implementation

Provided by category OOConcreteTexture(Private).

Definition at line 499 of file OOConcreteTexture.m.

499 :(BOOL)mipMap format:(OOTextureDataFormat)format
500{
501 GLenum glFormat = 0, internalFormat = 0, type = 0;
502 unsigned w = _width,
503 h = _height,
504 level = 0;
505 char* bytes = _bytes;
506 uint8_t components = OOTextureComponentsForFormat(format);
507
509
510 if (!DecodeFormat(format, _options, &glFormat, &internalFormat, &type))
511 return;
512
513 while (0 < w && 0 < h) {
514 OOGL(glTexImage2D(GL_TEXTURE_2D, level++, internalFormat, w, h, 0, glFormat, type, bytes));
515 if (!mipMap)
516 return;
517 bytes += w * components * h;
518 w >>= 1;
519 h >>= 1;
520 }
521
522 // Note: we only reach here if (mipMap).
523 _mipLevels = level - 1;
524 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, _mipLevels));
525}
#define GL_TEXTURE_MAX_LEVEL
uint8_t OOTextureComponentsForFormat(OOTextureDataFormat format)
Definition OOTexture.m:624
OOPixMapFormat OOTextureDataFormat
Definition OOTexture.h:107

Referenced by OOConcreteTexture(Private)::uploadTexture.

Here is the caller graph for this function:

Member Data Documentation

◆ _bytes

- (void*) _bytes
private

Definition at line 57 of file OOConcreteTexture.h.

Referenced by copyPixMapRepresentation, and dealloc.

◆ _format

- (OOTextureDataFormat) _format
private

Definition at line 64 of file OOConcreteTexture.h.

Referenced by copyPixMapRepresentation.

◆ _height

- (uint32_t) _height
private

Definition at line 60 of file OOConcreteTexture.h.

Referenced by copyPixMapRepresentation, dimensions, and texCoordsScale.

◆ _key

- (NSString*) _key
private

◆ _loaded

- (uint8_t) _loaded
private

◆ _loader

- (OOTextureLoader*) _loader
private

Definition at line 55 of file OOConcreteTexture.h.

Referenced by dealloc, and initWithLoader:key:options:anisotropy:lodBias:.

◆ _mipLevels

- (uint8_t) _mipLevels
private

Definition at line 53 of file OOConcreteTexture.h.

Referenced by isMipMapped.

◆ _options

- (uint32_t) _options
private

◆ _originalHeight

- (uint32_t) _originalHeight
private

Definition at line 62 of file OOConcreteTexture.h.

Referenced by originalDimensions.

◆ _originalWidth

- (uint32_t) _originalWidth
private

Definition at line 61 of file OOConcreteTexture.h.

Referenced by originalDimensions.

◆ _path

- (NSString*) _path
private

Definition at line 41 of file OOConcreteTexture.h.

Referenced by dealloc, and initWithPath:key:options:anisotropy:lodBias:.

◆ _textureName

- (GLuint) _textureName
private

Definition at line 58 of file OOConcreteTexture.h.

Referenced by apply, dealloc, and glTextureName.

◆ _uploaded

- (uint8_t) _uploaded
private

Definition at line 45 of file OOConcreteTexture.h.

Referenced by apply.

◆ _valid

- (uint8_t) _valid
private

Definition at line 52 of file OOConcreteTexture.h.

Referenced by descriptionComponents.

◆ _width

- (uint32_t) _width
private

Definition at line 59 of file OOConcreteTexture.h.

Referenced by copyPixMapRepresentation, dimensions, and texCoordsScale.


The documentation for this class was generated from the following files: