I want to do some graphics programming with gcc, and am wondering which is the best graphics libary to use.
Cheers Mick
I want to do some graphics programming with gcc, and am wondering which is the best graphics libary to use.
Cheers Mick
C standard library != graphics library. You already have a c standard library, most of your system depend on it. For graphics library check SDL for 2D and OpenGL for 3D. If you want to write GUI, read about Qt (C++, used by KDE) or Gtk (C, used by Gnome, pain in arse).
I used synaptic to download libsdl1.2-dev and tried to compile a sample file, but the headers were not recognised.
:|
Cheers Mick
Are the headers located in some directory which is in your include path?
There is a pretty good guide for setting up and creating a simple test program at lazyfoo.net.
Just skip the part about downloading and installing the rpm since you have already installed the deb.
If your using automake && autoconf
Then just copy
to your Makefile.amCode:<insert_var_here>_LDADD = -lSDL
I believe SDL is a C++ API.
If you want to use C, just use openGL (which is the 3D graphics part of SDL) with "glut".
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
Nope, it's a C graphics API, so you can use it with C or C++.
Well, okay, I meant freeglut, since yes, the original glut is defunct. I've used it with all the standard docs that refer to glut (inc, eg, the OGL superbible, AND the red book). It is maintained and it works perfectly. I believe everything that was in glut is in freeglut*, I've seen this stated a number of times and never heard anything to the contrary, so you are are full of tish on this. If you go to the official openGL forum and make this claim, you will get laughed off the page. Sorry. Freeglut is widely used, and it functions identically w/r/t any documentation that includes glut (which is most or all OGL documentation for beginners).
@mickpc: you need to use linker flags, eg for OGL/glut:
gcc test.c -lglut -lGLU -lGL -lXext -lX11 -lm
Maybe some nice person will post the flags for SDL; if not I am sure they are on page one of the intro tutorial or whatever...
* in any case, IMO you might as well keep your use of glut to a minimum; all it has to do is manage a window and an event loop. This way, when you want to really polish up and handle your own loop and window management, you will not find you have written something that involves a lot of higher-level functions from a secondary toolkit. The point of glut is just to allow you to do pure OpenGL programming easily. It is not to add a whole bunch of features like sound effects or whatever. It is a "low level" approach vs. the "high level" of SDL, which is it's own thing that potentially includes OGL -- whereas glut doesn't do anything except provide a cross-platform for OGL. It is and should be minimal. I have nothing against SDL, just this is apples and oranges. AFAICT (I have written a simple patch for tuxpaint, which is an SDL kid's game), you can do all kinds of stuff with SDL that really have absolutely nothing to do with 3D graphics programming.
Last edited by MK27; 09-28-2009 at 12:23 PM.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
kennedy != graphics programmer PERIOD!!!
. . . but, I thought that GTK was considered the "standard"?
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
SDL is written in C, but it has bindings for frigging many languages. But basically it's a C library.
GTK is "standard" widget toolkit on GNU, because it's used by GNOME.
Portable graphics programming => SDL with OpenGL.
Non-portable graphics programming for Unix-likes => Xlib, GLX, GLUT or whatever you want.
Portable GUI => if you want C++, Qt, if you don't, just do it or suffer.
Qt is not the only portable C++ gui toolkit. I use wxWidgets almost exclusively for gui stuff, and it's everything I need and more. it includes OpenGL stuff as well, and is certainly worth looking into if you want a truly cross-platform gui toolkit with OpenGL capability.
Actually GTK is cross-platform as well. AFAIK, glut is not tho [edit: wrong]. The GTK openGL extension does not appear to use glut.
Last edited by MK27; 09-28-2009 at 12:24 PM.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge