added so it can be used as empty

This commit is contained in:
Ziver Koc 2007-04-04 16:26:26 +00:00
parent 98c96ed24d
commit 69adb14553

View file

@ -88,40 +88,42 @@ public class Sprite extends Entity {
* Draw the sprite * Draw the sprite
*/ */
public void render() { public void render() {
// store the current model matrix if(texture != null){
GL11.glPushMatrix(); // store the current model matrix
GL11.glPushMatrix();
//Sets the location //Sets the location
super.setTranslationGL(); super.setTranslationGL();
//the rotation //the rotation
super.setRotationGL(texture.getImageWidth()/2,texture.getImageHeight()/2); super.setRotationGL(texture.getImageWidth()/2,texture.getImageHeight()/2);
//Sets the scale of the sprite //Sets the scale of the sprite
super.setScaleGL(); super.setScaleGL();
// bind to the appropriate texture for this sprite // bind to the appropriate texture for this sprite
texture.bindGL(); texture.bindGL();
GL11.glColor3f(1,1,1); GL11.glColor3f(1,1,1);
// draw a quad textured to match the sprite // draw a quad textured to match the sprite
GL11.glBegin(GL11.GL_QUADS); GL11.glBegin(GL11.GL_QUADS);
{ {
//Vertex at the upper left //Vertex at the upper left
GL11.glTexCoord2f(0, 0); GL11.glTexCoord2f(0, 0);
GL11.glVertex2f(0, 0); GL11.glVertex2f(0, 0);
//Vertex at the down left //Vertex at the down left
GL11.glTexCoord2f(0, texture.getHeight()); GL11.glTexCoord2f(0, texture.getHeight());
GL11.glVertex2f(0, texture.getImageHeight()); GL11.glVertex2f(0, texture.getImageHeight());
//Vertex at the upper right //Vertex at the upper right
GL11.glTexCoord2f(texture.getWidth(), texture.getHeight()); GL11.glTexCoord2f(texture.getWidth(), texture.getHeight());
GL11.glVertex2f(texture.getImageWidth(),texture.getImageHeight()); GL11.glVertex2f(texture.getImageWidth(),texture.getImageHeight());
//Vertex at the down right //Vertex at the down right
GL11.glTexCoord2f(texture.getWidth(), 0); GL11.glTexCoord2f(texture.getWidth(), 0);
GL11.glVertex2f(texture.getImageWidth(),0); GL11.glVertex2f(texture.getImageWidth(),0);
}
GL11.glEnd();
// restore the model view matrix to prevent contamination
GL11.glPopMatrix();
} }
GL11.glEnd();
// restore the model view matrix to prevent contamination
GL11.glPopMatrix();
} }
/** /**