PDA

View Full Version : glList inside a procedure of an object..



jrbcast
03-26-2002, 08:19 AM
Hi

Imagine Ive designed a Sphere class which sometimes I want to draw on my screen. for that purpose Ive 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

Jeeeez
03-26-2002, 06:32 PM
Sure, just make sure you instantiate the object after you initialize opengl and make the rendering context current

jrbcast
03-27-2002, 09:54 AM
Thanks, Im not sure but I think you gave me the answer.

Im 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 isnt it :-)) so:

Constructor:

viewerOGL(){
initializeGL();
}

initializeGL(){
.
set_perspective()
set_clear_color()
.
.
camera->set(); <-- Problem,matrix not updated
}


Should initialization be done outside that object?. If so I dont know how to make a proper class design for my 3D engine :-(.

Thanks.

Furrage
03-27-2002, 10:31 AM
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...

1) You don't create/initialise objects until after OpenGL is initialised.

2) 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.