TextureRenderer
, you can also use textures the classic
way (i.e. as it is done in pure OpenGL). Doing so is split into the
init()
and the display()
stage.
You need the following tools at your disposal:
int
in an int[]
(array) to store the
texture id.GL
object to operate on.With that, go to the init
stage:
int[]
array for texture identifiers (1 int
per texture)byteArray
, but do not do
anything with it yetGL
) how many textures you want ever
in this app:glGenTextures(<textureCount>,
<fittinglySizedIntArray>);
glBindTexture(GL_TEXTURE_2D, textureArray[<position>]);
byteArray
into graphics card
(where texId == textureArray[<position>]
):gl.glTexImage2D(<texId>, <always-0>,
<dataToUse: RGB, wid, hei, border>,
<dataSrc: RGB, UNSIGNED_BYTE, byteArray);
MAG
) or
zoom out (MIN
):glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_NEAREST);
glEnable(GL_TEXTURE_2D);
And in the display
stage:
glBegin()
) which texture you want to use:glBindTexture(GL_TEXTURE_2D, textureArray[<position>]);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-1.0f, -1.0f, 1.0f);
The above is certainly not a complete, tutorial-like description of
how to use textures the native way. For details, may I refer you to the
NeHe tutorial,
which explains it much better. I hope this small excerpt
persuaded you to use the JOGL TextureRenderer
,
as described in my JOGL tutorial.
And with this, have a good time!