Skip to content

Commit

Permalink
Fix wireframe mode
Browse files Browse the repository at this point in the history
  • Loading branch information
LordMonoxide committed Dec 11, 2024
1 parent 7587b8f commit 9833df8
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/main/java/legend/core/RenderEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import static org.lwjgl.glfw.GLFW.GLFW_KEY_D;
import static org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE;
import static org.lwjgl.glfw.GLFW.GLFW_KEY_F10;
import static org.lwjgl.glfw.GLFW.GLFW_KEY_F2;
import static org.lwjgl.glfw.GLFW.GLFW_KEY_F5;
import static org.lwjgl.glfw.GLFW.GLFW_KEY_LEFT_SHIFT;
import static org.lwjgl.glfw.GLFW.GLFW_KEY_M;
Expand Down Expand Up @@ -617,6 +618,8 @@ public void init() {

this.renderBatch(this.mainBatch);

glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

// set render states
glDisable(GL_DEPTH_TEST);
glDepthMask(true); // enable depth writes so glClear won't ignore clearing the depth buffer
Expand Down Expand Up @@ -682,15 +685,19 @@ private void renderBatch(final RenderBatch batch) {

this.clearDepth();

glPolygonMode(GL_FRONT_AND_BACK, this.wireframeMode ? GL_LINE : GL_FILL);
this.setProjectionMode(batch, ProjectionMode._3D);
this.renderPool(batch.modelPool, true);

glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
this.setProjectionMode(batch, ProjectionMode._2D);
this.renderPool(batch.orthoPool, false);

glPolygonMode(GL_FRONT_AND_BACK, this.wireframeMode ? GL_LINE : GL_FILL);
this.setProjectionMode(batch, ProjectionMode._3D);
this.renderPoolTranslucent(batch, batch.modelPool);

glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
this.setProjectionMode(batch, ProjectionMode._2D);
this.renderPoolTranslucent(batch, batch.orthoPool);

Expand Down Expand Up @@ -1103,10 +1110,6 @@ private void onKeyPress(final Window window, final int key, final int scancode,
case GLFW_KEY_SPACE -> this.movingUp = true;
case GLFW_KEY_LEFT_SHIFT -> this.movingDown = true;
case GLFW_KEY_ESCAPE -> this.window.close();
case GLFW_KEY_TAB -> {
this.wireframeMode = !this.wireframeMode;
glPolygonMode(GL_FRONT_AND_BACK, this.wireframeMode ? GL_LINE : GL_FILL);
}
}
} else if(key == GLFW_KEY_TAB) {
if((mods & GLFW_MOD_SHIFT) != 0) {
Expand All @@ -1122,6 +1125,8 @@ private void onKeyPress(final Window window, final int key, final int scancode,
case 1 -> System.out.println("Switched to legacy rendering");
case 2 -> System.out.println("Switched to VRAM rendering");
}
} else if(key == GLFW_KEY_F2) {
this.wireframeMode = !this.wireframeMode;
} else if(key == GLFW_KEY_F5) {
this.reloadShaders = true;
}
Expand Down

0 comments on commit 9833df8

Please sign in to comment.