PDA

View Full Version : click 2d button to display object



gottijay
07-17-2011, 06:08 AM
hi guys,
I'm really very confused
need an idea or a simple example of how i could achieve this. i

click a button and i load/display first object.
click second button i load/display first and second object....that idea

i have something like this


void buttoncallback()
{
Draw3D();
}
void display(){/*
* Clear the background
*/
glClear( GL_COLOR_BUFFER_BIT |
GL_DEPTH_BUFFER_BIT );

/*
* Enable lighting and the z-buffer


/*
* Draw the 3D elements in the scene
*/
Draw3D();

/*
* Disable depth test and lighting for 2D elements
*/
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);

/*
* Set the orthographic viewing transformation
*/
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,winw,winh,0,-1,1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

/*
* Draw the 2D overlay
*/
Draw2D();

/*
* Bring the back buffer to the front and vice-versa.
*/
glutSwapBuffers();
}
main(...)
{
.......
glutDisplayFunc(Draw);
glutReshapeFunc(Resize);
.....
}

a short snippet would really help thank you