 |
 |
OpenGL texture woes.
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Jul 2001
Location: Rehoboth Beach DE
Status:
Offline
|
|
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
|
|
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.
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Jul 2001
Location: Rehoboth Beach DE
Status:
Offline
|
|
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
|
|
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
|
|
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 ]
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Aug 2001
Location: Vienna, Austria
Status:
Offline
|
|
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>
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|