PDA

View Full Version : colored screen



Tralfas
04-20-2006, 04:33 PM
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++

songho
04-20-2006, 06:24 PM
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>

Tralfas
04-21-2006, 09:52 AM
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.

songho
04-21-2006, 12:58 PM
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

Tralfas
04-22-2006, 07:31 AM
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 :) :)

Tralfas
04-22-2006, 07:35 AM
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

04-22-2006, 12:59 PM
anyone know what might be wrong

jide
04-22-2006, 01:03 PM
If you could explain exactly what you have, someone might tell you what's wrong.

Tralfas
04-22-2006, 04:55 PM
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.

Tralfas
04-22-2006, 08:08 PM
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.

04-22-2006, 08:17 PM
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

Tralfas
04-22-2006, 10:15 PM
**** you it pretains to opengl dumbass

songho
04-23-2006, 12:04 AM
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.

Tralfas
04-23-2006, 12:53 AM
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!!!!