The title should be self explanatory. Does the method getTextureData() from the Texture class return the byte array that is stored within an OpenGL texture, or is it just a copy? I’m alright if either are the case, but I just want to know. If you’re curious, I’m using it for my Button class. The class ignores mouse clicks and rollovers if a pixel has an alpha of 0.
I’m pretty sure that that’s a copy, since OpenGL usually stores their textures on the Graphics Card’s memory, so to use it in your code, it needs to be sent to your RAM.
I wouldn’t implement that for your Button class You should simply expect your button to be able to be clicked in the corners, even if they are rounded off.
Also, the copying means a lot of performance decrease in your application, but only if you do that every frame (which I don’t expect ^^).
In my opinion: Just don’t
I could imagine that the copy would create a memory overhead. Overall performance, though, shouldn’t take much of a hit. All I do is specify an index in the 1-dimensional byte array (treating it as a matrix, of course) based on the mouse’s X and Y coordinates, and check to see if it is zero or not. Nothing too fancy. It actually hasn’t put a hit on my performance. I also have a method that can turn on and off this feature. By default, it is turned off, meaning that the only memory overhead in the event that this feature is not implemented is a null pointer.
Edit: I misinterpreted what you said. Of course I’m not copying it every frame. My bad.
LWJGL doesn’t have a Texture class.
This is part of SlickUtil; which is outdated and a little buggy.
getTextureData uses glGetTexImage, which is really slow since it requires copying data from GPU to CPU and can incur pipeline stalls.
Instead of using GL calls to acquire the pixel data it would be better to decode the PNG and save a copy of the RGBA bytes before sending them to a GL texture.
You can learn more about writing your own texture manager here: