Two ways to load a texture.

(sorry for my english)

I have one question about loading textures in jogl. I figured out that there is two ways to convert image to OpenGL texture. First one is to use Texture class from “com.sun.opengl.util.texture.Texture;”. The second one is to create my own Texture class and then manually load image data, convert it to bytes and then use as a texture. So, the question: is there any difference between these two methods, or they are totally equivalent?

The jogl Texture class automates a lot for you, such as using GL_TEXTURE_RECTANGLE instead of GL_TEXTURE_2D, and it also provides support to load in many different images. However, it makes you dependent on the jogl libraries for core functionality. This may be perfectly acceptable if you’re starting out, but for an advanced graphics engine (supporting different renderers: jogl or lwjgl), it makes more sense to make your own Texture class.

Also, the jogl Texture class doesn’t support 3D textures (and maybe not cubemaps?) the last time I checked, which could be an issue.

But is the JOGL’s texture class faster than a custom texture?

The Texture class is “just” a utility class, so whatever it can do you can do. So if it’s faster or not than your custom class depends completely on the implementation used, but in the end I imagine it won’t matter.

There are two different parts to loading a texture: loading it into memory, and sending it to the graphics card. Sending it the graphics card is reasonably simple and can’t really be optimized by changing opengl code. Loading can be improved a lot, especially depending how/what you use to load the images into memory and if you have to change the format of the data before sending to the gfx card.