Problem with SOIL in OpenGL

Apprentice
Posts: 11
Joined: 2008.08
Post: #1
Hello!

First things first, I'm really new to programming, period XD
New to Cocoa, new to OpenGL, new as in about one week.

So i've been messing around with CocoaGL and gotten up to the part, where i would like to texture a simple tile on my screen. The good old Red Book didn't answer that aspect nicely and other tutorials and examples that i've read, i've also read that these methods aren't quite the best ones to use, for example One Sad Cookie stated that NSBitmapImageRep is a dangerous way to load images into a texture, i'm still wondering why though.

Anyways, surfed around and found some image libaries, liked SOIL for it's simplicity, wrote the code for SOIL to load an image into an OpenGL texture, but upon building, i get an error...


Code:

tex_1 = SOIL_load_OGL_texture(
"texture.jpg.",
SOIL_LOAD_AUTO,
SOIL_CREATE_NEW_ID,
SOIL_FLAG_NTSC_SAFE_RGB
);

I don't get an error message in the text editor, but upon clicking the error message mark thingy ( don't know what to call it, sorry), it opens up a new window with the message:

Building target “OpenGL” of project OpenGL with configuration “Debug” — (1 error)
cd /Users/kalla/Desktop/OpenGL
/Developer/usr/bin/gcc-4.0 -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk -L/Users/kalla/Desktop/OpenGL/build/Debug -F/Users/kalla/Desktop/OpenGL/build/Debug -filelist /Users/kalla/Desktop/OpenGL/build/OpenGL.build/Debug/OpenGL.build/Objects-normal/i386/OpenGL.LinkFileList -mmacosx-version-min=10.5 -framework Cocoa -framework OpenGL -framework OpenAL -framework GLUT -o /Users/kalla/Desktop/OpenGL/build/Debug/OpenGL.app/Contents/MacOS/OpenGL
Undefined symbols:
"_SOIL_load_OGL_texture", referenced from:
-[PeaVaade drawRect:] in PeaVaade.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
"_SOIL_load_OGL_texture", referenced from:
-[PeaVaade drawRect:] in PeaVaade.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Build failed (1 error)




and that's it, don't ask why i've got OpenAL in my project XD i plan on using the same project to learn programming and MAYBE someday write a simple game or an app that ppl might find useful, if it's going to be a game, of course it's going to have sound, or do you suggest any other framework besides OpenAL?

anyways, went off topic with that, any help would be really great and appreciated, been messing around with this thing for a long time now and not found a solution.

PS! Really sorry for any spelling mistakes or weird english, not my native language Smile

BIIIIG Thanks in advance!

---
Ringo
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #2
Sounds like you're not linking to the SOIL library/framework/whatever they provide. You'll need to drag the SOIL .a, .dylib, or .framework into your Xcode project, whichever's appropriate.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #3
I use SOIL -- all I had to do was include the .c files in my project and it linked correctly.
Quote this message in a reply
Apprentice
Posts: 11
Joined: 2008.08
Post: #4
it said to add only SOIL.h to the project and link it, which i did, tried both #import and #include, but i'll try to see if adding and linking any other files fix it, just a sec Rasp


*just a sec over* :
added and linked SOIL.c .... got 32 errors and 82 warnings, PROGRESS!!!! XD
messing around some more Rasp

