Skip to content

Commit e25e75c

Browse files
authored
Misc: Replace remaining raw OpenGL scissor with UGraphics
GitHub: #179
1 parent 27eb54f commit e25e75c

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/main/kotlin/gg/essential/elementa/UIComponent.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import gg.essential.elementa.state.v2.ReferenceHolder
2020
import gg.essential.elementa.utils.*
2121
import gg.essential.elementa.utils.requireMainThread
2222
import gg.essential.elementa.utils.requireState
23+
import gg.essential.universal.UGraphics
2324
import gg.essential.universal.UMatrixStack
2425
import gg.essential.universal.UMouse
2526
import gg.essential.universal.UResolution
26-
import org.lwjgl.opengl.GL11
2727
import java.awt.Color
2828
import java.util.*
2929
import java.util.concurrent.ConcurrentHashMap
@@ -1800,8 +1800,9 @@ abstract class UIComponent : Observable(), ReferenceHolder {
18001800
* Draws a colored outline around a given area
18011801
*/
18021802
internal fun drawDebugOutline(matrixStack: UMatrixStack,left: Double, top: Double, right: Double, bottom: Double, component: UIComponent) {
1803-
if (ScissorEffect.currentScissorState != null) {
1804-
GL11.glDisable(GL11.GL_SCISSOR_TEST)
1803+
val scissorState = ScissorEffect.currentScissorState
1804+
if (scissorState != null) {
1805+
UGraphics.disableScissor()
18051806
}
18061807

18071808
val color = getDebugColor(component.depth(), (component.parent.hashCode() / PI) % PI)
@@ -1832,8 +1833,8 @@ abstract class UIComponent : Observable(), ReferenceHolder {
18321833
// Left outline block
18331834
UIBlock.drawBlock(matrixStack, color, left - DEBUG_OUTLINE_WIDTH, top, left, bottom)
18341835

1835-
if (ScissorEffect.currentScissorState != null) {
1836-
GL11.glEnable(GL11.GL_SCISSOR_TEST)
1836+
if (scissorState != null) {
1837+
UGraphics.enableScissor(scissorState.x, scissorState.y, scissorState.width, scissorState.height)
18371838
}
18381839
}
18391840

src/main/kotlin/gg/essential/elementa/components/Window.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import gg.essential.elementa.font.FontRenderer
1111
import gg.essential.elementa.utils.elementaDev
1212
import gg.essential.elementa.utils.requireMainThread
1313
import gg.essential.universal.*
14-
import org.lwjgl.opengl.GL11
1514
import java.util.concurrent.ConcurrentLinkedQueue
1615
import java.util.concurrent.TimeUnit
1716

@@ -178,7 +177,7 @@ class Window @JvmOverloads constructor(
178177
// We may have thrown in the middle of a ScissorEffect, in which case we
179178
// need to disable the scissor if we don't want half the user's screen gone
180179
ScissorEffect.currentScissorState = null
181-
GL11.glDisable(GL11.GL_SCISSOR_TEST)
180+
UGraphics.disableScissor()
182181

183182
UMinecraft.currentScreenObj = when {
184183
e is StackOverflowError && elementaDev -> {

0 commit comments

Comments
 (0)