View Full Version : Triangle side is not straight line

MirzaSe

09-02-2014, 05:55 PM

I have application to draw thick lines. It is drawn using triangles. The problem is one side of triangle is not straight. This is the image showing the drawn picture:

1415

These are the vertices:

x 0.5

y 0.8500000238

x 0.5

y 0.150000006

x -0.1499999762

y 0.150000006

x -0.5

y 0.8500000238

x -0.8500000238

y 0.8500000238

x -0.8500000238

y 0.5 float

x -0.8500000238

y 0.5

x -0.1499999762

y 0.150000006

x -0.8500000238

y 0

x -0.150000006

y 0

And the indices: 0, 1, 2, 0, 2, 3, 4, 3, 2, 4, 2, 5, 8, 7, 9, 8, 7, 6

This does not happen only with these vertices, but also if I draw it with other vertices. I have no idea why since the y coordinate does not change.

Yandersen

09-02-2014, 07:35 PM

Did you tried to shake your monitor? Unless those specific numbers are cursed by an evil wizard, the information given is insufficient to find the problem. Reveal the mystery of your drawing algorithm, otherwise "I have no idea why since the y coordinate does not change".

MirzaSe

09-02-2014, 08:23 PM

Did you tried to shake your monitor? Unless those specific numbers are cursed by an evil wizard, the information given is insufficient to find the problem. Reveal the mystery of your drawing algorithm, otherwise "I have no idea why since the y coordinate does not change".

These are the final points produced by the algorithm. Those are sent to GPU and drawn...

MtRoad

09-02-2014, 10:09 PM

These are the final points produced by the algorithm. Those are sent to GPU and drawn...

Yandersen's dark and hilarious Canadian humor aside, we need more information to help you (shader program if applicable, the actual draw calls, VBOs, and projection/camera/modelview matrices, etc.). Are you drawing anything else?

Yandersen

09-03-2014, 04:35 AM

Yeah, sry! :)

MirzaSe (http://www.opengl.org/discussion_boards/member.php/33992-MirzaSe), if those numbers are going directly to gl_Position without being multiplied by any matrices, then the vertical lines should be straight. But I believe you use some modelview or projection transformations, and there is the point where calculation errors come from.

Even if you compose your modelview matrix by 90 degree rotation and check it, the numbers in it will not be straight 1.0 and 0.0. Therefore the 90 degree rotations are better to do manually placing 1.0, -1.0 and 0.0 in proper locations of the matrix. If you are doing any other degrees of rotations (especially nesting those) - forget about straight lines. Recalculate the modelview matrix on CPU without nesting transformations (use angles as source arguments producing matrix as result; handle 90, 180, 270 rotations as exceptions to bypass deg-rad conversions and sin-cos calculations as those will introduce calculation errors).

MirzaSe

09-03-2014, 03:43 PM

Thank you, you saved my life :) It was problem with translation ...

Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.