Sign in to follow this  
bluknight

Setting up OpenGL, GLUT, and SDL in Dev-C++

Recommended Posts

Hi, I currently have dev-c++ installed on my computer. I don't know how to set it up to use the opengl, glut, and sdl libraries. Are there any tutorials any of you know of that could help me? Or do you know yourself? I also need to know how to make sure the libraries work and are included when I try to compile. I've used opengl before, and I remember something about needing to link to it in the compiling options or something... I'm not sure if I have to do the same thing with the other two, and I don't exactly remember what it was for opengl either. Any help would be greatly appriciated.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I'm not entirely sure what SDL is capable of... I know glut can make windows, and I was planning on using glut to initiate the windows, opengl to draw stuff and render the scene... and sdl to do sound, and i think it's got some libraries for internet capabilities and such...

Share this post


Link to post
Share on other sites
Go to Project | Settings. Find the Link tab. Look for the line with all the '.lib' entries and add glut32.lib (or maybe it is just glut.lib, I don't recall right now).

#include <GL/glut.h> in your code, it will include the normal gl headers, and even auto-link the other needed gl libs.

Share this post


Link to post
Share on other sites
To use SDL you have to link
-lmingw32 -lSDL_main -lSDL

and if you use additional libraries you have to include those too.
I'd look at the documentation of all the libraries.
Maybe use GLFW instead of GLUT. There are some good tutorials.

Also check if there are DevPaks for the libraries that you want.
It makes installing them easier.

You shouldn't use all of them together. You can use SDL alone for 2D stuff.
Or OpenGl combined with either SDL or GLFW or GLUT for 3d stuff.

That is just my personal opinion, but: using SDL in combination with OpenGl is weird.

Share this post


Link to post
Share on other sites
as i said before... the reason for SDL is not for graphics. I was planning on using the audio/input/internet parts of sdl...

The main problem I'm having with installing this stuff is I don't know which files go where, or what file types i need and everything...

Share this post


Link to post
Share on other sites
Quote:
Original post by Clueless
That is just my personal opinion, but: using SDL in combination with OpenGl is weird.


What makes you say that ? I've been using SDL and OpenGL together in all my projects and they work perfectly fine, under both Windows and Linux (as they're the two OSes I'm compiling for).

Plus there's a framework on Nehe's site you can use right out of the "box".

Share this post


Link to post
Share on other sites
The documentation of a library ALWAYS explains how it can be installed.
You can't ask how to install a certain library every time you want to use one.
There are the developer files that you need if you want to use the api for your own projects ...
and there are the runtime libraries that you need to run programs developed with the library.

The runtime libraries are DLLs. You have to put them into the folder with your exe file.

The developer stuff is mostly in lib and include folders.
You can put the content in the lib and include folders under you dev c++ path.

For each of the libraries you have to add something to the linker parameters in your projects.
If you want to use SDL ... as I said: -lmingw32 -lSDL_main -lSDL
If you want to use GLFW: -lglfw -lopengl32 -lglu32
If wendigo23 is correct, then maybe for GLUT: -lglut32
If you want to use audiere: -laudiere
...

I won't write what header files you have to include for all the libraries.
Try to figure out which you have to include.
It is just important that your project "knows" the include path.
So if there is a folder SDL under the dev-c++ include path you should either use #include <SDL/SDL.h>
or add the whole path to SDL.h to the "globally known include directories".
Then you only have to write #include <SDL.h>
...
If there are still any SPECIFIC question, just ask.

Trexmaster:
Using such a huge library for input, timing and maybe sound just seems weird to me.

Using audiere and glfw feels right. Maybe partly because of the licence!?
I want to create a simple engine as a static library for example.
If I'd use SDL it would be a lot more restrictive.

Using SDL for loading images ... having to convert from surface to texture ...
Not sure how to explain it. It is just strange IMO.

Share this post


Link to post
Share on other sites
Ok, here's an example of my problem...

For glut, i have three files that i believe i need for compiling, and I've also got a .dll file that i know i need to be with the exe.

glut32.lib
glut.h
glut.def

There are two folders, Lib and Include. I assume the files need to go in those two...

glut.h should go in the include judging by the types of files in there, but in the lib folder there are two types. .a and .def so that takes care of one more, but I still don't know where to put glut32.lib

...

I think .a is a special format for dev-c++ or something, but I'm not sure, and this is where much of the confusion comes from.

...

"If I'd use SDL it would be a lot more restrictive"
What do you mean?
I never really understood the license thing of SDL...

Share this post


Link to post
Share on other sites
.a is a static library in Dev-C++.
.lib doesn't work with Dev-C++.
You might have to compile the source ...

But are you sure that -libglut32.a isn't already in the lib folder?
And look under include ... what files are under the "GL" subfolder?

There are many threads about the SDL and LGPL ... can't summarize it right now.
I want to release my engine under the MPL 1.1 and I'm pretty sure that is not possible if I use LGPL libraries.

Btw ... there is a cool ... I mean entertaining ... LGPL thread.
http://www.gamedev.net/community/forums/topic.asp?topic_id=228090

Share this post


Link to post
Share on other sites
glut does in fact come standard with dev-c++, but right now i'm just trying to figure out hwat file type goes where, and what i need to do to install a library, glut just happened to be the first one i saw the zip of, so i decided to use it for the example...

Anyways, so I need to get .a files? I can't use the .lib?

How do I compile the libraries?
I think this is really what I've needed to know this whole time.

edit: Yeah that is kind of entertaining... I'm still slightly confused about the terms of that license... And that guy is really dense.

Share this post


Link to post
Share on other sites
Having to compile the library if you don't change anything should be the exception.
I always start cursing when I can't find .a libraries or DevPaks.

To compile GLFW for example I had to mess with the command line.
HORRIBLE.
There is no general answer ... well maybe the above:
libs in lib directory, public headers in include or a subfolder of include, starting a new project, adding the libs to the linker parameters, including the needed header(s) and if that doesn't help reading the documentation.
Maybe you can use the DLLs though ... maybe you don't have to work with static libraries.

I think some people were talking about a converter from lib to a ...
that was for the DirectX SDK though. Not sure if that is really an option in general.

Anybody knows more about licenses than I do? Correct me if I'm wrong, guys:

GPL says that you have to make your project open source and release it completely under the GPL!?

LGPL says you can make it closed source when you don't use a static library.
Only if the library is a dynamic library it can be relinked ...
I guess!

Zlib says that you just musn't claim that you made the library.

Mpl 1.1 means that you can use a static library as well as a dynamic library.
If you make any changes to the library you have to make them public though. Not the whole code.

It is more complicated and some points might not be quite correct.

Share this post


Link to post
Share on other sites
The result of using a static library is that your executable file gets bigger,
but you don't have to release your program with runtime libraries (DLLs).
I can't give a more technical explanation. Sorry.

Share this post


Link to post
Share on other sites
well how do you do it in the code?

edit: and wouldn't it make your program a lot more secure to statically link opengl or something? so then people can't compile the dll with cheats programmed in?

Share this post


Link to post
Share on other sites
Why don't any competent people reply here?

The code is pretty much the same ...
but the project was compiled as a static or dynamic library.
If you are using the libraries it is pretty similar too.

You won't compile OpenGl. OpenGl runtime stuff comes with the drivers for the hardware.
If you use OpenGl (include headers and add the OpenGl32 and Glu32 libraries to the linker) you still can't mess with OpenGl itself.
And you don't distribute it with the game. Your game will assume that people who want to run it have the OpenGl runtime stuff.

You are correct that static libraries might be more secure. If you write or use a library that people can download, mess with and recompile. Then they'd have to recompile your game too.
With dynamic libraries they wouldn't have to.

But you can make the use of DLLs secure too. For example by not distributing the code of the dynamic libraries.

And every time you change a static library you have to recompile both library and game.
If you'd use DLLs wisely you can make the whole thing pluggable.
It adds flexibility.

But I'm no expert. Guys ... correct me if I'm wrong.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this