Tralfas,
What is your problem exactly? Cannot compile the code, or the screen is not green?
I believe you have the minimal code enough to run. But there are some errors in it. For example, the function must be declared with a return type, and C++ is case sensitive.
And OpenGL headers are usually placed under “GL” sub directory. For example your include look like this; #include <GL/gl.h> #include <GL/glut.h>
sorry i should have posted what the problem was. i cant compile and i tried the new include files but it still didnt compile although i think it knocked off a couple errors. here are the errors i am recieving.
2 C:\Dev-Cpp\OpenGL.cpp
In file included from C:/Dev-Cpp/OpenGL.cpp
43 C:\Dev-Cpp\include\GL\glut.h
redeclaration of C++ built-in type `wchar_t’
6 C:\Dev-Cpp\OpenGL.cpp
ISO C++ forbids declaration of `RenderScene’ with no
C:\Dev-Cpp\OpenGL.cpp
[Warning] In function `int RenderScene()’:
7 C:\Dev-Cpp\OpenGL.cpp
`glclear’ undeclared (first use this function)
[Build Error] (Each undeclared identifier is reported only once for
8 C:\Dev-Cpp\OpenGL.cpp
`glflush’ undeclared (first use this function)
/Dev-Cpp/OpenGL.cpp C:\Dev-Cpp\C
At global scope:
12 C:\Dev-Cpp\OpenGL.cpp
ISO C++ forbids declaration of `SetupRC’ with no type
C:\Dev-Cpp\OpenGL.cpp
[Warning] In function `int main()’:
19 C:\Dev-Cpp\OpenGL.cpp
`GLUTDisplayFunc’ undeclared (first use this
those are all the errors i get when i try to compile.
Tralfas,
Line #6 and #12 are about function return type. Put “void” at the front of function name if it does not have return value. They must be;
void RenderScene(){…}
void SetupRC(){…}
Line #7, #8 and #19 are about incorrect upper/lower case, because C/C++ is case sensitive language. The correct names of those functions are glClear(), glFlush(), and glutDisplayFunc().
I am also using Dev-C++, but I have never encountered with “wchar_t” redeclaration error. However, I have seen many people have this error. Try to include glut.h header only, and link glut library first in linker option, for example,
-lglut32 -lglu32 -lopengl32
wow thanks for all the help i fixed all the code and then it still didnt work so i went into the dev c++ library folder. i had three folders in there one called glut, gcc-lib and glut.n32 and apparently the folders gcc-lib and glut.n32 all have to be in the glut folder.
omg i give up. i realized that the compiler didnt work even if it wasnt opengl. so i went to the website downloaded the newest version of dev c++. i got it working and ive got the program down to 2 errors.
1 C:\Dev-Cpp\OpenGL.cpp In file included from C:\Dev-Cpp\OpenGL.cpp
43 C:\Dev-Cpp\include\GL\glut.h redeclaration of C++ built-in type `short’
and i cant figure out why i have this because i didnt switch any folders around and i linked everything properly.
Please learn how to use your compiler before posting questions. This is very basic programming stuff, and doesn’t belong in these forums. “Beginner” means beginning OpenGL, not programming.
ok i followed all the steps and it worked. but then i made a new source file and put the code in. now i have linker errors. heres an example-
[Linker error] undefined reference to `glClear@4’
did i miss something?? thanks for your help i appreciate it a lot!!!