Is there a way to assign a jogl shape to a variable?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Is there a way to assign a jogl shape to a variable?

joeChook
I need to check collision of two shapes. This is a 2D program. One shape is a glPolygon with 4 vertices. The second shape is a glPoint. I need some kind of way to check if they collide and I thought the best way was by assigning the shape to a variable.
Reply | Threaded
Open this post in threaded view
|

Re: Is there a way to assign a jogl shape to a variable?

gouessej
Administrator
Hi

Rather store the vertices of each polygon you pass to OpenGL on the CPU side in a list, an array or ... whatever. Compute the bounding rectangle to ease the computation except if you need something extremely accurate. If you decide to keep the polygon, split it into triangles. Handling collisions is easier on very simple shapes and glPolygon is slow on some chips. If you already have the triangles, you can pass them to OpenGL.
Julien Gouesse | Personal blog | Website