Texture Loading Headaches

napthali
Unregistered
 
Post: #1
All right, I know this has been done to death on the boards, but I'm still having problems... I've tried the NeHe tutorials, and the QTValuePak, but to no avail. (They don't seem to work with Panther's XCode.)

I'm just trying to load a texture from file (format doesn't really matter to me at this stage, but I'm using Targa, since that seems to be the popular thing to do) and slap it on a quad. I'm writing in C++ and using GLUT.

Can anyone give me (or point me to) some sample code that ONLY loads a texture and displays it? Most samples I've seen do too many things at once, or are poorly commented. I still don't really have a handle on the OpenGL internal representation of a texture, and that's part of my problem at the moment.

I appreciate the help, and apologize for asking a newbie question.
Quote this message in a reply
kberg
Unregistered
 
Post: #2
If you're sure that your texture loading code is copied pretty much verbatim, you might not have a GL context set up when you're loading your textures?

Make sure you've already set up your GLUT / AGL / NSGL /CGL window before you try and load any textures or display lists.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #3
Damn, QTValuePak doesn't work in Panther Sad Guess I've got some work to do... been procrastinating updating QTValuePak for ages now, might be a good thing Smile

The texture loading code should is fine though... Smiley Tag (source also available on iDevGames) uses a modified version of the QTValuePak code to load textures, and that works fine on Panther. It's probably also a more useful example, since you can just about cut-and-paste the function...
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #4
Search our source code section. There are a few very small OpenGL samples that show things like that quite clearly.
Quote this message in a reply
napthali
Unregistered
 
Post: #5
Wow, thanks for all the advice, guys. Glad to find a place on the web that's friendly to dumb questions and newbies like me. Smile

I looked at the SmileyTag sample, but it's Obj-C and I only know C++ at the moment. I'm certainly not averse to learning Obj-C, but at this juncture I'd rather get the principle down in my native language so I can focus on just learning one thing at a time. Blink

I really wish the source code library was searchable.... or is it and I'm just missing something obvious. Any other suggestions?
Quote this message in a reply
Member
Posts: 201
Joined: 2002.06
Post: #6
The source code system is being revamped right now. A nice new set of features should be coming soon, I hope. Go, Griggs, Go!
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #7
Quote:Originally posted by napthali
I looked at the SmileyTag sample, but it's Obj-C and I only know C++ at the moment.

STLuaGraphics.m only has a couple of lines of ObjC; the rest is straight C (and mostly straight from QTValuePak). If you need help removing those couple of lines, either come to the iDevGames chat or email me personally.
Quote this message in a reply
Moderator
Posts: 3,573
Joined: 2003.06
Post: #8
Quote:Originally posted by OneSadCookie
Damn, QTValuePak doesn't work in Panther Sad Guess I've got some work to do...
I have a similar problem but I'm not using QTValuePak. It appears to be a problem with glTexImage2D although I haven't figured out what's up yet. SmileyTag uses gluBuild2DMipmaps instead and that works just fine in place of glTexImage2D in Panther for right now. Must figure this one out.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #9
glTexImage2D is significantly improved in Panther... maybe you're running afoul of that somehow [Image: wink.png]

The problem with QTValuePak is almost certainly to do with events or something. The QuickDraw image sample stopped working in Panther for event-handling reasons, I'm assuming something similar is going on here.
Quote this message in a reply
Moderator
Posts: 3,573
Joined: 2003.06
Post: #10
Quote:Originally posted by OneSadCookie
glTexImage2D is significantly improved in Panther... maybe you're running afoul of that somehow
Maybe. But this works:
Code:
gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGBA, imageBounds.right, imageBounds.bottom, GL_BGRA_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, buffer );
And this doesn't work in Panther whereas it worked just fine in Jaguar:
Code:
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, imageBounds.right, imageBounds.bottom, 0, GL_BGRA_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, buffer );
Events are definitely not the problem here. I'll just have to figure it out later.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #11
In what sense not work? White texture image? OpenGL error? Corrupt Texture Image?
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #12
Quote:Originally posted by napthali
I really wish the source code library was searchable.... or is it and I'm just missing something obvious. Any other suggestions?
If you click the download file finder, you can search it. Unfortunately, the example I was thinking of is Cocoa, so it won't help you much...
Quote this message in a reply
Member
Posts: 156
Joined: 2002.11
Moderator
Posts: 3,573
Joined: 2003.06
Post: #14
Quote:Originally posted by OneSadCookie
In what sense not work? White texture image? OpenGL error? Corrupt Texture Image?
Yeah, white texture image. Sorry about the lack of description. This is actually starting to tick me off a little now. My same exact texture loading library works perfectly in another app that I have so I suspect that the problem is not with glTexImage2D after all. It's gonna be a long night tracking this one down... Were there any significant changes to texturing/blending/??? in Panther that you can think of off the top of your head?
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #15
Several of Apple's own GL demos have broken white textures in Panther, so you're not alone.

Maybe flooding Apple with bugs saying "don't break stuff, dumbasses" will fix it?
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  iPhone texture loading issue yotryu 0 3,405 Mar 11, 2009 03:40 AM
Last Post: yotryu
  Texture Mapping: Loading a texture from a .bmp file? ishrock 5 6,100 Dec 13, 2008 09:27 AM
Last Post: ThemsAllTook
  OpenGL Texture Loading & Sprites corporatenewt 2 11,058 Jan 30, 2008 12:39 PM
Last Post: ynda20
  Texture Loading in Cocoa... dave05 3 8,071 Dec 11, 2007 03:12 AM
Last Post: DoG
  Cocoa Texture Loading Code Problem Nick 1 3,052 Oct 28, 2005 11:44 PM
Last Post: OneSadCookie