Need a bit of porting help

Lindley
Unregistered
 
Post: #1
Hi, I'm a long-time Mac user, and I've been a CS student for many years.....but I haven't actually done much programming on Macs before, so I need some help.

The final project for my Computer Graphics class was to write a roller coaster program in OpenGL. I wrote it entirely on school Linux machines, however; I'm now trying to get it to work on my TiBook under 10.3 with as few changes to the actual code as possible.

The project used GLUT, and for textures, it used something called libpicio, which is a simplified interface to libtiff.

Currently, I have managed to get it to run correctly as a command-line X11 app. However, I'd like it convert it into a standalone app with an actual interface, if that's possible without too much work. (The project is over, this port is just for the hell of it.)

What I've done so far is used fink to install libtiff and libglut, and simply compiled using Make. I'd like to figure out how to make it work in Xcode.

First, what type of Xcode project should I use? None of them seems ideally suited to what I want. The roller coaster program is written in C. Would making it a Cocoa application still allow me to use GLUT for windowing, etc, or would I have to change that? For the most part it would probably be an easy change, as long as there's an equivalent to glutSolidTorus.

Second, as of now, I'm getting "_jpeg_std_error" undeclared symbol errors when I run. This didn't happen when compiling with make, so I'm not sure what's going on. Anyone have any ideas?
If not, could you suggest an alternative simple image-reading library? All I really need to do is read in textures in a format acceptable to glTexImage2D.

Thanks in advance!
Quote this message in a reply
Member
Posts: 257
Joined: 2004.06
Post: #2
Lindley Wrote:First, what type of Xcode project should I use? None of them seems ideally suited to what I want. The roller coaster program is written in C. Would making it a Cocoa application still allow me to use GLUT for windowing, etc, or would I have to change that? For the most part it would probably be an easy change, as long as there's an equivalent to glutSolidTorus.

You can use Cocoa to handle all the UI stuff easily. Check out OSC's XCode/GLUT tutorial.

The brains and fingers behind Malarkey Software (plus caretaker of the world's two brattiest felines).
Quote this message in a reply
Member
Posts: 715
Joined: 2003.04
Post: #3
you'll find that Tutorial
Here
Quote this message in a reply
Lindley
Unregistered
 
Post: #4
That tutorial cleared the GLUT issues right up, but I'm still getting errors from the image-reading routines. Any suggestions on that?
Quote this message in a reply
Member
Posts: 257
Joined: 2004.06
Post: #5
igame3d Wrote:you'll find that Tutorial
Here

Doh! And you know, I had that URL in my copy/paste buffer too... Anyway, I can't help out with the jpeg thing since I usually use libpng and glpng to do my stuff. Maybe you're not linking in the jpeg libraries correctly.

The brains and fingers behind Malarkey Software (plus caretaker of the world's two brattiest felines).
Quote this message in a reply
Puzzler183
Unregistered
 
Post: #6
Lindley Wrote:That tutorial cleared the GLUT issues right up, but I'm still getting errors from the image-reading routines. Any suggestions on that?

I suspect you have endianness problems. Do 24 bit images look like red and blue are switched? If so, you have endianness problems. 32 bit images will also look odd if you have endianness issues.
Quote this message in a reply
Lindley
Unregistered
 
Post: #7
It could very well be an endian problem, but that's not all of it. I can't load images into memory at all.

I also have a small library someone wrote which is designed to read bmp images, but that hasn't worked either.....that may be an endianness issue, since it seems to be reading the image dimensions incorrectly right off the bat.
Quote this message in a reply
Lindley
Unregistered
 
Post: #8
All right, let me state exactly what I'm looking for right now:

-A known-to-work method of reading images (any format) into memory in such a way that they're immediately passable to glTexImg2D.

I really don't care what format my textures are in, I just want a way to read them. Apple's help files don't seem terribly useful in this regard.

Regarding libpng and glpng above----anything special to using those, or is it straightforward?
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #9
Lindley Wrote:All right, let me state exactly what I'm looking for right now:

-A known-to-work method of reading images (any format) into memory in such a way that they're immediately passable to glTexImg2D.

I really don't care what format my textures are in, I just want a way to read them. Apple's help files don't seem terribly useful in this regard.

Regarding libpng and glpng above----anything special to using those, or is it straightforward?
The obvious way to read images on the Mac would be by using QuickTime. OSC's fabulous QT tutorial should show you all you need to know.
Quote this message in a reply
Lindley
Unregistered
 
Post: #10
Do'h! Hadn't considered that.

...But, off hand, I can't find this QT tutorial of which you speak at the link above. Some sample code which may be helpful, but no tutorial.
Quote this message in a reply
Moderator
Posts: 702
Joined: 2002.04
Post: #11
I believe this is the tutorial of which DoG speaks: here.

Mark Bishop
--
Student and freelance OS X & iOS developer
Quote this message in a reply
Lindley
Unregistered
 
Post: #12
All right. I can use that....but it looks needlessly complicated.

Surely someone has written a wrapper class such that I can just do something akin to
pic = jpeg_read(filename); ?

Anyway, before I go changing all my code around to work through Quicktime, here's a different question:

The makefile which I currently have *will* compile correctly (for X11). I get linker errors when compiling in XCode. Clearly, something is different.

XCode claims that it uses gcc to compile....is there a way for me to see exactly what is being passed to gcc, so I can figure out what it's not sending?
Quote this message in a reply
Member
Posts: 184
Joined: 2004.07
Post: #13
http://openil.sourceforge.net/
This is the cross-platform lib I always use for image loading. It's about this easy:

Code:
ilInit( );
    
    ILuint imgId;
    ilGenImages( 1, &imgId );
    
    ilBindImage( imgId );

    ilLoadL( IL_TYPE_UNKNOWN, ( ILvoid * ) resource->getBuffer( ), resource->getSize( ) );

    ilConvertImage( IL_BGRA, IL_UNSIGNED_BYTE );

    int width = ilGetInteger( IL_IMAGE_WIDTH );
    int height = ilGetInteger( IL_IMAGE_HEIGHT );
    
    
    unsigned int* buffer = (unsigned int *) ilGetData( );

Then you can use buffer as an argument to BGRA data (you could use RGBA if you want that too, or whatever.)
Quote this message in a reply
Lindley
Unregistered
 
Post: #14
Looks great in theory, but Stuffit Expander is getting write permissions errors trying to deal with the .tar....
Quote this message in a reply
Member
Posts: 257
Joined: 2004.06
Post: #15
Lindley Wrote:XCode claims that it uses gcc to compile....is there a way for me to see exactly what is being passed to gcc, so I can figure out what it's not sending?

Build menu -> Detailed Build Results. The panel that contains all the raw compiler output is in a window pane that is completely closed so you'll have to drag it open (look for the two vertical dots in the middle of the window). If you want to adjust the compile options/flags/what have you, do a Get Info on the project file itself.

The brains and fingers behind Malarkey Software (plus caretaker of the world's two brattiest felines).
Quote this message in a reply
Post Reply