View Full Version : OpenGL primitive as a c/c++ Class ?

11-10-2008, 12:26 AM
Hello everybody!
I have not been able to find a topic about that so far...
I have a c++ class, which represents a room, and has 2 attributes : a GLUT window (the room), and a list of participants. I want to associate a GL_QUAD to each to each participant, ie in an ideal world each participant would have an attribute "GL_QUAD.
Is there any way of doing that?
It may be a stupid question, but it has just come to my mind, and I can't see how to do this..
Thanks for any help, any advice!

Rosario Leonardi
11-10-2008, 04:42 AM
With room do you mean a chat or a room with walls, doors, windows?
To draw a windows with some quad it's easy.
I think you can do something like that:

void room::draw(){
GLfloat *quadVector;

// you don't have to allocate this each frame ;)
quadVector = (GLfloat*)new GLfloat[numParticipant *4);
for(int i = 0; i < numPartecipant; i++)
participant [i].getQuadPoints(quadVector+i*4);

//here you can draw the quadlist with a vertex array

delete quadVector[];

the getQuadPoints fill the vector with the four vertex of the quad. Each participant should memorize his position, quad size.. bla bla bla. If you need more attribute (ie: vertex color) create another vector and ask the participant to fill it.

11-10-2008, 04:08 PM
Thank you Rosario, indeed a QUAD as a C++ object can simply be a 4-points vector. I guess I was in front of the screen for too long :D !
Thanks !