Hi,
for my battle system im using a Cubemap to fake a full 3D world.
Im using 6 textures, 4 for sides and 2 for ground and sky.
Now i would like to use GL_QUADS to display my 2D battlers.
The problem now is: My Battlers arent display =/
Heres the code/setting im using:
settings:
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
gl.glShadeModel(GL.GL_FLAT);
gl.glEnable(GL.GL_TEXTURE_2D);
gl.glEnable(GL.GL_BLEND);
gl.glColorMask(true, true, true, true);
double widht = 774;
double height = 540;
final float h = (float) width / (float) height;
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(60.0f, h, .1, 10);
gl.glViewport(0, 0, (int)width, (int)height);
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
render:
public void render(GL gl){
renderBG(gl);
for(int i=0;i<battler.length;i++){ // 2 Battlers
Texture tex = battler[i].battler.animations[battler[i].action].getFrame(); // The Texture is a texture with content.
tex.bind();
tex.enable();
gl.glTranslatef(battler[i].coor.xf, battler[i].coor.yf, battler[i].coor.zf); // All Coor are zero.
TextureCoords coords = tex.getImageTexCoords();
gl.glBegin(GL.GL_QUADS);
gl.glTexCoord2f(coords.left(), coords.bottom());
gl.glVertex3f(0, 0, 0);
gl.glTexCoord2f(coords.right(), coords.bottom());
gl.glVertex3f(1, 0, 0);
gl.glTexCoord2f(coords.right(), coords.top());
gl.glVertex3f(1, 1, 0);
gl.glTexCoord2f(coords.left(), coords.top());
gl.glVertex3f(0, 1, 0);
gl.glEnd();
gl.glTranslatef(-battler[i].coor.xf, -battler[i].coor.yf, -battler[i].coor.zf);
}
}
private void useCamera(GL gl){
gl.glRotatef((float)Math.toDegrees(Camera.v),1f,0f,0f); // is zero.
gl.glRotatef((float)Math.toDegrees(Camera.h),0f,1f,0f); // is zero.
gl.glRotatef((float)Math.toDegrees(Camera.c),0f,0f,1f); // is zero.
}
private void renderBG(GL gl){
cubemap.bind();
cubemap.enable();
gl.glEnable(GL.GL_LIGHTING);
gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
gl.glTexGeni(GL.GL_R, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
gl.glEnable(GL.GL_TEXTURE_GEN_S);
gl.glEnable(GL.GL_TEXTURE_GEN_T);
gl.glEnable(GL.GL_TEXTURE_GEN_R);
gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE);
gl.glMatrixMode(GL.GL_TEXTURE);
gl.glPushMatrix();
gl.glLoadIdentity();
useCamera(gl);
glut.glutSolidSphere(5.0, 40, 20);
gl.glDisable(GL.GL_LIGHTING);
gl.glPopMatrix();
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glDisable(GL.GL_TEXTURE_GEN_S);
gl.glDisable(GL.GL_TEXTURE_GEN_T);
gl.glDisable(GL.GL_TEXTURE_GEN_R);
}