LWJGL non square buttons

I am using LWJGL to try and use a PNG as a button Texture. The only way I know how to make a button is to draw a Quad in openGL then bind a texture to it. Is there a way to make the Texture be the bounds of the button? All i could think to do to actually crop the click detection area was to draw multiple Quad to the screen and then bind part of the texture to each, and there has to be a better way than that.

I would be grateful for any help, and if what i am asking for does not make sense tell me and i will try to explain better.

well what I do is I detect the mouse click to each button , binding a box around it . Do you mean a non four sided button such as an L shaped piece? thats a bit complex and it depends on the type of shape you are using. Generally for shapes like this I recommend using GL_TRIANGLES because you can make any shape with them.

Keep the quad, make parts of the PNG transparent. That’s how everyone does it.

Transparent part of the button? Why would you want that? Unless you mean it detects the click in the opaque part.

Anyway you can either do it by creating a piece of geometry using GL_TRIANGLES like lcass said, or by rendering the GUI alpha channel to a black and white texture then test if the mouse is in the “opaque” part (white in my case).

That is what I meant, yes. If something is a non-standard shape it may become easier to do pixel-perfect collision, which is cheap in this case since it’s gui and clicks aren’t that frequent.

Keep the quad what-ever size you want, and tweak the texture coordinates so that the transparent part won’t be visible.

http://puu.sh/drbyG/3eb77f8ad3.png

Or better, you can simply remove the transparency part in the texture, textures by default, scale to the quad size.