colored screen

hi
ok so this program is supposed to make a blank window of some color in this case green for some reason it doesnt work can any help

#include <gl.h>
#include <glut.h>
using namespace std;

RenderScene(void)
{
glclear (GL_COLOR_BUFFER_BIT);
glflush();
}

SetupRC(void)
{
glClearColor(0.0f, 1.0f, 0.0f, 0.0f);
}
int main()
{
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutCreateWindow(“simple”);
GLUTDisplayFunc(RenderScene);

SetupRC();
glutMainLoop();

return 0;
}
i put the two include files in the include folders and put the librairies in. im using dev c++

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.

thanks :slight_smile: :slight_smile:

wow that celebration was shortlived. i can compile the file but now when i try to run it it says sourcefile not compile!!! what is going on.

opengl vs tralfas and opengl wins

anyone know what might be wrong

If you could explain exactly what you have, someone might tell you what’s wrong.

ok this is what i have

 #include <gl.h>
#include <glut.h>
using namespace std;

void RenderScene(void)
{
glClear (GL_COLOR_BUFFER_BIT);
glFlush();
}

void SetupRC(void)
{
glClearColor(0.0f, 1.0f, 0.0f, 0.0f);
}
int main()
{
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutCreateWindow("simple");
glutDisplayFunc(RenderScene);

SetupRC();
glutMainLoop();

system ("pause")
return 0;
}  

dev c++ compiles it but it wont let me run it. when i hit run it says Warning- source file not compiled.

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.

Thanks

**** you it pretains to opengl dumbass

Tralfas,
I think you still have the redeclaration error with Dev-C++ and GLUT.

Here is how I use GLUT in Dev-C++. Please uninstall Dev-C++ first and follow the following steps:

  1. Install Dev-C++.
  2. Install glut.3.7.6+.DevPak from http://www.nigels.com/glt/devpak/ . (the 2nd one)
  3. Open Dev-C++ and start a new project.
  4. Select “Multimedia” tab (the next of “basic”) from “New Project” window.
  5. Select “glut” template and put the project name then click “ok”.
  6. Compile the example code and run it.

If you can compile and run it successfully, configuring GLUT on Dev-C++ is done. Let me know if you still encounter redeclaration error.

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!!!