mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-13 17:37:58 -04:00
fix some more bugs
This commit is contained in:
parent
d2c40a810d
commit
2ecf73b82e
@ -26,10 +26,8 @@ import de.bixilon.minosoft.gui.rendering.system.base.BlendingFunctions
|
|||||||
import de.bixilon.minosoft.gui.rendering.system.base.DepthFunctions
|
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.RenderSystem
|
||||||
import de.bixilon.minosoft.gui.rendering.system.base.RenderingCapabilities
|
import de.bixilon.minosoft.gui.rendering.system.base.RenderingCapabilities
|
||||||
import de.bixilon.minosoft.gui.rendering.system.base.buffer.vertex.PrimitiveTypes
|
|
||||||
import de.bixilon.minosoft.gui.rendering.system.base.phases.CustomDrawable
|
import de.bixilon.minosoft.gui.rendering.system.base.phases.CustomDrawable
|
||||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.AbstractTexture
|
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.AbstractTexture
|
||||||
import de.bixilon.minosoft.gui.rendering.util.mesh.Mesh
|
|
||||||
import de.bixilon.minosoft.gui.rendering.util.mesh.SimpleTextureMesh
|
import de.bixilon.minosoft.gui.rendering.util.mesh.SimpleTextureMesh
|
||||||
import de.bixilon.minosoft.modding.event.events.TimeChangeEvent
|
import de.bixilon.minosoft.modding.event.events.TimeChangeEvent
|
||||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||||
@ -49,7 +47,7 @@ class SkyRenderer(
|
|||||||
private val skyboxShader = renderSystem.createShader(ResourceLocation(ProtocolDefinition.MINOSOFT_NAMESPACE, "sky/skybox"))
|
private val skyboxShader = renderSystem.createShader(ResourceLocation(ProtocolDefinition.MINOSOFT_NAMESPACE, "sky/skybox"))
|
||||||
private val skySunShader = renderSystem.createShader(ResourceLocation(ProtocolDefinition.MINOSOFT_NAMESPACE, "sky/sun"))
|
private val skySunShader = renderSystem.createShader(ResourceLocation(ProtocolDefinition.MINOSOFT_NAMESPACE, "sky/sun"))
|
||||||
private val skyboxMesh = SkyboxMesh(renderWindow)
|
private val skyboxMesh = SkyboxMesh(renderWindow)
|
||||||
private var skySunMesh = SimpleTextureMesh(renderWindow, PrimitiveTypes.TRIANGLE)
|
private var skySunMesh = SimpleTextureMesh(renderWindow)
|
||||||
private lateinit var sunTexture: AbstractTexture
|
private lateinit var sunTexture: AbstractTexture
|
||||||
private var sunMatrixUpToDate: Boolean = true
|
private var sunMatrixUpToDate: Boolean = true
|
||||||
var baseColor = RenderConstants.DEFAULT_SKY_COLOR
|
var baseColor = RenderConstants.DEFAULT_SKY_COLOR
|
||||||
@ -98,8 +96,8 @@ class SkyRenderer(
|
|||||||
setSunMatrix(renderWindow.inputHandler.camera.projectionMatrix * renderWindow.inputHandler.camera.viewMatrix.toMat3().toMat4())
|
setSunMatrix(renderWindow.inputHandler.camera.projectionMatrix * renderWindow.inputHandler.camera.viewMatrix.toMat3().toMat4())
|
||||||
skySunMesh.unload()
|
skySunMesh.unload()
|
||||||
|
|
||||||
skySunMesh = SimpleTextureMesh(renderWindow, PrimitiveTypes.TRIANGLE)
|
skySunMesh = SimpleTextureMesh(renderWindow)
|
||||||
Mesh.addQuad(
|
skySunMesh.addQuad(
|
||||||
start = Vec3(-0.15f, 1.0f, -0.15f),
|
start = Vec3(-0.15f, 1.0f, -0.15f),
|
||||||
end = Vec3(+0.15f, 1.0f, +0.15f),
|
end = Vec3(+0.15f, 1.0f, +0.15f),
|
||||||
vertexConsumer = { position, uv ->
|
vertexConsumer = { position, uv ->
|
||||||
|
@ -2,14 +2,16 @@ package de.bixilon.minosoft.gui.rendering.system.base.phases
|
|||||||
|
|
||||||
import de.bixilon.minosoft.gui.rendering.Renderer
|
import de.bixilon.minosoft.gui.rendering.Renderer
|
||||||
import de.bixilon.minosoft.gui.rendering.system.base.BlendingFunctions
|
import de.bixilon.minosoft.gui.rendering.system.base.BlendingFunctions
|
||||||
|
import de.bixilon.minosoft.gui.rendering.system.base.RenderingCapabilities
|
||||||
|
|
||||||
interface TranslucentDrawable : Renderer {
|
interface TranslucentDrawable : Renderer {
|
||||||
val skipTranslucent: Boolean
|
val skipTranslucent: Boolean
|
||||||
get() = false
|
get() = false
|
||||||
|
|
||||||
fun setupTranslucent() {
|
fun setupTranslucent() {
|
||||||
renderSystem.reset(depthMask = false, blending = true) // ToDo: This is just a translucent workaround
|
renderSystem.reset(blending = true) // ToDo: This is just a translucent workaround
|
||||||
renderSystem.setBlendFunc(BlendingFunctions.SOURCE_ALPHA, BlendingFunctions.ONE_MINUS_SOURCE_ALPHA, BlendingFunctions.ONE, BlendingFunctions.ONE_MINUS_SOURCE_ALPHA)
|
renderSystem.enable(RenderingCapabilities.BLENDING)
|
||||||
|
renderSystem.setBlendFunc(BlendingFunctions.SOURCE_ALPHA, BlendingFunctions.ONE_MINUS_SOURCE_ALPHA, BlendingFunctions.ONE, BlendingFunctions.ZERO)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun drawTranslucent()
|
fun drawTranslucent()
|
||||||
|
@ -14,7 +14,7 @@ import org.lwjgl.opengl.GL20.glEnableVertexAttribArray
|
|||||||
import org.lwjgl.opengl.GL20.glVertexAttribPointer
|
import org.lwjgl.opengl.GL20.glVertexAttribPointer
|
||||||
import java.nio.FloatBuffer
|
import java.nio.FloatBuffer
|
||||||
|
|
||||||
class FloatOpenGLVertexBuffer(override val structure: MeshStruct, data: FloatBuffer, override val primitiveType: PrimitiveTypes = PrimitiveTypes.TRIANGLE) : FloatOpenGLBuffer(data), FloatVertexBuffer {
|
class FloatOpenGLVertexBuffer(override val structure: MeshStruct, data: FloatBuffer, override val primitiveType: PrimitiveTypes) : FloatOpenGLBuffer(data), FloatVertexBuffer {
|
||||||
override var vertices = -1
|
override var vertices = -1
|
||||||
private set
|
private set
|
||||||
private var vao = -1
|
private var vao = -1
|
||||||
|
@ -63,6 +63,26 @@ abstract class Mesh(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun addQuad(start: Vec3, end: Vec3, uvStart: Vec2 = Vec2(0.0f, 0.0f), uvEnd: Vec2 = Vec2(1.0f, 1.0f), vertexConsumer: (position: Vec3, uv: Vec2) -> Unit) {
|
||||||
|
val positions = arrayOf(
|
||||||
|
start,
|
||||||
|
Vec3(start.x, start.y, end.z),
|
||||||
|
end,
|
||||||
|
Vec3(end.x, end.y, start.z),
|
||||||
|
)
|
||||||
|
val texturePositions = arrayOf(
|
||||||
|
Vec2(uvEnd.x, uvStart.y),
|
||||||
|
uvStart,
|
||||||
|
Vec2(uvStart.x, uvEnd.y),
|
||||||
|
uvEnd,
|
||||||
|
)
|
||||||
|
|
||||||
|
for ((vertexIndex, textureIndex) in order) {
|
||||||
|
vertexConsumer.invoke(positions[vertexIndex], texturePositions[textureIndex])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enum class MeshStates {
|
enum class MeshStates {
|
||||||
PREPARING,
|
PREPARING,
|
||||||
LOADED,
|
LOADED,
|
||||||
@ -84,25 +104,5 @@ abstract class Mesh(
|
|||||||
2 to 3,
|
2 to 3,
|
||||||
1 to 0,
|
1 to 0,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
fun addQuad(start: Vec3, end: Vec3, uvStart: Vec2 = Vec2(0.0f, 0.0f), uvEnd: Vec2 = Vec2(1.0f, 1.0f), vertexConsumer: (position: Vec3, uv: Vec2) -> Unit) {
|
|
||||||
val positions = arrayOf(
|
|
||||||
start,
|
|
||||||
Vec3(start.x, start.y, end.z),
|
|
||||||
end,
|
|
||||||
Vec3(end.x, end.y, start.z),
|
|
||||||
)
|
|
||||||
val texturePositions = arrayOf(
|
|
||||||
Vec2(uvEnd.x, uvStart.y),
|
|
||||||
uvStart,
|
|
||||||
Vec2(uvStart.x, uvEnd.y),
|
|
||||||
uvEnd,
|
|
||||||
)
|
|
||||||
|
|
||||||
for ((vertexIndex, textureIndex) in TRIANGLE_TO_QUAD_ORDER) {
|
|
||||||
vertexConsumer.invoke(positions[vertexIndex], texturePositions[textureIndex])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.AbstractTex
|
|||||||
import glm_.vec2.Vec2
|
import glm_.vec2.Vec2
|
||||||
import glm_.vec3.Vec3
|
import glm_.vec3.Vec3
|
||||||
|
|
||||||
open class SimpleTextureMesh(renderWindow: RenderWindow, primitiveType: PrimitiveTypes) : Mesh(renderWindow, SimpleTextureMeshStruct, primitiveType, initialCacheSize = 2 * 3 * SimpleTextureMeshStruct.FLOATS_PER_VERTEX) {
|
open class SimpleTextureMesh(renderWindow: RenderWindow, primitiveType: PrimitiveTypes = renderWindow.renderSystem.preferredPrimitiveType) : Mesh(renderWindow, SimpleTextureMeshStruct, primitiveType, initialCacheSize = 2 * 3 * SimpleTextureMeshStruct.FLOATS_PER_VERTEX) {
|
||||||
|
|
||||||
fun addVertex(position: Vec3, texture: AbstractTexture, uv: Vec2, tintColor: RGBColor) {
|
fun addVertex(position: Vec3, texture: AbstractTexture, uv: Vec2, tintColor: RGBColor) {
|
||||||
data.addAll(
|
data.addAll(
|
||||||
@ -32,6 +32,7 @@ open class SimpleTextureMesh(renderWindow: RenderWindow, primitiveType: Primitiv
|
|||||||
uv.x,
|
uv.x,
|
||||||
uv.y,
|
uv.y,
|
||||||
Float.fromBits(texture.renderData?.shaderTextureId ?: RenderConstants.DEBUG_TEXTURE_ID),
|
Float.fromBits(texture.renderData?.shaderTextureId ?: RenderConstants.DEBUG_TEXTURE_ID),
|
||||||
|
Float.fromBits(tintColor.rgba)
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,6 +41,7 @@ open class SimpleTextureMesh(renderWindow: RenderWindow, primitiveType: Primitiv
|
|||||||
val position: Vec3,
|
val position: Vec3,
|
||||||
val uv: Vec2,
|
val uv: Vec2,
|
||||||
val indexLayerAnimation: Int,
|
val indexLayerAnimation: Int,
|
||||||
|
val tint: RGBColor,
|
||||||
) {
|
) {
|
||||||
companion object : MeshStruct(SimpleTextureMeshStruct::class)
|
companion object : MeshStruct(SimpleTextureMeshStruct::class)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user