Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.Uni.main.lib;
- import com.Uni.main.Rettangolo;
- import org.lwjgl.opengl.Display;
- import org.lwjgl.opengl.GL11;
- import org.newdawn.slick.opengl.Texture;
- import org.newdawn.slick.opengl.TextureLoader;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.IOException;
- public class TextureRect extends Rettangolo {
- private static Texture texture;
- private final String imagePath;
- private static char c = ' ';
- public TextureRect(int x, int y, int width, int heigth,
- String path)
- {
- super(x, y, width, heigth, c);
- this.imagePath = path;
- }
- public void loadImagine()
- {
- try {
- // Load the wood texture from "res/images/wood.png"
- texture = TextureLoader.getTexture("PNG", new FileInputStream(new File(imagePath)));
- } catch (IOException e) {
- e.printStackTrace();
- Display.destroy();
- System.exit(1);
- }
- }
- @Override
- public void renderRect()
- {
- texture.bind();
- GL11.glBegin(GL11.GL_QUADS);
- GL11.glTexCoord2f(0, 0);
- GL11.glVertex2i(xUpperLeft , yUpperLeft );
- GL11.glTexCoord2f(1, 0);
- GL11.glVertex2i(xUpperLeft + larghezza, yUpperLeft );
- GL11.glTexCoord2f(1, 1);
- GL11.glVertex2i(xUpperLeft + larghezza, yUpperLeft + altezza);
- GL11.glTexCoord2f(1, 1);
- GL11.glVertex2i(xUpperLeft , yUpperLeft + altezza);
- GL11.glEnd();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement