Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: Polygon 2D

  1. #11
    Junior Member Newbie
    Join Date
    May 2013
    Posts
    12
    I'm using with stencil buffer.

    Code :
    glVertexPointer(3, GL_DOUBLE, 0, data());
     
    		glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);
    		glDepthMask(GL_FALSE);
    		glEnable(GL_STENCIL_TEST);
    		glStencilFunc(GL_ALWAYS,0x1,0x1);
    		glStencilOp(GL_KEEP,GL_KEEP,GL_INVERT);
    		glDrawArrays(GL_TRIANGLE_FAN,0,size()); 
     
    		//Draw the triangle strip a second time but only where the stencil is one
    		glDepthMask(GL_TRUE);
    		glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
     
    		glStencilFunc(GL_EQUAL,0x1,0x1);
    		//NOT TESTED:  using GL_INVERT as the last parameter permit to clear stencil value to 0 where 
    		//stencil value is one and to draw multiple concave polygon in the same frame.   
    		glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP);
    		glDrawArrays(GL_TRIANGLE_FAN,0,size()); 
     
    		glDisable(GL_STENCIL_TEST);
     
    		//Desenha contorno
    		glColor3f(0,0,0);
    		glDrawArrays(GL_LINE_LOOP,0,size());

  2. #12
    Member Regular Contributor trinitrotoluene's Avatar
    Join Date
    Sep 2008
    Location
    Montérégie,Québec
    Posts
    362
    Can you put your vertices data on a hosting web site and put a link on this thread so I can test your data on my computer.

  3. #13
    Junior Member Newbie
    Join Date
    May 2013
    Posts
    12

    Points

    Quote Originally Posted by trinitrotoluene View Post
    Can you put your vertices data on a hosting web site and put a link on this thread so I can test your data on my computer.
    There is the points...

    https://docs.google.com/file/d/0B8B-...it?usp=sharing

  4. #14
    Member Regular Contributor trinitrotoluene's Avatar
    Join Date
    Sep 2008
    Location
    Montérégie,Québec
    Posts
    362
    I have tried your data and the algorithm with stencil buffer work as is. I think your problem is when you read your data in a file or when you pass the data to OpenGL. Check if the value of your points in the array is all valid.
    Last edited by trinitrotoluene; 05-31-2013 at 07:30 PM.

  5. #15
    Junior Member Newbie
    Join Date
    May 2013
    Posts
    12

    Mfc

    Quote Originally Posted by trinitrotoluene View Post
    I have tried your data and the algorithm with stencil buffer work as is. I think your problem is when you read your data in a file or when you pass the data to OpenGL. Check if the value of your points in the array is all valid.
    These points are my debug Trace from my point vector.

    Im using opengl with MFC window. Not using glut. May be some init parameter?

    Have some settings to gradient color?

    Because just setting color and drawvertex polygon it's painting with a gradient.

  6. #16
    Member Regular Contributor trinitrotoluene's Avatar
    Join Date
    Sep 2008
    Location
    Montérégie,Québec
    Posts
    362
    To test your data, I have computed the min and max for x and y. Then computed the mean value for both min max for each x,y and subtracted that value to each point. I do so because it easier to hardcode the value for the orthographic projection and I have read on this forum (but I don't remember well) that when you give large value for translatef, strange things can happen (Your vertices are far away the origin). When you call VertexPointer with GL_DOUBLE most if not all OpenGL implementations convert your data to GL_FLOAT type, but I don't think it will solve your problem.

    I never used MFC so I can't help for this.

  7. #17
    Junior Member Newbie
    Join Date
    May 2013
    Posts
    12

    Ortho

    Quote Originally Posted by trinitrotoluene View Post
    To test your data, I have computed the min and max for x and y. Then computed the mean value for both min max for each x,y and subtracted that value to each point. I do so because it easier to hardcode the value for the orthographic projection and I have read on this forum (but I don't remember well) that when you give large value for translatef, strange things can happen (Your vertices are far away the origin). When you call VertexPointer with GL_DOUBLE most if not all OpenGL implementations convert your data to GL_FLOAT type, but I don't think it will solve your problem.

    I never used MFC so I can't help for this.
    My ortho has the min and max x/y...

    I will try to do this, subtract the min x and y to each point. And set my ortho do 0 and width of the limit map.

    So I'll tell you what happened.

  8. #18
    Junior Member Newbie
    Join Date
    May 2013
    Posts
    12
    Trinitroluene, using glut it's working. Dammit! Thanks for all.

Posting Permissions

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