Minecraft 1.21.5 brought on an onslaught of rendering engine changes, including a complete overhaul of how the rendering pipeline works as a whole. All the existing APIs in OmniCore were nigh impossible to migrate over to the new pipeline structure.
In turn, this gave us the opportunity to completely redo our own rendering APIs from the ground up to be more efficient, flexible, easier to use and have contextual awareness of the rendering pipeline, also making your experience writing rendering code richer, more powerful and more compatible.
The OmniRenderState class has been deprecated in favor of the new OmniRenderPipeline API, which generally covers all of it's bases, and is rather used to manage GL states and per-frame render passes. This means that you will no longer have global render state, but rather state per render pass. This allows for more flexibility and better performance, as the rendering engine can now optimize the state changes based on the current render pass.
Replacement is a bit tricky depending on how you were using OmniRenderState previously. All of it's methods have been split into several different state classes which are used to individually manage GL states. These classes are:
OmniManagedAlphaStateOmniManagedBlendStateOmniManagedColorLogicOmniManagedColorMaskOmniManagedDepthStateOmniManagedPolygonOffsetOmniManageScissorState
All of these classes should be constructed as you do any other class, or using their applicable DISABLED field or asEnabled method, and then applied using the activate method.
Take this example:
OmniRenderState.enableDepth()
OmniRenderState.enableAlpha()To replace all of it, you'd do this:
OmniManagedDepthState.asEnabled().activate()
OmniManagedAlphaState.asEnabled().activate()The OmniTessellator class has been deprecated in favor of the new OmniBufferBuilder & OmniBuiltBuffer classes. These APIs are outwardly nearly identical aside from how you attain an instance of the buffer builder itself. The new API makes good use of the new rendering pipeline APIs and should be a good bit more performant than the old one.
Thankfully, as was stated, the API is nearly identical, so you should be able to replace it with minimal effort. The only major difference is that the new API uses OmniBufferBuilder instead of OmniTessellator, and the build method now returns an OmniBuiltBuffer instead of you being able to directly draw your automatically built buffer. This is because the new rendering pipeline is now responsible for drawing the buffer. In order for your built buffer to be drawn, you must create your own OmniRenderPipeline instance and call your built buffer's draw method using it.
This is a bit of a change, but it allows for more flexibility and better performance, as the rendering engine can now optimize the buffer drawing based on the current render pass.
Your old code may look something a bit like this:
val x = 50f
val y = 50f
val width = 100f
val height = 100f
val tessellator = OmniTessellator.getFromBuffer()
tessellator.beginWithDefaultShader(OmniTessellator.DrawModes.QUADS, OmniTessellator.VertexFormats.POSITION_TEXTURE_COLOR)
tessellator
.vertex(stack, x, y + height, 0f)
.texture(0f, 0f)
.color(color)
.next()
tessellator
.vertex(stack, x + width, y + height, 0f)
.texture(1f, 0f)
.color(color)
.next()
tessellator
.vertex(stack, x + width, y, 0f)
.texture(1f, 1f)
.color(color)
.next()
tessellator
.vertex(stack, x, y, 0f)
.texture(0f, 1f)
.color(color)
.next()
tessellator.draw()Migrating that to the new API would look a bit like this:
private val PIPELINE by lazy {
OmniRenderPipeline.builderWithDefaultShader(
identifier = OmniIdentifier.create("example_mod", "example_pipeline"),
vertexFormat = VertexFormats.POSITION_TEXTURE_COLOR,
mode = DrawModes.QUADS,
).apply {
blendState = OmniManagedBlendState.asEnabled(BlendEquation.active(), BlendFunction.LIGHTMAP)
depthState = OmniManagedDepthState.DISABLED
}.build()
}
val buffer = OmniBufferBuilder.create(DrawModes.QUADS, VertexFormats.POSITION_TEXTURE_COLOR)
buffer
.vertex(stack, x.toDouble(), (y + height).toDouble(), 0.0)
.texture(0.0, 0.0)
.color(color)
.next()
buffer
.vertex(stack, (x + width).toDouble(), (y + height).toDouble(), 0.0)
.texture(1.0, 0.0)
.color(color)
.next()
buffer
.vertex(stack, (x + width).toDouble(), y.toDouble(), 0.0)
.texture(1.0, 1.0)
.color(color)
.next()
buffer
.vertex(stack, x.toDouble(), y.toDouble(), 0.0)
.texture(0.0, 1.0)
.color(color)
.next()
buffer.build()?.drawWithCleanup(PIPELINE) {
texture(0, yourTexturesGlId) // This is assigned to Sampler0 in the shader
}