Cubemap Texture loading

hello,

i work with java/jogl opengl and found an
tutorial about cubemap, but the face textures
of the cubemap are only simpel colored textures.

i didnt found a way to load my textures into
the cubemap.

i try google but didnt find anything and the
redbook on opengl.org is offline since a few days

gl.glTexImage2D(GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL.GL_RGBA,imageSize, imageSize, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE,texture[nr]<-error );

i see that the gltextimage2d want this:

private static ByteBuffer imageBuf1 = BufferUtil.newByteBuffer(imageSize * imageSize * 4);

but how did i copy my textures into that imageBuf1 for example

much thx for any help


import com.sun.opengl.util.;
import javax.media.opengl.
;
import javax.media.opengl.glu.*;

Texture[] texture= new Texture[200];

//Texture Loader
texture[nr] = TextureIO.newTexture(new File(“gfx/d00”+nr+“.JPG”), true);
texture[nr].bind();

gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR_MIPMAP_NEAREST);

gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 2);
gl.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_MODULATE);

I’d look into the dds texture format and maybe one of free image libraries, great for cubemaps an just about everything else.

hello modus,

i have the cubemap images already inside the project
i use them as skybox and now i also want
the
same textures to use in the cubemap

the only problem i have, i dont know how get them
into the gl.glTexImage2D.

texture[nr] -> ‘convert/copy/whatever’ -> private static ByteBuffer imageBuf1 ?!?!?!

:slight_smile:

DerTherion: the only problem i have, i dont know how get them into the gl.glTexImage2D.

thru glTexImage2D. you need to upload pixels for EACH direction one by one.
GL_TEXTURE_CUBE_MAP_POSITIVE_X
GL_TEXTURE_CUBE_MAP_NEGATIVE_X
GL_TEXTURE_CUBE_MAP_POSITIVE_Y
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
GL_TEXTURE_CUBE_MAP_POSITIVE_Z
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z

hello _NK47 :slight_smile:

i know that i have to feed glTexImage2D with pixels…

my problem is simple…

i got some textures loaded…and i search for a way
go get the pixels (of that textures) and
copy/put/whatever into imageBuf1

(at moment the imagebuf1-6 pixeldata are simple
created colors that shows me that cubemap is working
but instead of an green reflection i want an pictures in
the cubemap,but i cant find commands/code/demos with source
for that copy tetxurepixel to buffer )

gl.glTexImage2D(GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL.GL_RGBA,
imageSize, imageSize, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE,
imageBuf1);



you want to download pixels from GPU to CPU? if yes use glGetTexImage().

basically you upload texture data with glTexImage2d() and download it with glGetTexImage().