Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > OpenGL texture woes.

OpenGL texture woes.
Thread Tools
Fresh-Faced Recruit
Join Date: Jul 2001
Location: Rehoboth Beach DE
Status: Offline
Reply With Quote
Sep 20, 2001, 07:56 PM
 
I've been trying to port some OpenGL OSX GLUT demos at NEHE to Cocoa,and I've run into serious problems when opening an image file.There are two files,gltx.h and gltx.c which I have imported in my project.They work just fine in the GLUT windowing enviroment but when I try to load the texture in Cocoa,I get an error message stating "gltxReadRGB() failed: can't open image file "image.rgb"."I know the image file is OK,I've swapped several in and out from other apps,they all work in the other apps,none work in the one in question.I've called the function correctly(the warning I received is embedded in the function in question),named the image properly,and imported all the relevant headers.Does anyone have any idea where the problem would be?Any info would be greatly appreciated.
     
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status: Offline
Reply With Quote
Sep 20, 2001, 08:07 PM
 
Are you sure that it is looking for the file in the appropriate place? The way that I did what you are talking about is to send the texture function the path to the image file (keeping the image file in the program bundle). Is this what you are trying to do?

I use a technique like this:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
[<font color = purple>self</font> loadTexture:[[[NSBundle mainBundle] pathForResource:<font color = orange>@"image<font color = red>"</font> ofType:<font color = orange>@"</font>rgb"</font>] cString]];
</font>[/code]

The "loadTexture:" method is just a wrapper for the call to the C file that reads the image file.

Is that of any help?
Jeff.
Spectral Class
"Shedding Light on Innovation"
     
4.669  (op)
Fresh-Faced Recruit
Join Date: Jul 2001
Location: Rehoboth Beach DE
Status: Offline
Reply With Quote
Sep 20, 2001, 09:07 PM
 
How did you declare the loadTexture function in the header,I've been having a lot of trouble with the synatax.

[ 09-20-2001: Message edited by: 4.669 ]
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Sep 21, 2001, 01:34 AM
 
Originally posted by 4.669:
<STRONG>How did you declare the loadTexture function in the header,I've been having a lot of trouble with the synatax.</STRONG>
Probably -(void)loadTexture void *)textureData
or -(void)loadTexture char *)textureData

Edit: annoying smileys!

[ 09-21-2001: Message edited by: Angus_D ]
     
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status: Offline
Reply With Quote
Sep 21, 2001, 03:41 PM
 
Angus was right:
-(void)loadTexture char *)textureData

the cString method of NSString will return (char *)


A question I have about this, however, is about the compiler warning that this creates. Is there any way to stop it from complaining about removing attributes or whatever the warning is (can't remember right now)?

Not a big problem but an annoyance, nonetheless.

Jeff.

[ 09-21-2001: Message edited by: Apocalypse ]
Spectral Class
"Shedding Light on Innovation"
     
Forum Regular
Join Date: Aug 2001
Location: Vienna, Austria
Status: Offline
Reply With Quote
Sep 21, 2001, 08:49 PM
 
Originally posted by Apocalypse:
<STRONG>Angus was right:
-(void)loadTexture char *)textureData

the cString method of NSString will return (char *)
</STRONG>
I don't know anything about OpenGL (wish I would), but when passing a file directly, you should use NSData: <font face = "courier">[[NSData dataWithContentsOfFile:@"..."] bytes]</font>
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:19 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2