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: Scaling for polygon overlay

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2010
    Posts
    22

    Scaling for polygon overlay

    Hi

    I have a polygon in 3d space and I want to draw an overlay on this polygon,I need to draw an overlay polygon about few pixels bigger than the polygon itself otherwise I won't see it.Easiest would be to scale it by about 1.2.
    But how to calculate the coordinates for the new scaled polygon.
    For each vertex if original coordinates were x,y,z what would be new x,y,z??

    Well one solution is to find the center of the polygon and then to move each vertex acoording to the direction vector from polygon center.But this is painful - any simpler solutions?

    Thanks a lot in advance

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    2,882

    Re: Scaling for polygon overlay

    Quote Originally Posted by StuckInBorland
    I have a polygon in 3d space and I want to draw an overlay on this polygon, I need to draw an overlay polygon about few pixels bigger than the polygon itself otherwise I won't see it.Easiest would be to scale it by about 1.2.
    That solution is possible but aesthetically probably not ideal because you will see different X/Y deltas depending on where you are relative to the "scaling center".

    Usually what's done is to just draw on top of the existing shape, either by disabling depth test, or using something like glPolygonOffset to shift the shape slightly closer to the eye while still sending the same vertex positions down the pipe. Then you don't need to handle the tweaks to make this happen.

    Before you draw the overlay, try doing this:

    Code :
        glEnable( GL_POLYGON_OFFSET_FILL );
        glPolygonOffset( scale,  offset );
    Then merely send the overlay down the pipe without any vertex position modifications.

    See:
    * http://www.opengl.org/resources/faq/...ygonoffset.htm

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2010
    Posts
    22

    Re: Scaling for polygon overlay

    Thanks!!

    I forgot about polygon offset...After you reminded me it solved another issue I had.But regards polygon overlay I'm thinking to do decals since seems that offset is not enough

Posting Permissions

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