added so it can be used as empty
This commit is contained in:
parent
98c96ed24d
commit
69adb14553
1 changed files with 35 additions and 33 deletions
|
|
@ -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
|
|
||||||
super.setTranslationGL();
|
//Sets the location
|
||||||
//the rotation
|
super.setTranslationGL();
|
||||||
super.setRotationGL(texture.getImageWidth()/2,texture.getImageHeight()/2);
|
//the rotation
|
||||||
//Sets the scale of the sprite
|
super.setRotationGL(texture.getImageWidth()/2,texture.getImageHeight()/2);
|
||||||
super.setScaleGL();
|
//Sets the scale of the sprite
|
||||||
|
super.setScaleGL();
|
||||||
// bind to the appropriate texture for this sprite
|
|
||||||
texture.bindGL();
|
// bind to the appropriate texture for this sprite
|
||||||
GL11.glColor3f(1,1,1);
|
texture.bindGL();
|
||||||
|
GL11.glColor3f(1,1,1);
|
||||||
// draw a quad textured to match the sprite
|
|
||||||
GL11.glBegin(GL11.GL_QUADS);
|
// draw a quad textured to match the sprite
|
||||||
{
|
GL11.glBegin(GL11.GL_QUADS);
|
||||||
//Vertex at the upper left
|
{
|
||||||
GL11.glTexCoord2f(0, 0);
|
//Vertex at the upper left
|
||||||
GL11.glVertex2f(0, 0);
|
GL11.glTexCoord2f(0, 0);
|
||||||
//Vertex at the down left
|
GL11.glVertex2f(0, 0);
|
||||||
GL11.glTexCoord2f(0, texture.getHeight());
|
//Vertex at the down left
|
||||||
GL11.glVertex2f(0, texture.getImageHeight());
|
GL11.glTexCoord2f(0, texture.getHeight());
|
||||||
//Vertex at the upper right
|
GL11.glVertex2f(0, texture.getImageHeight());
|
||||||
GL11.glTexCoord2f(texture.getWidth(), texture.getHeight());
|
//Vertex at the upper right
|
||||||
GL11.glVertex2f(texture.getImageWidth(),texture.getImageHeight());
|
GL11.glTexCoord2f(texture.getWidth(), texture.getHeight());
|
||||||
//Vertex at the down right
|
GL11.glVertex2f(texture.getImageWidth(),texture.getImageHeight());
|
||||||
GL11.glTexCoord2f(texture.getWidth(), 0);
|
//Vertex at the down right
|
||||||
GL11.glVertex2f(texture.getImageWidth(),0);
|
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue