Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Functions;
- import static org.lwjgl.opengl.GL11.*;
- import java.io.IOException;
- import java.io.InputStream;
- import org.newdawn.slick.opengl.Texture;
- import org.newdawn.slick.opengl.TextureLoader;
- import org.newdawn.slick.util.ResourceLoader;
- public class renderer {
- public static final int WIDTH = 1600, HEIGHT = 832;
- public static void drawQuad(float x, float y, float quadWidth, float quadHeight){
- glBegin(GL_QUADS);
- glVertex2f(x,y);
- glVertex2f(x+quadWidth,y);
- glVertex2f(x+quadWidth,y+quadHeight);
- glVertex2f(x,y+quadHeight);
- glEnd();
- }
- public static void drawQuadTex(Texture tex, float x, float y, float quadWidth, float quadHeight){
- tex.bind();
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTranslatef(x, y, 0);
- glBegin(GL_QUADS);
- glTexCoord2f(0, 0);
- glVertex2f(0, 0);
- glTexCoord2f(1, 0);
- glVertex2f(quadWidth, 0);
- glTexCoord2f(1, 1);
- glVertex2f(quadWidth, quadHeight);
- glTexCoord2f(0, 1);
- glVertex2f(0, quadHeight);
- glEnd();
- glLoadIdentity();
- }
- public static Texture loadTexture(String path, String fileType){
- Texture tex = null;
- InputStream in = ResourceLoader.getResourceAsStream(path);
- try {
- tex = TextureLoader.getTexture(fileType, in);
- } catch (IOException e) {
- e.printStackTrace();
- }
- return tex;
- }
- public static Texture quickLoad(String name){
- Texture tex = null;
- tex = loadTexture("res/img/" + name + ".png", "PNG");
- return tex;
- }
- }
Add Comment
Please, Sign In to add comment