OK! added all the files to the project but only linked (#import) SOIL.h
compiles nicely, and runs, BUT, not showing texture -_-

going to try and figure that out now, really big Thanks for pointing the solution out!!!
pretty fast replies too, i like this place already! XD
Quote this message in a reply
Moderator
Posts: 3,572
Joined: 2003.06
Post: #5
RingoEST Wrote:... pretty fast replies too, i like this place already! XD

BTW, iDevGames was born in Japan. You might take note of the "squarlies" style of smileys, which were influenced by that fact:

Ninja LOL Wink Rasp Smile Love
Quote this message in a reply
Member
Posts: 53
Joined: 2007.08
Post: #6
RingoEST Wrote:Code:

tex_1 = SOIL_load_OGL_texture(
"texture.jpg.",
SOIL_LOAD_AUTO,
SOIL_CREATE_NEW_ID,
SOIL_FLAG_NTSC_SAFE_RGB

);



Ringo

If you are having problems getting your texture to display, it might be because you are telling it to load "texture.jpg." That may just be a typo from posting, but your code should probably read "texture.jpg" . After calling that load function, you should probably check if it was loaded successfully and maybe printf an error message or something to let you know if its not.
Quote this message in a reply
Apprentice
Posts: 11
Joined: 2008.08
Post: #7
AnotherJake, I'm not actually from japan, i'm just staying and studying here as an exchange student, homeland is Estonia Smile

anyways, Terrydil, thanks for pointing that out!
wasn't a posting typo, had it in my code as well but it didn't change anything, i added the

if( 0 == tex_1 )
{
NSLog(@"SOIL loading error: '%s'\n", SOIL_last_result() );
}

code that was on SOIL's website and yeah, the console tells me that it couldn't read the file, i just can't figure it out, what's wrong with this code? :


#import "PeaVaade.h"
#import <Cocoa/Cocoa.h>
#import <OpenGL/OpenGL.h>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
#import "SOIL.h"


GLuint tex_1;

@implementation PeaVaade

- (void) drawRect: (NSRect) PeaVaade
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
gluOrtho2D(0.0, 650.0, 0.0, 450.0);
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

tex_1 = SOIL_load_OGL_texture(
"tile.png",
SOIL_LOAD_AUTO,
SOIL_CREATE_NEW_ID,
SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB
);

/* check for an error during the load process */
if( 0 == tex_1 )
{
NSLog(@"SOIL loading error: '%s'\n", SOIL_last_result() );
}

glBindTexture(GL_TEXTURE_2D, tex_1);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0); // Point 1. Drawing Counterclockwise...
glVertex2f(0.0, 0.0);

glTexCoord2f(64.0, 0.0); // point 2.
glVertex2f(64.0, 0.0);

glTexCoord2f(64.0, 64.0); // point 3.
glVertex2f(64.0, 64.0);

glTexCoord2f(0.0, 64.0); // point 4.
glVertex2f(0.0, 64.0);

glEnd();

glFlush();
}

@end



i just can't figure it out, man i'm stupid Sad
Quote this message in a reply
Moderator
Posts: 3,572
Joined: 2003.06
Post: #8
RingoEST Wrote:AnotherJake, I'm not actually from japan, i'm just staying and studying here as an exchange student, homeland is Estonia Smile

Wow, you're a long way from home! Blink Sorry about the off-topic...
Quote this message in a reply
Apprentice
Posts: 11
Joined: 2008.08
Post: #9
yeah extremely sorry for the off-topic (A) Smile

but yeah, 11hours of flight!Grin 6th month here, going back in january...
man it's a blast here!Grin really coolRasp
Quote this message in a reply
Member
Posts: 53
Joined: 2007.08
Post: #10
The image most likely isn't loading because you haven't specified the path correctly. Using "tile.png" isn't sufficient unless the working directory is the folder which contains the file. You may want to look at http://blog.onesadcookie.com/2007/12/fin...files.html for info on finding your files.

//edit: Since you mentioned you are new to programming (and presumably Xcode as well), make sure you are adding whatever resources you need (images and such) to the Resources directory in your Xcode project.
Quote this message in a reply
Apprentice
Posts: 11
Joined: 2008.08
Post: #11
it's just incredible how two lines of code can fix a biiiiig problem, wow! Grin

Thank You All SOOOO Much for Your Help!!! Smile
By the way, Terrydil, or anyone else for that matter, i did what the Required Reading announcment said, and lurked around a bit before posting, say, is there a problem that OneSadCookie HAS NOT fixed? XD
Quote this message in a reply
Member
Posts: 53
Joined: 2007.08
Post: #12
RingoEST Wrote:By the way, Terrydil, or anyone else for that matter, i did what the Required Reading announcment said, and lurked around a bit before posting, say, is there a problem that OneSadCookie HAS NOT fixed? XD

He has yet to come out with an app that automatically produces original, money-making games with the click of a button, but I expect that any day now.
Quote this message in a reply
Apprentice
Posts: 11
Joined: 2008.08
Post: #13
He's THAT good? :O
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  OpenGL Alpha Channel Problem Moganza 1 2,983 Jan 19, 2013 08:25 AM
Last Post: sealfin
  SOIL linker errors kropcke 6 6,574 Aug 30, 2012 09:38 PM
Last Post: kropcke
  iPad, OpenGL ES, and XCode Instruments problem! Bandit 0 3,881 Dec 13, 2010 01:21 PM
Last Post: Bandit
  OpenGL global and local coordinate problem. mikey 4 3,864 May 26, 2009 08:48 AM
Last Post: mikey
  Simple OpenGL ES problem soulstorm 3 4,147 May 14, 2009 03:53 PM
Last Post: AnotherJake