Modified texture loading for a) OpenGL 1.1 compatibility on little-endian systems and b) one less memory copy under OS X.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@2507 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
26669c1961
commit
3f3a843d2b
@ -88,7 +88,7 @@ static BOOL sCheckedExtensions = NO;
|
||||
#if OOLITE_BIG_ENDIAN
|
||||
#define RGBA_IMAGE_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
|
||||
#elif OOLITE_LITTLE_ENDIAN
|
||||
#define RGBA_IMAGE_TYPE GL_UNSIGNED_INT_8_8_8_8
|
||||
#define RGBA_IMAGE_TYPE GL_UNSIGNED_BYTE //GL_UNSIGNED_INT_8_8_8_8_REV
|
||||
#else
|
||||
#error Neither OOLITE_BIG_ENDIAN nor OOLITE_LITTLE_ENDIAN is defined as nonzero!
|
||||
#endif
|
||||
@ -113,7 +113,7 @@ static float sAnisotropyScale; // Scale of anisotropy values
|
||||
#ifdef GL_CLAMP_TO_EDGE
|
||||
static BOOL sClampToEdgeAvailable;
|
||||
#else
|
||||
#warning GL_CLAMP_TO_EDGE (OpenGL 1.2) and GL_SGIS_texture_edge_clamp are unavialble -- are you using an up-to-date gl.h?
|
||||
#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?
|
||||
#define sClampToEdgeAvailable (NO)
|
||||
#define GL_CLAMP_TO_EDGE GL_CLAMP
|
||||
#endif
|
||||
|
@ -54,6 +54,7 @@ SOFTWARE.
|
||||
#import "OOTextureScaling.h"
|
||||
#import <stdlib.h>
|
||||
#import "OOTextureLoadDispatcher.h"
|
||||
#import "OOCPUInfo.h"
|
||||
|
||||
|
||||
static unsigned sGLMaxSize;
|
||||
@ -75,6 +76,10 @@ static BOOL sHaveSetUp = NO;
|
||||
- (void)applySettings;
|
||||
- (void)getDesiredWidth:(uint32_t *)outDesiredWidth andHeight:(uint32_t *)outDesiredHeight;
|
||||
|
||||
#if OOLITE_LITTLE_ENDIAN
|
||||
- (void) swizzle4;
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@ -297,6 +302,14 @@ static BOOL sHaveSetUp = NO;
|
||||
height = desiredHeight;
|
||||
}
|
||||
|
||||
// Byte-swap RGBA data on little-endian systems. (All graphics cards prefer sane-endian data.)
|
||||
#if OOLITE_LITTLE_ENDIAN
|
||||
if (format == kOOTextureDataRGBA)
|
||||
{
|
||||
[self swizzle4];
|
||||
}
|
||||
#endif
|
||||
|
||||
// Generate mip maps if needed.
|
||||
if (generateMipMaps && !rescale)
|
||||
{
|
||||
@ -369,4 +382,22 @@ static BOOL sHaveSetUp = NO;
|
||||
if (outDesiredHeight != NULL) *outDesiredHeight = desiredHeight;
|
||||
}
|
||||
|
||||
|
||||
#if OOLITE_LITTLE_ENDIAN
|
||||
- (void) swizzle4
|
||||
{
|
||||
NSParameterAssert(data != NULL);
|
||||
|
||||
uint32_t *pixels = data;
|
||||
uint32_t count = height * rowBytes / sizeof (uint32_t);
|
||||
|
||||
// FIXME: this could do with vectorization.
|
||||
while (count--)
|
||||
{
|
||||
*pixels = htonl(*pixels);
|
||||
pixels++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
Loading…
x
Reference in New Issue
Block a user