PDA

View Full Version : newbie question



finch
03-02-2001, 01:17 PM
I JUST got started learning OpenGL whith the red book and I'm having problems with animation.

I can't get glut double buffer to work. When I try to write a program double buffered, everything that I display is red, there are no other colors. Also it's not really double buffering.

Can anyone think of what I'm doing wrong just off of the top of their head from those symptoms?

I appreciate your help.

Tim Stirling
03-03-2001, 08:52 AM
search through the entire project to see if any code anywhere could turn it red, mainly just the glColorf, glClearColor and material color.

finch
03-03-2001, 09:36 AM
If I just change the buffer to single, the color is fine.

finch
03-03-2001, 01:51 PM
Nevermind, I figured out my problem.
For those curious, I was writing
glutInitDisplayMode(GLUT_DOUBLE | | GLUT_RGB);
instead of
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
because I am used to coding in C++.
(I know, I'm a tard)

Could anyone tell me what type of translations I would need to make in order to get an OpenGL code to compile in a C++ project? This would make life a lot easier for me.

rts
03-03-2001, 02:31 PM
Since C is a subset of C++, and since OpenGL is an API in C, you don't need to do anything special to get OpenGL to work in C++. Just start compiling with g++ instead of gcc (or whatever your preferred C++ compiler is).

Hope this helps.

finch
03-03-2001, 04:10 PM
If I add the same source code to a C++ project, I get around twenty link errors that list functions in the gl and glut libraries and say that they're undefined symbols.

Oh, and I'm compiling with CodeWarrior.

Deiussum
03-03-2001, 05:04 PM
For those curious, I was writing
glutInitDisplayMode(GLUT_DOUBLE | | GLUT_RGB);
instead of
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
because I am used to coding in C++.


Using | | vs. | is not different between C++ and C. | | is a boolean operation, meaning you will get a simple true/false value. (0/1) Using | is a bitwise operator which means that all the bits will be or'd together to give you the value.

For instance..

0x1 | 0x2 == 0x3
0x1 | | 0x2 == 0x1

As to the linker errors, you probably need ti include the libraries in your project.