Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Biased turkey

Problem integrating OpenGL with SDL

This topic is 6093 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I can''t compile an example from the book " Programming Linux games". So far I had no problem at all for compiling the pure SDL programs, but now I had a lot them of the following type like: Undefined reference to GViewport Undefined reference to glClearColor etc... Obviously, there is some missing openGL ( or Mesa ) header file. The beginning of my source code is: /* Example of OpenGL rendering through SDL. */ #include #include #include #include And I compile the program with the following command ( as specified in the book: gcc XXXX.c -o XXXX `sdl-config --cflags --libs` -I/usr/X11R6/include -L/usr/X11R6/lib 1) The books says " furthermore, you need to compile your copy of SDL with OpenGL video support " How could I , I downloaded and installed the already compiled binary packaged, not the source 2) The missing header file is really in my system: I had the gl.h at /usr/include 3) I had Redhat 7.1 Thanks in advance for any opinion, suggestion or ... r.t.f.m

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by Biased turkey
2) The missing header file is really in my system: I had the gl.h at /usr/include


gl.h should reside in a sub-directory called "gl" i.e. /usr/include/gl/gl.h
And you should include it with:

#include <gl/gl.h>

As a small aside: The 'recommended' way of including the SDL.h header is:

#include "SDL.h"

(according to www.libsdl.org)

You should also link to the gl and glu libs.
Add this to your command line when compiling:

-lgl -lglu

Or it could be:

-lopengl -lglu

I don't quite remember...

Edited by - Dactylos on October 17, 2001 4:58:13 AM

Share this post


Link to post
Share on other sites
Sorry for the incomplete #include statements. It should have been:
#include
#include
#include
#include

I checked and the path for GL/gl.h is correct, I can see it and display the content of that file.
So, I''ll look for some other mistake I could have done.
I''ll try the -lgl command .
Thanks anyway.

Share this post


Link to post
Share on other sites
To Dactylos: Thanks a bunch for your suggestion, The book never mentions looking for specific libraries ( in our case an OGL or a Mesa library ) BUT the first basic examples source codes and bitmaps included with the book are located in a directory that also includes a makefile for compiling the binaries. I didn''t use the makefile because I first want to get a little familiar with the gcc compiler( new to me ) and thus compiling " by hand " without any help. Yesterday night I had a look at that makefile and to my surprise there is a line that says:
OPENGL_LIB=-L/usr/X11R6/include -lGL.
So as you suggested I added missing -lGL to the command line and ..voila, no more error at compiling time and I get an executable .
Now, when I run the executable, instead of having a colored 3D triangle ( as written in the book ) I have a frozen blue window that also freezes the whole system, like a blue screen of death . I didn''t know Linux Redhat 7.1 includes a Win98n emulator

But I shouldn''t complaint, at least now the program compiles OK.

To Null and Void: thanks for the tip about HTML tags.

Share this post


Link to post
Share on other sites
I''ve had a similar problem with that particular listing, it doesnt crash the machine though...
Other than that I am very pleased with the rest of the book.

If you want to see more in-depth examples of SDL and OpenGL working together
check out the SDL ports of the NeHe demos, just go to www.libsdl.org/opengl/intro.html
they are written in C and I think they have up to Lesson 30 included. after 30 You have to
look under the demos for the various ports. They all compile without a problem and show
up as they should on screen.


Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!