PDA

View Full Version : OpenGL Global Variables



Vortex
03-01-2012, 06:13 AM
Hello. I've just started C++ not long ago and only know some basics on OpenGL. I was taught to use global variables to animate( rotate, translate, ... ) the scene in glutDisplayFunc(MyDisplay) by changing the variables in other part of the program. So, I know global variables have it's disadvantages so i was wondering how to go around doing it without global variables ?

ZbuffeR
03-01-2012, 06:40 AM
The way glut works, you need global variables, because you can't pass variables to MyDisplay.
It can even be a single global var, holding a struct with all the details needed to draw the display.

Vortex
03-01-2012, 06:51 AM
So if i don't wanna use global variables, what do you suggest ?

ZbuffeR
03-01-2012, 07:43 AM
I am partial to GLFW : http://www.glfw.org/index.html

menzel
03-01-2012, 11:27 AM
+1 for glfw

Alfonse Reinheart
03-01-2012, 12:34 PM
Though sadly, GLFW does not (yet) have a way to create an sRGB framebuffer.

Vortex
03-01-2012, 10:18 PM
Okay! I will read about it thanks!