From 69adb145534c967b8c83b9ccfdc44e25d1bf0a61 Mon Sep 17 00:00:00 2001 From: Ziver Koc Date: Wed, 4 Apr 2007 16:26:26 +0000 Subject: [PATCH] added so it can be used as empty --- src/ei/engine/scene/Sprite.java | 68 +++++++++++++++++---------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/src/ei/engine/scene/Sprite.java b/src/ei/engine/scene/Sprite.java index 665213a..35059c6 100644 --- a/src/ei/engine/scene/Sprite.java +++ b/src/ei/engine/scene/Sprite.java @@ -88,40 +88,42 @@ public class Sprite extends Entity { * Draw the sprite */ public void render() { - // store the current model matrix - GL11.glPushMatrix(); - - //Sets the location - super.setTranslationGL(); - //the rotation - super.setRotationGL(texture.getImageWidth()/2,texture.getImageHeight()/2); - //Sets the scale of the sprite - super.setScaleGL(); - - // bind to the appropriate texture for this sprite - texture.bindGL(); - GL11.glColor3f(1,1,1); - - // draw a quad textured to match the sprite - GL11.glBegin(GL11.GL_QUADS); - { - //Vertex at the upper left - GL11.glTexCoord2f(0, 0); - GL11.glVertex2f(0, 0); - //Vertex at the down left - GL11.glTexCoord2f(0, texture.getHeight()); - GL11.glVertex2f(0, texture.getImageHeight()); - //Vertex at the upper right - GL11.glTexCoord2f(texture.getWidth(), texture.getHeight()); - GL11.glVertex2f(texture.getImageWidth(),texture.getImageHeight()); - //Vertex at the down right - GL11.glTexCoord2f(texture.getWidth(), 0); - GL11.glVertex2f(texture.getImageWidth(),0); + if(texture != null){ + // store the current model matrix + GL11.glPushMatrix(); + + //Sets the location + super.setTranslationGL(); + //the rotation + super.setRotationGL(texture.getImageWidth()/2,texture.getImageHeight()/2); + //Sets the scale of the sprite + super.setScaleGL(); + + // bind to the appropriate texture for this sprite + texture.bindGL(); + GL11.glColor3f(1,1,1); + + // draw a quad textured to match the sprite + GL11.glBegin(GL11.GL_QUADS); + { + //Vertex at the upper left + GL11.glTexCoord2f(0, 0); + GL11.glVertex2f(0, 0); + //Vertex at the down left + GL11.glTexCoord2f(0, texture.getHeight()); + GL11.glVertex2f(0, texture.getImageHeight()); + //Vertex at the upper right + GL11.glTexCoord2f(texture.getWidth(), texture.getHeight()); + GL11.glVertex2f(texture.getImageWidth(),texture.getImageHeight()); + //Vertex at the down right + GL11.glTexCoord2f(texture.getWidth(), 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(); } /**