PDA

View Full Version : glut my but (don't work) (few other questions also)



colinisinhere
06-13-2002, 09:55 AM
I am useing Dev-C++... and i have glut.h... but when i run this code it say that all my functions are undefined.



#include <GL/glut.h>
#include <stdlib.h>

void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);

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();
glFlush();
}

void init(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}

int main(int argc, char** argv)
{
glutInit(&amp;argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_ RGB);
glutInitWindowSize(250, 250);
glutInitWindowPosition(100, 100);
glutCreateWindow("hello");
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}

please help

yakuza
06-13-2002, 10:18 AM
I'm guessing you haven't linked glut32.lib

colinisinhere
06-13-2002, 12:47 PM
i tried that and it still doesnt work.

secnuop
06-13-2002, 04:32 PM
Which functions does it say are undefined -- the gl ones or the glut ones? Does it complain at link time or at compile time?

I can see two possible problems -- it either can't find glut.h, or you may have forgotten to link against opengl32.lib.

Armageddon
06-13-2002, 11:53 PM
I don't use Glut so I could be wrong..

Does GLUT Include gl.h? If not, then I'd say thats your problem..

Try including <gl/gl.h> and <gl/glu.h>

and linking to opengl32.lib and glu32.lib

Hope this helps

Deiussum
06-14-2002, 04:18 AM
Doesn't Dev-C++ use .a files instead of .lib files?

In any case, I think to add the libraries, somewhere you need to add -lGL -lglut -lGLU to the command-line parameters that Dev-C++ uses. I haven't used Dev-C++ much myself, so I can't tell you exactly where that goes, offhand. http://www.opengl.org/discussion_boards/ubb/smile.gif

mikael_aronsson
06-14-2002, 04:26 AM
Hi !

The latest versions of MinGW32 can use .lib files without problems, but older ones need .a files

Mikael

colinisinhere
06-14-2002, 07:46 AM
ok... should i use glut or should i do it with windows API?

And what format of 3d objects does opengl mainly use? .obj? If so... is there an .obj texture program around... thanks

colinisinhere
06-14-2002, 07:51 AM
And the compiling... it just says that names all the functions and says they are undefined.... i have tried everything

Deiussum
06-14-2002, 08:55 AM
OpenGL has no support for any given file format. You have to do that on your own or use a 3rd party library.

The errors you are getting are likely linker errors, which means that you haven't included the library to be linked into the project. Since you haven't copy/pasted the exact error, this is just an educated guess, though.

As I said above, to link a library in you need to find out where to do that in the Dev-C++ project settings. Contrary to the belief of many new programmers, #include does not add a library, but just supplies a header file. (In the case of VC++ and Borland, however, there are #pragma statements that can be used to link in a library, however. Not sure of any equivalent for Dev-C++ off hand, though.)

colinisinhere
06-14-2002, 12:23 PM
Yea... i know... i can't copy/paste the error with dev-c++. i am not a new programmer... i know the basic c++ console stuf and allegro but i want to get in 3d stuff... wher do you think i should start?

colinisinhere
06-16-2002, 01:03 PM
no one want to help?

Armageddon
06-16-2002, 02:23 PM
Theres not much anyone can say to help, without more information. If you can't copy and paste, give us an example (type it by hand) of the error. If the error is the always the same (with different filenames), give the error once and a list of the filenames.

Sorry I couldn't be of more help.

Gavin
06-17-2002, 03:52 AM
And at no point does it say can't find file glut.h?