Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: OpenGL primitive as a c/c++ Class ?

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2008
    Location
    New-Zealand
    Posts
    18

    OpenGL primitive as a c/c++ Class ?

    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!
    Cheers,
    Thibault.
    What?

  2. #2
    Member Regular Contributor Rosario Leonardi's Avatar
    Join Date
    Aug 2008
    Location
    Italy
    Posts
    352

    Re: OpenGL primitive as a c/c++ Class ?

    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:

    Code :
    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.
    ~ ~ I tell you, realtime 3D is made of blood, sweat and screams! ~ ~

  3. #3
    Junior Member Newbie
    Join Date
    Nov 2008
    Location
    New-Zealand
    Posts
    18

    Re: OpenGL primitive as a c/c++ Class ?

    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 !
    Thanks !
    What?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •