38 lines
991 B
Java
38 lines
991 B
Java
package shootergame.util.gl;
|
|
|
|
import shootergame.display.Camera;
|
|
import shootergame.util.gl.texture.TextureReference;
|
|
import shootergame.util.math.vec.Vec2d;
|
|
|
|
public class VerticalRender
|
|
{
|
|
public static void render(Vec2d pos, Camera camera, TextureReference tex, Vec2d size)
|
|
{
|
|
double w = size.x/2.0;
|
|
double h = size.y;
|
|
|
|
// Push the matrix
|
|
GlHelpers.pushMatrix();
|
|
|
|
// Get the angle between the camera and the tile
|
|
double angle_r = camera.angle.x;
|
|
|
|
// Make the tile upright
|
|
GlHelpers.translate3(0.5, 0.5, 0);
|
|
GlHelpers.translate3(pos.x, pos.y, 0);
|
|
GlHelpers.rotate(-angle_r, 0, 0, 1);
|
|
GlHelpers.translate3(-0.5, -0.5, 0);
|
|
|
|
// Render the tile
|
|
GlHelpers.begin();
|
|
tex.texCoord(0, 1); GlHelpers.vertex3(0.5-w, 0.5, 0);
|
|
tex.texCoord(1, 1); GlHelpers.vertex3(0.5+w, 0.5, 0);
|
|
tex.texCoord(1, 0); GlHelpers.vertex3(0.5+w, 0.5, h);
|
|
tex.texCoord(0, 0); GlHelpers.vertex3(0.5-w, 0.5, h);
|
|
GlHelpers.end();
|
|
|
|
// Pop the matrix
|
|
GlHelpers.popMatrix();
|
|
}
|
|
}
|