Imagine I´ve designed a Sphere class which sometimes I want to draw on my screen. for that purpose I´ve made a draw() procedure. I want to know If I can make a compiled list inside an object and draw It directly. I say so because sometimes when I call procedures from the window class located within the other objects they seem not to work properly with the OpenGL context (specially working with OGL matrices).
Thaks a lot
Sure, just make sure you instantiate the object after you initialize opengl and make the rendering context current
Thanks, I´m not sure but I think you gave me the answer.
I´m initializing my GL context inside the object which makes calls to other objects. It becomes initialized In the constructor. Imagine my visualization class is called viewerOGL (original isn´t it :-)) so:
camera->set(); <-- Problem,matrix not updated
Should initialization be done outside that object?. If so I don´t know how to make a proper class design for my 3D engine :-(.
Back to basics. With OpenGL gl Calls don’t work until OpenGL is initialised (i.e. you’ve gotten a valid rendering context). So when you are initialising your objects make sure you don’t make any OpenGL calls until after OpenGL initialisation. This gives you 2 options…
You don’t create/initialise objects until after OpenGL is initialised.
Initialise objects in two parts. The first part contains no OpenGL calls and can be done anytime. The second part contains all the OpenGL calls and does not get called until OpenGL is initialised.