Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
Update viewport for SkyRenderer
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsFlare committed Jul 22, 2022
1 parent d59cb0c commit a470752
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import net.durchholz.beacon.render.opengl.OpenGL;
import net.durchholz.beacon.render.opengl.textures.CubemapTexture;
import net.durchholz.beacon.util.Image;
import net.durchholz.beacon.window.Viewport;
import net.durchholz.beacon.window.Window;
import net.durchholz.beacon.window.event.ViewportResizeEvent;
import org.lwjgl.opengl.GL30;
Expand All @@ -34,8 +33,6 @@ public class Renderer {
private final SpriteRenderer crosshairRenderer = new SpriteRenderer(new Image(Util.readResource("textures/crosshair.png")));
private final GeometryBuffer gBuffer = new GeometryBuffer(1, 1);

private Viewport viewport;

public boolean renderUI = true;
public boolean renderSkybox = true;
public boolean renderWorld = true;
Expand All @@ -47,8 +44,7 @@ public Renderer(Window window) throws IOException {
this.camera = new Camera(window);
this.userInterface = new UserInterface();
this.worldRenderer = new WorldRenderer();
this.viewport = window.getViewport();
gBuffer.allocate(viewport.width(), viewport.height());
gBuffer.allocate(window.getViewport().width(), window.getViewport().height());

EventType.addListener(this);
}
Expand Down Expand Up @@ -103,11 +99,10 @@ private void onResize(ViewportResizeEvent event) {

private void renderSky() {
float dayPercentage = Util.clamp((float) sin(2 * Math.PI * Main.getDayPercentage()) + 0.75f, 0, 1);
Vec2f viewportRes = new Vec2f(viewport.width(), viewport.height());

var projection = camera.projection();
projection.multiply(camera.view(false, true));
//System.out.println(camera.getDirection());
final Vec2f viewportRes = new Vec2f(Main.INSTANCE.getWindow().getViewport().width(), Main.INSTANCE.getWindow().getViewport().height());

gBuffer.use(() -> {
OpenGL.setDrawBuffers(GL30.GL_COLOR_ATTACHMENT0);
Expand Down

0 comments on commit a470752

Please sign in to comment.