Drawing bitmaps in OpenGL
The bottom line is, unless you create the NSBitmapImageRep yourself with the longwinded constructor passing your own pixel array, you should not attempt to pass -bitmapData to OpenGL.
Even if your app happens to work for the images you've tried on the OS you've tried, there are no guarantees for other images, and other OSes.
Even if your app happens to work for the images you've tried on the OS you've tried, there are no guarantees for other images, and other OSes.
Some one seems to have maliciously destroyed the content at GameWiki and in particular I would have liked to see the code for the ImageIO texture loader. Does anyone have a (more or less) clean version of that code they could share along with caveats or criticisms?
http://gamewiki.evolpenguin.com/index.ph...oldid=3461 is the last good version of the page.
It needs
to work on Intel, and of course it requires 10.4.
It needs
Code:
#if defined(__BIG_ENDIAN__)
GL_UNSIGNED_INT_8_8_8_8_REV,
#else
GL_UNSIGNED_INT_8_8_8_8,
#endifto work on Intel, and of course it requires 10.4.
Thanks OSC!
I've been working through this and I am stuck again.
To get my image object within the IOImage Texture loader I chopped in some code from the Apple Dev site:
Everything loads but the build gets hung up in the debugger because at the end of this code fragement there is basically no data in the object (in the debugger the value is 0x1) so:
fails.
I've checked in the debugger and "raw" does have an address and 196 Kbytes of data in the summary (Furthermore, RedSquare.bmp is an image file that opens fine in Preview).
So the problem seems to be with the line
Which isn't doesn't appear to be moving the data.
Any thoughts?
By the way I had to make some changes to the Assert and AssertNonNull statements using assert (lower case) and assert (____ !-= NULL) to the same effect (I hope). I am working without the Carbon framework.
To get my image object within the IOImage Texture loader I chopped in some code from the Apple Dev site:
Code:
NSString* path=[ NSString stringWithFormat:@"%@/%s",
[ [ NSBundle mainBundle ] resourcePath ],
"RedSquare.bmp" ];
NSData* raw;
raw=nil;
raw = [NSData dataWithContentsOfFile:path];
CGImageRef image = NULL;
CGImageSourceRef sourceRef;
sourceRef = CGImageSourceCreateWithData((CFDataRef)raw, NULL);
if(sourceRef) {
image = CGImageSourceCreateImageAtIndex(sourceRef, 0, NULL);
CFRelease(sourceRef);
NSLog(@"SourceRef exists");
}Everything loads but the build gets hung up in the debugger because at the end of this code fragement there is basically no data in the object (in the debugger the value is 0x1) so:
Code:
unsigned width = CGImageGetWidth(image);fails.
I've checked in the debugger and "raw" does have an address and 196 Kbytes of data in the summary (Furthermore, RedSquare.bmp is an image file that opens fine in Preview).
So the problem seems to be with the line
Code:
image = CGImageSourceCreateImageAtIndex(sourceRef, 0, NULL);Which isn't doesn't appear to be moving the data.
Any thoughts?
By the way I had to make some changes to the Assert and AssertNonNull statements using assert (lower case) and assert (____ !-= NULL) to the same effect (I hope). I am working without the Carbon framework.
Those macros aren't from Carbon, you're intended to define 'em however you want 
[[NSBundle mainBundle] pathForResource:@"RedSquare" ofType:@"bmp"] would be a more normal way to get the path, but what you have should *work*...

[[NSBundle mainBundle] pathForResource:@"RedSquare" ofType:@"bmp"] would be a more normal way to get the path, but what you have should *work*...
I started over and coverted the method back to a function and it seems to run smoothly. Except that there is no texture on the cube. I imagine I am binding the texture incorectly in the drawRect method. But I'll work at it.
Thanks.
Thanks.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| opengl text/font drawing from CGContext | fretmunky | 11 | 11,401 |
Dec 7, 2008 11:29 AM Last Post: fretmunky |
|
| OpenGL ES - Drawing a simple cube help. | MattCairns | 7 | 10,988 |
Oct 10, 2008 05:26 PM Last Post: Frogblast |
|
| Loading textures from bitmaps | tehqin | 5 | 3,448 |
Feb 26, 2007 01:58 AM Last Post: unknown |
|
| OpenGL, SDL, and Transparent Bitmaps | RyanA | 4 | 3,347 |
Jun 26, 2006 04:26 PM Last Post: RyanA |
|
| Loading Bitmaps | Jones | 3 | 2,193 |
May 3, 2006 07:57 PM Last Post: OneSadCookie |
|

