Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.anim8.engine;
- import static org.lwjgl.opengl.GL11.GL_QUADS;
- import static org.lwjgl.opengl.GL11.glBegin;
- import static org.lwjgl.opengl.GL11.glEnd;
- import static org.lwjgl.opengl.GL11.glTexCoord2f;
- import static org.lwjgl.opengl.GL11.glVertex2i;
- import org.lwjgl.opengl.GL11;
- import org.newdawn.slick.opengl.Texture;
- public class renderer {
- private Texture texture;
- public String textureDirString;
- public Boolean texLoaded = false;
- public int noTimes = 0;
- loadTexture lt = new loadTexture();
- public void displayTile(int x, int y, String tempTex){
- if(texLoaded != true){
- readyTexture(tempTex);
- }
- tileRender(x,y);
- }
- public Boolean getTexLoaded(){
- return texLoaded;
- }
- renderer() {
- texLoaded = false;
- }
- public void readyTexture(String textureDir){
- texture = lt.loadTexture(textureDir);
- textureDirString = textureDir;
- texture.bind();
- texLoaded = true;
- System.out.println("Loaded: " + textureDirString);
- }
- public void tileRender(int x, int y){
- GL11.glPushMatrix();
- glBegin(GL_QUADS);
- glTexCoord2f(0, 0);
- glVertex2i(x , y); //Upper Left
- glTexCoord2f(1, 0);
- glVertex2i(x + texture.getTextureWidth(),y); //Upper Right
- glTexCoord2f(1, 1);
- glVertex2i(x + texture.getTextureWidth(), y + texture.getTextureHeight()); //Bottom Right
- glTexCoord2f(0, 1);
- glVertex2i(x,y + texture.getTextureHeight()); //Bottom Left
- System.out.println("Rendered: " + textureDirString);
- glEnd();
- GL11.glPopMatrix();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement