mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 11:24:56 -04:00
render system: polygon offset
This commit is contained in:
parent
47703a9430
commit
09e8071262
@ -41,6 +41,7 @@ interface RenderSystem {
|
||||
depthTest: Boolean = true,
|
||||
blending: Boolean = false,
|
||||
faceCulling: Boolean = true,
|
||||
polygonOffset: Boolean = false,
|
||||
depthMask: Boolean = true,
|
||||
sourceRGB: BlendingFunctions = BlendingFunctions.ONE,
|
||||
destinationRGB: BlendingFunctions = BlendingFunctions.ONE_MINUS_SOURCE_ALPHA,
|
||||
@ -48,15 +49,19 @@ interface RenderSystem {
|
||||
destinationAlpha: BlendingFunctions = BlendingFunctions.ZERO,
|
||||
depth: DepthFunctions = DepthFunctions.LESS,
|
||||
clearColor: RGBColor = Colors.TRANSPARENT,
|
||||
polygonOffsetFactor: Float = 0.0f,
|
||||
polygonOffsetUnit: Float = 0.0f,
|
||||
) {
|
||||
setBlendFunction(sourceRGB, destinationRGB, sourceAlpha, destinationAlpha)
|
||||
this[RenderingCapabilities.DEPTH_TEST] = depthTest
|
||||
this[RenderingCapabilities.BLENDING] = blending
|
||||
this[RenderingCapabilities.FACE_CULLING] = faceCulling
|
||||
this[RenderingCapabilities.POLYGON_OFFSET] = polygonOffset
|
||||
this.depth = depth
|
||||
this.depthMask = depthMask
|
||||
this.clearColor = clearColor
|
||||
shader = null
|
||||
polygonOffset(polygonOffsetFactor, polygonOffsetUnit)
|
||||
}
|
||||
|
||||
fun enable(capability: RenderingCapabilities)
|
||||
@ -110,4 +115,7 @@ interface RenderSystem {
|
||||
fun clear(vararg buffers: IntegratedBufferTypes)
|
||||
|
||||
fun getErrors(): List<RenderSystemError>
|
||||
|
||||
|
||||
fun polygonOffset(factor: Float, unit: Float)
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2021 Moritz Zwerger
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -17,5 +17,6 @@ enum class RenderingCapabilities {
|
||||
DEPTH_TEST,
|
||||
BLENDING,
|
||||
FACE_CULLING,
|
||||
POLYGON_OFFSET,
|
||||
;
|
||||
}
|
||||
|
@ -289,6 +289,16 @@ class OpenGLRenderSystem(
|
||||
return errors
|
||||
}
|
||||
|
||||
private var polygonOffsetFactor: Float = 0.0f
|
||||
private var polygonOffsetUnit: Float = 0.0f
|
||||
override fun polygonOffset(factor: Float, unit: Float) {
|
||||
if (this.polygonOffsetFactor != factor || this.polygonOffsetUnit != unit) {
|
||||
glPolygonOffset(factor, unit)
|
||||
this.polygonOffsetFactor = factor
|
||||
this.polygonOffsetUnit = unit
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val RenderingCapabilities.gl: Int
|
||||
get() {
|
||||
@ -296,6 +306,7 @@ class OpenGLRenderSystem(
|
||||
RenderingCapabilities.BLENDING -> GL_BLEND
|
||||
RenderingCapabilities.DEPTH_TEST -> GL_DEPTH_TEST
|
||||
RenderingCapabilities.FACE_CULLING -> GL_CULL_FACE
|
||||
RenderingCapabilities.POLYGON_OFFSET -> GL_POLYGON_OFFSET_FILL
|
||||
else -> throw IllegalArgumentException("OpenGL does not support capability: $this")
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ import de.bixilon.minosoft.gui.rendering.renderer.Renderer
|
||||
import de.bixilon.minosoft.gui.rendering.renderer.RendererBuilder
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.DepthFunctions
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.RenderSystem
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.RenderingCapabilities
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.phases.OpaqueDrawable
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.phases.TranslucentDrawable
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.phases.TransparentDrawable
|
||||
@ -693,6 +694,8 @@ class WorldRenderer(
|
||||
}
|
||||
|
||||
renderWindow.renderSystem.depth = DepthFunctions.LESS_OR_EQUAL
|
||||
renderWindow.renderSystem[RenderingCapabilities.POLYGON_OFFSET] = true
|
||||
renderWindow.renderSystem.polygonOffset(-2.5f, -2.5f)
|
||||
textShader.use()
|
||||
for (mesh in visible.text) {
|
||||
mesh.draw()
|
||||
|
@ -57,10 +57,13 @@ class WorldBorderRenderer(
|
||||
renderSystem.reset(
|
||||
blending = true,
|
||||
sourceRGB = BlendingFunctions.SOURCE_ALPHA,
|
||||
destinationRGB = BlendingFunctions.ONE_MINUS_SOURCE_ALPHA,
|
||||
destinationRGB = BlendingFunctions.ONE,
|
||||
sourceAlpha = BlendingFunctions.SOURCE_ALPHA,
|
||||
destinationAlpha = BlendingFunctions.DESTINATION_ALPHA,
|
||||
faceCulling = false,
|
||||
polygonOffset = true,
|
||||
polygonOffsetFactor = -3.0f,
|
||||
polygonOffsetUnit = -3.0f,
|
||||
)
|
||||
shader.use()
|
||||
textureOffset += 0.01f
|
||||
|
Loading…
x
Reference in New Issue
Block a user