Here's a thought: instead of asking libpng for data in the wrong order and then swapping it, how about asking for data in the right order? It's a crazy idea, but it might just work.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@2530 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
657d4556a8
commit
dafcec17b1
@ -661,7 +661,6 @@
|
||||
25F46752099695D5009483BF /* OoliteApp.h in Headers */ = {isa = PBXBuildFile; fileRef = 25F46750099695D5009483BF /* OoliteApp.h */; };
|
||||
25F46753099695D5009483BF /* OoliteApp.m in Sources */ = {isa = PBXBuildFile; fileRef = 25F46751099695D5009483BF /* OoliteApp.m */; };
|
||||
25F4676509969672009483BF /* MyOpenGLView.m in Sources */ = {isa = PBXBuildFile; fileRef = 25F4676309969672009483BF /* MyOpenGLView.m */; };
|
||||
2B13C51F105D342D00AF4A7B /* oolite-nova-system.png in Copy Debug OXP */ = {isa = PBXBuildFile; fileRef = 2B13C51E105D342D00AF4A7B /* oolite-nova-system.png */; };
|
||||
2B13C520105D342D00AF4A7B /* oolite-nova-system.png in Resources */ = {isa = PBXBuildFile; fileRef = 2B13C51E105D342D00AF4A7B /* oolite-nova-system.png */; };
|
||||
2B13C521105D343900AF4A7B /* oolite-nova-system.png in Copy Images */ = {isa = PBXBuildFile; fileRef = 2B13C51E105D342D00AF4A7B /* oolite-nova-system.png */; };
|
||||
2B9A1089105D526200EE2AE6 /* javascript-errors.plist in Resources */ = {isa = PBXBuildFile; fileRef = 2B9A1088105D526200EE2AE6 /* javascript-errors.plist */; };
|
||||
@ -1070,7 +1069,6 @@
|
||||
dstSubfolderSpec = 16;
|
||||
files = (
|
||||
1AD267650C83058C00B4BFD1 /* Debug.oxp in Copy Debug OXP */,
|
||||
2B13C51F105D342D00AF4A7B /* oolite-nova-system.png in Copy Debug OXP */,
|
||||
);
|
||||
name = "Copy Debug OXP";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
@ -49,6 +49,7 @@ SOFTWARE.
|
||||
#import "OOPNGTextureLoader.h"
|
||||
#import "OOFunctionAttributes.h"
|
||||
#import "OOLogging.h"
|
||||
#import "OOCPUInfo.h"
|
||||
|
||||
|
||||
void png_error(png_structp, png_const_charp) NO_RETURN_FUNC;
|
||||
@ -159,17 +160,20 @@ static void PNGRead(png_structp png, png_bytep bytes, png_size_t size);
|
||||
{
|
||||
// TODO: what about PNG_COLOR_TYPE_GRAY_ALPHA ?
|
||||
format = kOOTextureDataGrayscale;
|
||||
|
||||
// png_set_invert_mono(png);
|
||||
}
|
||||
else
|
||||
{
|
||||
format = kOOTextureDataRGBA;
|
||||
|
||||
#if OOLITE_BIG_ENDIAN
|
||||
png_set_bgr(png);
|
||||
png_set_swap_alpha(png); // RGBA->ARGB
|
||||
|
||||
png_set_filler(png, 0xFF, PNG_FILLER_BEFORE);
|
||||
#elif OOLITE_LITTLE_ENDIAN
|
||||
png_set_filler(png, 0xFF, PNG_FILLER_AFTER);
|
||||
#else
|
||||
#error Don't know how to handle byte order.
|
||||
#endif
|
||||
}
|
||||
|
||||
png_read_update_info(png, pngInfo);
|
||||
|
@ -54,13 +54,6 @@ SOFTWARE.
|
||||
#import "OOTextureScaling.h"
|
||||
#import <stdlib.h>
|
||||
#import "OOTextureLoadDispatcher.h"
|
||||
#import "OOCPUInfo.h"
|
||||
|
||||
#if OOLITE_WINDOWS
|
||||
#import <winsock2.h>
|
||||
#else
|
||||
#import <arpa/inet.h> // For htonl
|
||||
#endif
|
||||
|
||||
|
||||
static unsigned sGLMaxSize;
|
||||
@ -82,10 +75,6 @@ static BOOL sHaveSetUp = NO;
|
||||
- (void)applySettings;
|
||||
- (void)getDesiredWidth:(uint32_t *)outDesiredWidth andHeight:(uint32_t *)outDesiredHeight;
|
||||
|
||||
#if OOLITE_LITTLE_ENDIAN
|
||||
- (void) swizzle4;
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@ -308,14 +297,6 @@ 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)
|
||||
{
|
||||
@ -388,22 +369,4 @@ 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