Split: Loading textures
well. so far so good, this forum seems to be the best on the net, thanks guys!.. I'm glad it's back up..
now... i have a basic understanding of setting up vertex points in opengl...
however, looking at sample code from here and there, it seems that the preloading of image files into textures has to be done byte by byte, row by row, in a very confusing fashion, not nearly as simple as CGCreateImageWithPNGDataProvider (my sprites are all PNG RGBA...)
//
Anyways, the bottom line is, I have no idea how to work with texture maps in OpenGL. I don't even know what mipmap means, or what the difference between bilinear and trilinear is. I have no idea what kind of pointer I should pass to openGL so it can reference the texture, or whether it takes an arbitrary resource ID (I seem to recall looking at some image loading methods that return INTEGERS!?!?!?)... and if I'm supposed to return an ID after loading is complete, how do I later make use of that ID to draw the image? there must be a list/vector that refers to a pointer or something.
okay and.... what the hell is a texel!? and what's with this "power of 2" stuff... I'm looking at apple's "OpenGL Image" sample code... and my alpha channel isn't working properly.
help, please!
now... i have a basic understanding of setting up vertex points in opengl...
however, looking at sample code from here and there, it seems that the preloading of image files into textures has to be done byte by byte, row by row, in a very confusing fashion, not nearly as simple as CGCreateImageWithPNGDataProvider (my sprites are all PNG RGBA...)
//

Anyways, the bottom line is, I have no idea how to work with texture maps in OpenGL. I don't even know what mipmap means, or what the difference between bilinear and trilinear is. I have no idea what kind of pointer I should pass to openGL so it can reference the texture, or whether it takes an arbitrary resource ID (I seem to recall looking at some image loading methods that return INTEGERS!?!?!?)... and if I'm supposed to return an ID after loading is complete, how do I later make use of that ID to draw the image? there must be a list/vector that refers to a pointer or something.
okay and.... what the hell is a texel!? and what's with this "power of 2" stuff... I'm looking at apple's "OpenGL Image" sample code... and my alpha channel isn't working properly.
help, please!
First, step through the redbook passages on texturing. Once you've done that Here's some code to get you started with texture upload in Cocoa:
Code to create a suitable bitmap from any NSImage. (See +bitmapWithImage;. note: this code is altivec opt')
Code to upload that bitmap to GL.
These classes will also allocate memory and names and various other things. Feel free to take or modify whatever.
Code to create a suitable bitmap from any NSImage. (See +bitmapWithImage;. note: this code is altivec opt')
Code to upload that bitmap to GL.
These classes will also allocate memory and names and various other things. Feel free to take or modify whatever.
---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
dave05 Wrote:I have no idea how to work with texture maps in OpenGL.
Most of your questions can be answered by reading the glTexImage2D man page.
General info is available on "the internet":
texel
texture mapping
texture filtering
okay, the code you provided to convert an NSImage to a bitmap is, I suppose, where I get lost...
Should I attempt to understand what is going on within this method?
.. the thing is, I want to avoid downloading an entire library of code if possible. If it's possible to convert a CGImage to a GLVoid byte by byte, I'd rather do that than borrow a pile of someone else's work.
Maybe I'll print off the whole redbook..
Should I attempt to understand what is going on within this method?
.. the thing is, I want to avoid downloading an entire library of code if possible. If it's possible to convert a CGImage to a GLVoid byte by byte, I'd rather do that than borrow a pile of someone else's work.
Maybe I'll print off the whole redbook..
by the way, if someone had just directed me to
http://developer.apple.com/qa/qa2001/qa1325.html
I would have figured this out long ago. arrrrrrrrrrrrrg
http://developer.apple.com/qa/qa2001/qa1325.html
I would have figured this out long ago. arrrrrrrrrrrrrg
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Loading and using textures with alpha in OpenGL with Cocoa | corporatenewt | 4 | 5,077 |
Dec 8, 2007 02:06 PM Last Post: Malarkey |
|
| loading textures - cocoa openGL | mDmarco | 20 | 8,330 |
Aug 28, 2007 08:48 PM Last Post: OneSadCookie |
|
| Best way to deal with loading textures? | bronxbomber92 | 14 | 4,797 |
May 4, 2007 05:31 PM Last Post: OneSadCookie |
|
| libpng loading junk at bottom of my OpenGL textures...? | BinarySpike | 6 | 5,042 |
Apr 19, 2007 12:20 PM Last Post: BinarySpike |
|
| Loading textures from bitmaps | tehqin | 5 | 3,451 |
Feb 26, 2007 01:58 AM Last Post: unknown |
|

