PDA

View Full Version : draw square with 2 vertices given possible?



Numberator
01-21-2010, 05:43 AM
Is it possible to make a square using triangle strip if I am only given 2 vertices(the diagonal of the square)?

ZbuffeR
01-21-2010, 06:18 AM
Not directly, you will have to compute the other two vertices.

_x57_
01-21-2010, 06:21 AM
there is no opengl function doing that.
Of course you can implement a helper method that generates 4 vertices from two two-dimensional ( i assume you are 2d, because in 3d that would not make sense...) points as you described and sends them to the gl to draw a triangle fan.

mark ds
01-21-2010, 12:44 PM
glRect?

http://www.opengl.org/sdk/docs/man/xhtml/glRect.xml

_x57_
01-22-2010, 02:16 AM
glRect?

http://www.opengl.org/sdk/docs/man/xhtml/glRect.xml

Fascinating. Never stumbled across it...

ZbuffeR
01-22-2010, 02:27 AM
Yeah, it was already deprecated when I learned about its existence :D

mark ds
01-22-2010, 03:01 AM
Yeah, it was already deprecated when I learned about its existence :D

LOL. I never claimed it was cutting edge! :D

Iulian B
01-23-2010, 06:50 PM
On the other hand, for something a bit more cutting edge, you could construct a vbo holding an "normalized" rectangle ({0,0},{0,1},{1,0},{1,1}), pass your own 2 vertices as uniform data and inside the vertex shader, using some clever math, reconstruct the rectangle... Hey, in this way, you could also batch multiple rectangles and instance-render them :D

...just sayin'...