LWJGL Gurus I summon you

Started by Java Cool Dude, March 21, 2004, 07:56:57

Previous topic - Next topic

Java Cool Dude

 public static void updateCubeMap(){

	GL11.glViewport(0, 0, 256, 256);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();

    GLU.gluPerspective (90, 1.0f, 1, 5000);

	GL11.glMatrixMode(GL11.GL_MODELVIEW);
 
    pixelBuffer.makeCurrent();

    for(int i = 0, face = 0; i < 6; i++){
      GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
      GL11.glLoadIdentity();

      switch(i){
        case 0: face = GL13.GL_TEXTURE_CUBE_MAP_POSITIVE_X;
                GL11.glRotatef(-90, 0, 1, 0);
                GL11.glRotatef(180, 0, 0, 1);
        break;
        case 1: face = GL13.GL_TEXTURE_CUBE_MAP_NEGATIVE_X;
                GL11.glRotatef( 90,0,1,0);
                GL11.glRotatef(180, 0, 0, 1);
        break;
        case 2: face = GL13.GL_TEXTURE_CUBE_MAP_POSITIVE_Y;
                GL11.glRotatef(-90,1,0,0);
        break;
        case 3: face = GL13.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y;
                GL11.glRotatef( 90,1,0,0);
        break;
        case 4: face = GL13.GL_TEXTURE_CUBE_MAP_POSITIVE_Z;
                GL11.glRotatef(180,1,0,0);
        break;
        case 5: face = GL13.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z;
                GL11.glRotatef(180,0,0,1);
        break;
      }
      GL11.glTranslatef(shapeList.getXTrans(),
                        shapeList.getYTrans(),
                        shapeList.getZTrans());

      pixelBuffer.setAttrib(Pbuffer.CUBE_MAP_FACE,face);

      GLParticles.drawParticles();
    }
    pixelBuffer.bindTexImage(cubemapID);
  }


Is that the right way to make a dynamic cube map texture?
Spasi: I'm told you're the right dude to ask for that stuff, aren't you :)

spasi

Quote from: "Java Cool Dude"Spasi: I'm told you're the right dude to ask for that stuff, aren't you :)

:) Well, I've never done any dynamic cube-maps before! Anyway, you haven't mentioned what exactly is the problem you're dealing with, but here's what I think goes wrong:

pixelBuffer.makeCurrent() should be the first statement of the method. You want to setup the view for the pbuffer, not the (still current) framebuffer.

All of the "face" assignments in the switch block should use Pbuffer.<FACE> instead of GL13.<FACE>. If you take a look at the LWJGL code, you'll see why.

You may want to clear the color buffer too.

I hope these help.