Results 1 to 3 of 3

Thread: GL_POINTS array issue

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    1

    GL_POINTS array issue

    I have an issue that has been giving me fits trying to debug, and am hoping someone here can help me locate the problem.

    I am working on a game with some explosions that are made up of two parts:

    1) A 2D polygon "card" for a bitmapped explosion graphic
    2) An array of single-pixel points making up a particle system of "sparks" flying out from the explosion.

    The view I'm rendering is out the front of a spaceship, and as the player steers, I am rotating the elements outside the window in my own code,with my spaceship always at 0,0,0 and looking out along the negative Z axis.

    So let's say I set off an explosion. I create two elements in my data, one for the bitmapped vapor cloud and one for the particle system. Both have the same XYZ coordinates. Both initially appear in the same location on the screen.

    Each explosion's particles are stored as an array of 3D points, all relative to the particle system's centerpoint. Each particle has its own position and vector, which is updated elsewhere and works fine. The plan here is that setting the transform to the center of the explosion would plot all the particles relative to that point on the screen, with the proper 3D transform handling the transformations of all the particles.

    Here is the code which draws the particles:

    Code :
    for(int i = 0; i < thePExplosionObjects->active; ++i) {
      glLoadIdentity();
      glTranslatef(thePExplosionObjects->pos[i].x, thePExplosionObjects->pos[i].y, thePExplosionObjects->pos[i].z);		// Positions the object
      glVertexPointer(3, GL_FLOAT, 0, thePExplosionObjects->particles[i]);	// And just point to the coordinate table!
      glDrawArrays(GL_POINTS, 0, thePExplosionObjects->pcount[i]);		// BAM! n points of debris plotted!
    }

    And here is the code that draws the bitmapped vapor clouds on 2d cards:

    Code :
    PlanarElement &amp;theElement = thePlanarElements.elements[index];
    glVertexPointer(3, GL_FLOAT, 0, theElement.vertices);
    glBindTexture(GL_TEXTURE_2D, theElement.texture);
    glTexCoordPointer(2, GL_FLOAT, 0, theElement.texcoords);
    glColor4ub(theElement.brite, theElement.brite, theElement.brite, theElement.brite);
    glLoadIdentity();
    glTranslatef(theElement.where.x, theElement.where.y, theElement.where.z);		// Positions the object  
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

    The problem comes when I start steering around. As the ship steers (any axis), the particle system falls behind the bitmapped card -- Even though they are using the same transform (a simple translate to where they are located), and I have triple-checked to be sure that they are at the exact same 3D coordinates. I put in debug prints to the system log and the coordinates being fed to OpenGL are identical.

    I even went in and simplified the particle system down to one point fixed at 0,0,0 within the particle system and that does the same thing -- It's almost as if the drawing of the points array is scaled differently somehow, despite the fact that I reset the transform to identity prior to the call.

    Is there a reason why the drawing of a GL_POINTS array would not end up in the same place onscreen as a 2d card that was transformed to the exact same point in space? Are GL_POINTs not scaled the same way as the 2d card? I've been looking through all the documentation I can find, and cannot locate anything that says the GL_POINTS are treated any differently than any other element in OpenGL.

    Any suggestions appreciated!

  2. #2
    Senior Member Regular Contributor
    Join Date
    Dec 2008
    Location
    USA
    Posts
    134

    Re: GL_POINTS array issue

    If it's possible, I would render the points and the vapor cloud together, something like this:

    Code :
    glPushMatrix();
    glTranslate(x,y,z) // translate to center of explosion
    drawVapor();
    drawPoints();
    glPopMatrix();

    drawPoints() would draw the particles using the coordinates relative to the center of the system, as would the 2d cards. I'm not entirely sure why what you're doing doesn't work, but rearranging it slightly may fix something or reveal the problem.

  3. #3
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: GL_POINTS array issue

    The problem comes when I start steering around. As the ship steers (any axis), the particle system falls behind the bitmapped card
    "the particle system falls behind", can you elaborate more on this? Perhaps some screenshots or videos may be helpful.

Similar Threads

  1. Replies: 12
    Last Post: 01-29-2013, 01:09 AM
  2. Vertex attributes array issue
    By Zengar in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-06-2003, 07:49 AM
  3. Vertex Array Issue??
    By dabeav in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-13-2002, 04:56 AM
  4. Vertex Array Speed issue
    By satan in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-30-2002, 12:36 AM
  5. GL_POINTS
    By in forum OpenGL: User Software
    Replies: 1
    Last Post: 02-15-2000, 09:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean