package raiding.main;
import org.lwjgl.opengl.GL11;
import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.BasicGame;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.opengl.SlickCallable;
import org.newdawn.slick.opengl.Texture;
import org.newdawn.slick.opengl.renderer.SGL;
public class Example extends BasicGame{
public static class PsuedoPerspectiveCall extends SlickCallable{
private Image img;
/**
* @param img The image that you want drawn in perspective.
*/
public PsuedoPerspectiveCall(Image img){
this.img = img;
}
@Override
protected void performGLOperations() throws SlickException{
//Bind Texture
Texture tex = img.getTexture(); //get Texture ref from Image
tex.bind(); //binds the texture
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glFrustum(-1.0, 1, -1.0, 1.0, 5, 100);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glTranslatef(0, 0, -5.01f);
//Draw Quad
GL11.glBegin(SGL.GL_QUADS); //beings GL mode to draw quads
//TRI-1
//POINT ONE
GL11.glTexCoord2f(0.0f, 0.0f);
GL11.glVertex3f(1.0f, 1.0f, 0);
//POINT TWO
GL11.glTexCoord2f(1.0f, 0.0f);
GL11.glVertex3f( -1.0f, 1.5f, -15);
//POINT THREE
GL11.glTexCoord2f(1.0f, 1.0f);
GL11.glVertex3f( -1.0f, -1.0f, -15);
//POINT FOUR
GL11.glTexCoord2f(0.0f, 1.0f);
GL11.glVertex3f(1.0f, -1.0f, 0);
GL11.glEnd(); //END GL mode to draw Quads
}
}
private SlickCallable callable;
public Example(String title){
super(title);
}
@Override
public void init(GameContainer arg0) throws SlickException{
//setTargetFrameRate(100);
//Image img1 = new Image("data/img/backGrounds/bg_def.png");
// Image img1 = new Image("data/img/gui/cirno_Pic_01.png");
Image img1 = new Image("data/blackmage.png");
callable = new PsuedoPerspectiveCall(img1);
}
@Override
public void update(GameContainer gc, int delta) throws SlickException{
//TODO implement
}
public void render(GameContainer arg0, Graphics arg1)
throws SlickException{
//Do regular drawing here
callable.call();
//Do more regular drawing
}
public static void main(String[] args){
Example t = new Example("Psuedo Texture Example");
try{
AppGameContainer agc = new AppGameContainer(t, 400,400, false);
agc.start();
}catch(SlickException e){
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}