[Fuse-for-macosx-commits] SF.net SVN: fuse-for-macosx: [431] trunk/fuse/fusepb
Brought to you by:
fredm
From: <fr...@us...> - 2007-07-16 12:29:17
|
Revision: 431 http://svn.sourceforge.net/fuse-for-macosx/?rev=431&view=rev Author: fredm Date: 2007-07-16 05:29:05 -0700 (Mon, 16 Jul 2007) Log Message: ----------- Switch to using ImageIO for texture loading. Modified Paths: -------------- trunk/fuse/fusepb/Fuse.xcodeproj/project.pbxproj trunk/fuse/fusepb/views/DisplayOpenGLView.m trunk/fuse/fusepb/views/Texture.h trunk/fuse/fusepb/views/Texture.m Added Paths: ----------- trunk/fuse/fusepb/resources/cassette_green.png trunk/fuse/fusepb/resources/cassette_red.png trunk/fuse/fusepb/resources/microdrive_green.png trunk/fuse/fusepb/resources/microdrive_red.png trunk/fuse/fusepb/resources/plus3disk_green.png trunk/fuse/fusepb/resources/plus3disk_red.png Modified: trunk/fuse/fusepb/Fuse.xcodeproj/project.pbxproj =================================================================== --- trunk/fuse/fusepb/Fuse.xcodeproj/project.pbxproj 2007-07-13 13:49:45 UTC (rev 430) +++ trunk/fuse/fusepb/Fuse.xcodeproj/project.pbxproj 2007-07-16 12:29:05 UTC (rev 431) @@ -149,9 +149,6 @@ B61F463109121DF100C8096C /* tzx.icns in Resources */ = {isa = PBXBuildFile; fileRef = B643BB980403A13600A864FD /* tzx.icns */; }; B61F463209121DF100C8096C /* z80.icns in Resources */ = {isa = PBXBuildFile; fileRef = B6676DB0040C348F00B2BFEF /* z80.icns */; }; B61F463309121DF100C8096C /* blank.icns in Resources */ = {isa = PBXBuildFile; fileRef = B6AF242A04156EE700F48F48 /* blank.icns */; }; - B61F463409121DF100C8096C /* cassette.bmp in Resources */ = {isa = PBXBuildFile; fileRef = B6FD5BE505A4EDBF00A6C4FC /* cassette.bmp */; }; - B61F463509121DF100C8096C /* microdrive.bmp in Resources */ = {isa = PBXBuildFile; fileRef = B63B80B7076DB4BC00002519 /* microdrive.bmp */; }; - B61F463609121DF100C8096C /* plus3disk.bmp in Resources */ = {isa = PBXBuildFile; fileRef = B6FD5BEA05A4EDD700A6C4FC /* plus3disk.bmp */; }; B61F463709121DF100C8096C /* SavePanelAccessoryView.nib in Resources */ = {isa = PBXBuildFile; fileRef = B619FC2E090D9BC200344F94 /* SavePanelAccessoryView.nib */; }; B61F463909121DF100C8096C /* z80_ops.c in Sources */ = {isa = PBXBuildFile; fileRef = F55985B20389224001A804BA /* z80_ops.c */; }; B61F463A09121DF100C8096C /* z80.c in Sources */ = {isa = PBXBuildFile; fileRef = F55985B30389224001A804BA /* z80.c */; }; @@ -294,6 +291,12 @@ B6CA2A310C33F8C10003CF90 /* wd1770.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CA2A2D0C33F8C10003CF90 /* wd1770.h */; }; B6CADD570C47AD90004BA954 /* Texture.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CADD550C47AD90004BA954 /* Texture.h */; }; B6CADD580C47AD90004BA954 /* Texture.m in Sources */ = {isa = PBXBuildFile; fileRef = B6CADD560C47AD90004BA954 /* Texture.m */; }; + B6CADD690C48E188004BA954 /* cassette_green.png in Resources */ = {isa = PBXBuildFile; fileRef = B6CADD670C48E188004BA954 /* cassette_green.png */; }; + B6CADD6A0C48E188004BA954 /* cassette_red.png in Resources */ = {isa = PBXBuildFile; fileRef = B6CADD680C48E188004BA954 /* cassette_red.png */; }; + B6CADD720C48E1A3004BA954 /* microdrive_green.png in Resources */ = {isa = PBXBuildFile; fileRef = B6CADD6E0C48E1A3004BA954 /* microdrive_green.png */; }; + B6CADD730C48E1A3004BA954 /* microdrive_red.png in Resources */ = {isa = PBXBuildFile; fileRef = B6CADD6F0C48E1A3004BA954 /* microdrive_red.png */; }; + B6CADD740C48E1A3004BA954 /* plus3disk_green.png in Resources */ = {isa = PBXBuildFile; fileRef = B6CADD700C48E1A3004BA954 /* plus3disk_green.png */; }; + B6CADD750C48E1A3004BA954 /* plus3disk_red.png in Resources */ = {isa = PBXBuildFile; fileRef = B6CADD710C48E1A3004BA954 /* plus3disk_red.png */; }; B6CE7F410B2830A300EB65B3 /* cocoadisplay.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CE7F3B0B2830A300EB65B3 /* cocoadisplay.h */; }; B6CE7F420B2830A300EB65B3 /* cocoajoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = B6CE7F3C0B2830A300EB65B3 /* cocoajoystick.c */; }; B6CE7F440B2830A300EB65B3 /* cocoaui.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CE7F3E0B2830A300EB65B3 /* cocoaui.h */; }; @@ -402,7 +405,6 @@ B639B7670A6BAFCF00927E24 /* csw.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = csw.icns; sourceTree = "<group>"; }; B639B7D00A6BB45600927E24 /* raw.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = raw.icns; sourceTree = "<group>"; }; B63ABD8D042F175200A864FD /* scaler.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = scaler.c; path = ../ui/scaler/scaler.c; sourceTree = SOURCE_ROOT; }; - B63B80B7076DB4BC00002519 /* microdrive.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; name = microdrive.bmp; path = ../lib/microdrive.bmp; sourceTree = SOURCE_ROOT; }; B63F9949077182B4004D6DFA /* RollbackController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = RollbackController.h; path = controllers/RollbackController.h; sourceTree = SOURCE_ROOT; }; B63F994A077182B4004D6DFA /* RollbackController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = RollbackController.m; path = controllers/RollbackController.m; sourceTree = SOURCE_ROOT; }; B6403FD60A7E4B1A00E00B11 /* loader.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = loader.c; sourceTree = "<group>"; }; @@ -544,6 +546,12 @@ B6CA304D049CEC410037E9F2 /* psg.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = psg.h; path = ../psg.h; sourceTree = SOURCE_ROOT; }; B6CADD550C47AD90004BA954 /* Texture.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Texture.h; sourceTree = "<group>"; }; B6CADD560C47AD90004BA954 /* Texture.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = Texture.m; sourceTree = "<group>"; }; + B6CADD670C48E188004BA954 /* cassette_green.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = cassette_green.png; sourceTree = "<group>"; }; + B6CADD680C48E188004BA954 /* cassette_red.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = cassette_red.png; sourceTree = "<group>"; }; + B6CADD6E0C48E1A3004BA954 /* microdrive_green.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = microdrive_green.png; sourceTree = "<group>"; }; + B6CADD6F0C48E1A3004BA954 /* microdrive_red.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = microdrive_red.png; sourceTree = "<group>"; }; + B6CADD700C48E1A3004BA954 /* plus3disk_green.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = plus3disk_green.png; sourceTree = "<group>"; }; + B6CADD710C48E1A3004BA954 /* plus3disk_red.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = plus3disk_red.png; sourceTree = "<group>"; }; B6CC82FF0800E408006EFFB9 /* CAMachines.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CAMachines.h; path = content_arrays/CAMachines.h; sourceTree = SOURCE_ROOT; }; B6CC83000800E408006EFFB9 /* CAMachines.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = CAMachines.m; path = content_arrays/CAMachines.m; sourceTree = SOURCE_ROOT; }; B6CD0B9E06069F4A00847338 /* fuse.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = fuse.cpp; path = ../fuse.cpp; sourceTree = SOURCE_ROOT; }; @@ -588,8 +596,6 @@ B6F74F9D04B85B660059D51C /* SaveBinaryController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = SaveBinaryController.m; path = controllers/SaveBinaryController.m; sourceTree = "<group>"; }; B6F905ED05CDA24300C2F10D /* Fuse Help */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "Fuse Help"; path = "resources/Fuse Help"; sourceTree = SOURCE_ROOT; }; B6FA759C0C1D7507007F5A10 /* audiofile.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = audiofile.framework; path = ../../audiofile/build/Deployment/audiofile.framework; sourceTree = "<group>"; }; - B6FD5BE505A4EDBF00A6C4FC /* cassette.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; name = cassette.bmp; path = ../lib/cassette.bmp; sourceTree = SOURCE_ROOT; }; - B6FD5BEA05A4EDD700A6C4FC /* plus3disk.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; name = plus3disk.bmp; path = ../lib/plus3disk.bmp; sourceTree = SOURCE_ROOT; }; B6FD5C7A05A4F5B600A6C4FC /* utils.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = utils.h; path = ../utils.h; sourceTree = SOURCE_ROOT; }; B6FEA44B0444C2CC0013916D /* tc2068-0.rom */ = {isa = PBXFileReference; lastKnownFileType = file; name = "tc2068-0.rom"; path = "../roms/tc2068-0.rom"; sourceTree = SOURCE_ROOT; }; B6FEA44C0444C2CC0013916D /* tc2068-1.rom */ = {isa = PBXFileReference; lastKnownFileType = file; name = "tc2068-1.rom"; path = "../roms/tc2068-1.rom"; sourceTree = SOURCE_ROOT; }; @@ -850,16 +856,19 @@ B643BB8C0403A0D300A864FD /* resources */ = { isa = PBXGroup; children = ( - F5F4333103903ED801E7A043 /* Fuse.icns */, B6AF242A04156EE700F48F48 /* blank.icns */, - B6FD5BE505A4EDBF00A6C4FC /* cassette.bmp */, + B6CADD670C48E188004BA954 /* cassette_green.png */, + B6CADD680C48E188004BA954 /* cassette_red.png */, B639B7670A6BAFCF00927E24 /* csw.icns */, B6F0480E0952B597006D8005 /* dck.icns */, B643BB8D0403A0FD00A864FD /* dsk.icns */, + F5F4333103903ED801E7A043 /* Fuse.icns */, B650986A09366C8F003AF1BF /* hdf.icns */, B6F048100952B5AD006D8005 /* mdr.icns */, - B63B80B7076DB4BC00002519 /* microdrive.bmp */, - B6FD5BEA05A4EDD700A6C4FC /* plus3disk.bmp */, + B6CADD6E0C48E1A3004BA954 /* microdrive_green.png */, + B6CADD6F0C48E1A3004BA954 /* microdrive_red.png */, + B6CADD700C48E1A3004BA954 /* plus3disk_green.png */, + B6CADD710C48E1A3004BA954 /* plus3disk_red.png */, B639B7D00A6BB45600927E24 /* raw.icns */, B650986B09366C8F003AF1BF /* rom.icns */, B650986C09366C8F003AF1BF /* rzx.icns */, @@ -1419,6 +1428,7 @@ B61F461E09121DF100C8096C /* plus3e-1.rom in Resources */, B61F461F09121DF100C8096C /* plus3e-2.rom in Resources */, B61F462009121DF100C8096C /* plus3e-3.rom in Resources */, + B6CA2A260C33F8800003CF90 /* plusd.rom in Resources */, B61F462109121DF100C8096C /* se-0.rom in Resources */, B61F462209121DF100C8096C /* se-1.rom in Resources */, B61F462309121DF100C8096C /* tc2048.rom in Resources */, @@ -1429,14 +1439,11 @@ B61F462A09121DF100C8096C /* ts2068.png in Resources */, B61F462B09121DF100C8096C /* Fuse.icns in Resources */, B61F463309121DF100C8096C /* blank.icns in Resources */, - B61F463409121DF100C8096C /* cassette.bmp in Resources */, B639B7680A6BAFCF00927E24 /* csw.icns in Resources */, B6F0480F0952B597006D8005 /* dck.icns in Resources */, B61F462C09121DF100C8096C /* dsk.icns in Resources */, B650986D09366C8F003AF1BF /* hdf.icns in Resources */, B6F048110952B5AE006D8005 /* mdr.icns in Resources */, - B61F463509121DF100C8096C /* microdrive.bmp in Resources */, - B61F463609121DF100C8096C /* plus3disk.bmp in Resources */, B650986E09366C8F003AF1BF /* rom.icns in Resources */, B650986F09366C8F003AF1BF /* rzx.icns in Resources */, B6F048130952B5C1006D8005 /* scl.icns in Resources */, @@ -1452,7 +1459,12 @@ B61F463209121DF100C8096C /* z80.icns in Resources */, B6F0481B0952B5FD006D8005 /* zxs.icns in Resources */, B639B7D10A6BB45600927E24 /* raw.icns in Resources */, - B6CA2A260C33F8800003CF90 /* plusd.rom in Resources */, + B6CADD690C48E188004BA954 /* cassette_green.png in Resources */, + B6CADD6A0C48E188004BA954 /* cassette_red.png in Resources */, + B6CADD720C48E1A3004BA954 /* microdrive_green.png in Resources */, + B6CADD730C48E1A3004BA954 /* microdrive_red.png in Resources */, + B6CADD740C48E1A3004BA954 /* plus3disk_green.png in Resources */, + B6CADD750C48E1A3004BA954 /* plus3disk_red.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; Added: trunk/fuse/fusepb/resources/cassette_green.png =================================================================== (Binary files differ) Property changes on: trunk/fuse/fusepb/resources/cassette_green.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/fuse/fusepb/resources/cassette_red.png =================================================================== (Binary files differ) Property changes on: trunk/fuse/fusepb/resources/cassette_red.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/fuse/fusepb/resources/microdrive_green.png =================================================================== (Binary files differ) Property changes on: trunk/fuse/fusepb/resources/microdrive_green.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/fuse/fusepb/resources/microdrive_red.png =================================================================== (Binary files differ) Property changes on: trunk/fuse/fusepb/resources/microdrive_red.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/fuse/fusepb/resources/plus3disk_green.png =================================================================== (Binary files differ) Property changes on: trunk/fuse/fusepb/resources/plus3disk_green.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/fuse/fusepb/resources/plus3disk_red.png =================================================================== (Binary files differ) Property changes on: trunk/fuse/fusepb/resources/plus3disk_red.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/fuse/fusepb/views/DisplayOpenGLView.m =================================================================== --- trunk/fuse/fusepb/views/DisplayOpenGLView.m 2007-07-13 13:49:45 UTC (rev 430) +++ trunk/fuse/fusepb/views/DisplayOpenGLView.m 2007-07-16 12:29:05 UTC (rev 431) @@ -287,20 +287,21 @@ xOrigin:(int) x yOrigin:(int) y { + NSString *filename; NSBitmapImageRep *bitmap; - NSImage *image = [NSImage imageNamed: name]; + NSImage *image; - /* create a bitmap with the correct image data */ - bitmap = [[NSBitmapImageRep alloc] initWithData:[image TIFFRepresentation]]; - if (bitmap == nil) NSLog(@"in loadPicture: NSBitmapImageRep not loaded"); + filename = [NSString stringWithFormat:@"%@_green", name]; /* Colour first image green */ - greenTexture = [greenTexture initWithBitmap:bitmap withXOrigin:x - withYOrigin:y colourRed:0]; + greenTexture = [greenTexture initWithImageFile:filename withXOrigin:x + withYOrigin:y]; + filename = [NSString stringWithFormat:@"%@_red", name]; + /* Colour second image red */ - redTexture = [redTexture initWithBitmap:bitmap withXOrigin:x - withYOrigin:y colourRed:1]; + redTexture = [redTexture initWithImageFile:filename withXOrigin:x + withYOrigin:y]; } -(void) setNeedsDisplayYes Modified: trunk/fuse/fusepb/views/Texture.h =================================================================== --- trunk/fuse/fusepb/views/Texture.h 2007-07-13 13:49:45 UTC (rev 430) +++ trunk/fuse/fusepb/views/Texture.h 2007-07-16 12:29:05 UTC (rev 431) @@ -1,5 +1,5 @@ -/* DisplayOpenGLView.h: Implementation for the DisplayOpenGLView class - Copyright (c) 2006-2007 Fredrick Meunier +/* Texture.h: Implementation for the Texture class + Copyright (c) 2007 Fredrick Meunier This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -35,8 +35,8 @@ Cocoa_Texture texture; GLuint textureId; } --(id) initWithBitmap:(NSBitmapImageRep*)bitmap withXOrigin:(int)x - withYOrigin:(int)y colourRed:(int)red; +-(id) initWithImageFile:(NSString*)filename withXOrigin:(int)x + withYOrigin:(int)y; -(void) dealloc; -(Cocoa_Texture*) getTexture; Modified: trunk/fuse/fusepb/views/Texture.m =================================================================== --- trunk/fuse/fusepb/views/Texture.m 2007-07-13 13:49:45 UTC (rev 430) +++ trunk/fuse/fusepb/views/Texture.m 2007-07-16 12:29:05 UTC (rev 431) @@ -1,5 +1,5 @@ -/* DisplayOpenGLView.m: Implementation for the DisplayOpenGLView class - Copyright (c) 2006-2007 Fredrick Meunier +/* Texture.m: Implementation for the Texture class + Copyright (c) 2007 Fredrick Meunier This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,63 +24,48 @@ #import "Texture.h" -unsigned char * -NSBitmapImageRepToRGBAPixelArray(NSBitmapImageRep * bitmap, int red) +@implementation Texture + +-(id) initWithImageFile:(NSString*)filename withXOrigin:(int)x + withYOrigin:(int)y { - unsigned char * pixels; - NSBitmapImageRep * bitmap2; - NSGraphicsContext * context; -#define BYTES_PER_PIXEL 4 - int targetWidth = [bitmap pixelsWide]; - int targetHeight = [bitmap pixelsHigh]; + if( ( self = [super init] ) ) { + NSString *textureName = [[NSBundle mainBundle] pathForImageResource:filename]; + if( !textureName ) + NSLog(@"in initWithImageFile no textureName for filename:%@", filename); + NSURL *textureFile = [NSURL fileURLWithPath:textureName]; - pixels = (unsigned char *) malloc(BYTES_PER_PIXEL * targetWidth * targetHeight); - bitmap2 = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: &pixels - pixelsWide: targetWidth - pixelsHigh: targetHeight - bitsPerSample: 8 - samplesPerPixel: 4 - hasAlpha: YES - isPlanar: NO - colorSpaceName: NSDeviceRGBColorSpace - bitmapFormat: NSAlphaNonpremultipliedBitmapFormat - bytesPerRow: (targetWidth * BYTES_PER_PIXEL) - bitsPerPixel: (BYTES_PER_PIXEL * 8)]; + CGImageSourceRef image_source = CGImageSourceCreateWithURL( + (CFURLRef)textureFile, + nil); - context = [NSGraphicsContext graphicsContextWithBitmapImageRep: bitmap2]; - [NSGraphicsContext saveGraphicsState]; - [NSGraphicsContext setCurrentContext: context]; - [bitmap drawInRect: NSMakeRect(0, 0, targetWidth, targetHeight)]; - [NSGraphicsContext restoreGraphicsState]; + CGImageRef image = CGImageSourceCreateImageAtIndex( + image_source, + 0, + nil); + texture.image_width = CGImageGetWidth(image); + texture.image_height = CGImageGetHeight(image); - int i; - for( i = 0; i < targetWidth * targetHeight; i++ ) { -#ifdef WORDS_BIGENDIAN - pixels[i*4+3] = red ? pixels[i*4+0] : 0; // r on ppc - pixels[i*4+2] = red ? 0 : pixels[i*4+1]; // g on ppc - pixels[i*4+0] = 0; - pixels[i*4+1] = 0; -#else /* #ifdef WORDS_BIGENDIAN */ - pixels[i*4+0] = red ? pixels[i*4+0] : 0; // r on i386 - pixels[i*4+1] = red ? 0 : pixels[i*4+1]; // g on i386 - pixels[i*4+2] = 0; -#endif /* #ifdef WORDS_BIGENDIAN */ - } + texture.pixels = malloc(texture.image_width * texture.image_height * 4); - [bitmap2 release]; + CGColorSpaceRef color_space = CGColorSpaceCreateDeviceRGB(); - return pixels; -} + CGContextRef context = CGBitmapContextCreate( + texture.pixels, + texture.image_width, + texture.image_height, + 8, + texture.image_width * 4, + color_space, + kCGImageAlphaPremultipliedFirst); -@implementation Texture + CGContextDrawImage( + context, + CGRectMake(0, 0, texture.image_width, texture.image_height), + image); --(id) initWithBitmap:(NSBitmapImageRep*)bitmap withXOrigin:(int)x - withYOrigin:(int)y colourRed:(int)red -{ - if( ( self = [super init] ) ) { - texture.pixels = NSBitmapImageRepToRGBAPixelArray( bitmap, red ); - texture.image_width = [bitmap pixelsWide]; - texture.image_height = [bitmap pixelsHigh]; + CGContextRelease(context); + texture.image_xoffset = x; texture.image_yoffset = y; @@ -93,7 +78,10 @@ -(void) dealloc { glDeleteTextures(1, &textureId); - free( texture.pixels ); + if (texture.pixels != NULL) { + free( texture.pixels ); + texture.pixels = NULL; + } [super dealloc]; } @@ -112,19 +100,26 @@ glGenTextures(1, &textureId); /* Set memory alignment parameters for unpacking the bitmap. */ + glPixelStorei( GL_UNPACK_ROW_LENGTH, texture.image_width ); glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); /* Specify the texture's properties. */ - glBindTexture( GL_TEXTURE_RECTANGLE_EXT, textureId ); - glTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - glTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - glTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); - glTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); + glBindTexture( GL_TEXTURE_RECTANGLE_ARB, textureId ); + glTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); + glTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); + /* Upload the texture bitmap. */ - glTexImage2D( GL_TEXTURE_RECTANGLE_EXT, 0, GL_RGBA, texture.image_width, - texture.image_height, 0, GL_RGBA, - GL_UNSIGNED_INT_8_8_8_8_REV, texture.pixels ); + glTexImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, texture.image_width, + texture.image_height, 0, GL_BGRA_EXT, +#ifdef WORDS_BIGENDIAN + GL_UNSIGNED_INT_8_8_8_8_REV, +#else /* #ifdef WORDS_BIGENDIAN */ + GL_UNSIGNED_INT_8_8_8_8, +#endif /* #ifdef WORDS_BIGENDIAN */ + texture.pixels ); } @end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |