You are not logged in.
Pages: 1
I found a Nene Tutorial for opengl on his website. he has written a tutorial on learning OPENGL. however, his tutorials cover opengl in windows environments, not linux. therefore, he doesn't go through the steps of creating the developing environment for OPENGL.
he has an example that is easy (example1), the code is simple, probably just 20 lines or so. however, when i compile with gcc, i get errors. i'm in school right now, not at home so i can't remember what I typed. my question is just this:
what packages and sources do I need to compile opengl source?
-mesa?, glut? (btw, what is glut? i read descriptions but i just can't understand.)
if anyone has had experience compiling opengl source code, what are the arguments *generally* given to gcc?
Offline
It's probably best to use something like SDL.
Offline
gcc -o file -Wall -lglut -lGL -lGLU file.c
the GL headers should be there with X
Offline
to i3839:
if i use SDL, i probably need to rewrite the code, right?
to phrakture:
i used the command that you supplied. when i run it as:
gcc -o example1 -Wall -lglut -lGL -lGLU open1.c
i get:
/usr/bin/ld: cannot find -lglut
collect2: ld returned 1 exit status
i ran ldconfig as root and i still got the same error.
my system:
gcc 3.4.3-1
2.6.10-ARCH
Offline
to phrakture:
i used the command that you supplied. when i run it as:gcc -o example1 -Wall -lglut -lGL -lGLU open1.c
hmm, well you only need lib flags for the libraries you're using... are you using glut? (probably not, I never have) try just -lGL and -lGLU
Offline
to i3839:
if i use SDL, i probably need to rewrite the code, right?
You probably need to do that anyway, but mostly the init stuff like getting a graphical context and opening a window etc.
Offline
ovihc wrote:to i3839:
if i use SDL, i probably need to rewrite the code, right?You probably need to do that anyway, but mostly the init stuff like getting a graphical context and opening a window etc.
Writing in OpenGL or SDL doesn't matter - use what you want...
Offline
As far as I know, SDL doesn't replace anything from the OpenGL API, it just adds general functionality which is needed anyway and platform specific, like opening windows, configuring a graphical context, sound, mouse/keyboard input, etc. and other things not done by OpenGL.
The question is wether to use SDL or Glut, if the example code uses glut anyway, which is unclear.
Offline
For the record, there are NeHe tutorial for Linux/SDL as well. For example:
http://nehe.gamedev.net/data/lessons/li … n02.tar.gz
Dusty
Offline
i'm reading the OPENGL RED BOOK. all their examples use GLUT.
for example:
/*
/*
* hello.c
* This is a simple, introductory OpenGL program.
*/
#include <GL/glut.h>
void display(void)
{
/* clear all pixels */
glClear (GL_COLOR_BUFFER_BIT);
/* draw white polygon (rectangle) with corners at
* (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)
*/
glColor3f (1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glVertex3f (0.25, 0.25, 0.0);
glVertex3f (0.75, 0.25, 0.0);
glVertex3f (0.75, 0.75, 0.0);
glVertex3f (0.25, 0.75, 0.0);
glEnd();
/* don't wait!
* start processing buffered OpenGL routines
*/
glFlush ();
}
void init (void)
{
/* select clearing color */
glClearColor (0.0, 0.0, 0.0, 0.0);
/* initialize viewing values */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}
/*
* Declare initial window size, position, and display mode
* (single buffer and RGBA). Open window with "hello"
* in its title bar. Call initialization routines.
* Register callback function to display graphics.
* Enter main loop and process events.
*/
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (250, 250);
glutInitWindowPosition (100, 100);
glutCreateWindow ("hello");
init ();
glutDisplayFunc(display);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
then i type in:
gcc -o hello -Wall -lglut -lGL -lGLU hello.c
RESULT:
/usr/bin/ld: cannot find -lglut
collect2: ld returned 1 exit status
then i type in:
gcc -o hello -Wall -lGL -lGLU hello.c
RESULT:
/tmp/ccGHDkOj.o(.text+0x15c): In function `main':
: undefined reference to `glutInit'
/tmp/ccGHDkOj.o(.text+0x168): In function `main':
: undefined reference to `glutInitDisplayMode'
/tmp/ccGHDkOj.o(.text+0x17c): In function `main':
: undefined reference to `glutInitWindowSize'
/tmp/ccGHDkOj.o(.text+0x190): In function `main':
: undefined reference to `glutInitWindowPosition'
/tmp/ccGHDkOj.o(.text+0x19c): In function `main':
: undefined reference to `glutCreateWindow'
/tmp/ccGHDkOj.o(.text+0x1ad): In function `main':
: undefined reference to `glutDisplayFunc'
/tmp/ccGHDkOj.o(.text+0x1b2): In function `main':
: undefined reference to `glutMainLoop'
collect2: ld returned 1 exit status
then i type in:
gcc -o hello -Wall -lGL hello.c
RESULT:
/tmp/ccay73p0.o(.text+0x15c): In function `main':
: undefined reference to `glutInit'
/tmp/ccay73p0.o(.text+0x168): In function `main':
: undefined reference to `glutInitDisplayMode'
/tmp/ccay73p0.o(.text+0x17c): In function `main':
: undefined reference to `glutInitWindowSize'
/tmp/ccay73p0.o(.text+0x190): In function `main':
: undefined reference to `glutInitWindowPosition'
/tmp/ccay73p0.o(.text+0x19c): In function `main':
: undefined reference to `glutCreateWindow'
/tmp/ccay73p0.o(.text+0x1ad): In function `main':
: undefined reference to `glutDisplayFunc'
/tmp/ccay73p0.o(.text+0x1b2): In function `main':
: undefined reference to `glutMainLoop'
collect2: ld returned 1 exit status
however, i tried the nehe tutorial that uses sdl, and it works perfectly!!
am i stuck with SDL(not a bad thing of course)?
-am i typing in the wrong GCC command?
-what are the differences in sdl and glut? is sdl better? would it help me -more to learn sdl instead of glut?[/b]
Offline
SDL is better than glut, but that's just opinion... the compilation is failing because it can't find glut... try a "pacman -Ss glut" and see if it's a seperate package (I don't know if it is...)
Offline
SDL is better than glut, but that's just opinion... the compilation is failing because it can't find glut... try a "pacman -Ss glut" and see if it's a seperate package (I don't know if it is...)
glut is a separate package, yes.
Offline
Pages: 1