Advertisement
Anim8

renderer Class - Virtual Pet

Aug 3rd, 2013
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.56 KB | None | 0 0
  1. package com.anim8.engine;
  2.  
  3. import static org.lwjgl.opengl.GL11.GL_QUADS;
  4. import static org.lwjgl.opengl.GL11.glBegin;
  5. import static org.lwjgl.opengl.GL11.glEnd;
  6. import static org.lwjgl.opengl.GL11.glTexCoord2f;
  7. import static org.lwjgl.opengl.GL11.glVertex2i;
  8.  
  9. import org.lwjgl.opengl.GL11;
  10. import org.newdawn.slick.opengl.Texture;
  11.  
  12. public class renderer {
  13.    
  14.    
  15.    
  16.     private Texture texture;
  17.     public String textureDirString;
  18.     public Boolean texLoaded = false;
  19.    
  20.     public int noTimes = 0;
  21.     loadTexture lt = new loadTexture();
  22.    
  23.     public void displayTile(int x, int y, String tempTex){
  24.         if(texLoaded != true){
  25.             readyTexture(tempTex);
  26.            
  27.         }
  28.         tileRender(x,y);
  29.        
  30.     }
  31.     public Boolean getTexLoaded(){
  32.         return texLoaded;
  33.     }
  34.  
  35.     renderer() {
  36.         texLoaded = false;
  37.     }
  38.    
  39.     public void readyTexture(String textureDir){
  40.         texture = lt.loadTexture(textureDir);
  41.         textureDirString = textureDir;
  42.         texture.bind();
  43.         texLoaded = true;
  44.         System.out.println("Loaded: " + textureDirString);
  45.     }
  46.    
  47.     public void tileRender(int x, int y){
  48.     GL11.glPushMatrix();
  49.  
  50.        
  51.    
  52.     glBegin(GL_QUADS);
  53.         glTexCoord2f(0, 0);
  54.         glVertex2i(x , y); //Upper Left
  55.         glTexCoord2f(1, 0);
  56.         glVertex2i(x + texture.getTextureWidth(),y); //Upper Right
  57.         glTexCoord2f(1, 1);
  58.         glVertex2i(x + texture.getTextureWidth(), y + texture.getTextureHeight()); //Bottom Right
  59.         glTexCoord2f(0, 1);
  60.         glVertex2i(x,y + texture.getTextureHeight()); //Bottom Left
  61.         System.out.println("Rendered: " + textureDirString);
  62.     glEnd();
  63.     GL11.glPopMatrix();
  64.  
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement