cheaper/more proper checkerboard background render (still bad)
:trolley:
This commit is contained in:
parent
ee700c442e
commit
122ebb9688
@ -105,6 +105,58 @@ fun GuiGraphics.renderRect(
|
|||||||
renderRect(pose().last().pose(), x, y, width, height, z, color)
|
renderRect(pose().last().pose(), x, y, width, height, z, color)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("NAME_SHADOWING")
|
||||||
|
fun renderCheckerboard(
|
||||||
|
matrix: Matrix4f,
|
||||||
|
x: Float,
|
||||||
|
y: Float,
|
||||||
|
width: Float,
|
||||||
|
height: Float,
|
||||||
|
z: Float = 0f,
|
||||||
|
color: RGBAColor = RGBAColor.WHITE
|
||||||
|
) {
|
||||||
|
RenderSystem.setShader(GameRenderer::getPositionColorShader)
|
||||||
|
|
||||||
|
RenderSystem.enableBlend()
|
||||||
|
RenderSystem.defaultBlendFunc()
|
||||||
|
|
||||||
|
if (!is3DContext)
|
||||||
|
RenderSystem.depthFunc(GL_ALWAYS)
|
||||||
|
|
||||||
|
val tess = tesselator
|
||||||
|
val builder = tess.builder
|
||||||
|
|
||||||
|
builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR)
|
||||||
|
|
||||||
|
for (i in 0 ..< width.toInt()) {
|
||||||
|
val x = x + i.toFloat()
|
||||||
|
|
||||||
|
for (j in 0 ..< height.toInt()) {
|
||||||
|
val y = y + j.toFloat()
|
||||||
|
|
||||||
|
if ((i + j) % 2 == 0) {
|
||||||
|
builder.vertex(matrix, x, y + 1f, z).color(color).endVertex()
|
||||||
|
builder.vertex(matrix, x + 1f, y + 1f, z).color(color).endVertex()
|
||||||
|
builder.vertex(matrix, x + 1f, y, z).color(color).endVertex()
|
||||||
|
builder.vertex(matrix, x, y, z).color(color).endVertex()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tess.end()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun GuiGraphics.renderCheckerboard(
|
||||||
|
x: Float,
|
||||||
|
y: Float,
|
||||||
|
width: Float,
|
||||||
|
height: Float,
|
||||||
|
z: Float = 0f,
|
||||||
|
color: RGBAColor = RGBAColor.WHITE
|
||||||
|
) {
|
||||||
|
renderCheckerboard(pose().last().pose(), x, y, width, height, z, color)
|
||||||
|
}
|
||||||
|
|
||||||
fun renderTexturedRect(
|
fun renderTexturedRect(
|
||||||
matrix: Matrix4f,
|
matrix: Matrix4f,
|
||||||
x: Float,
|
x: Float,
|
||||||
|
@ -13,6 +13,7 @@ import net.minecraftforge.registries.ForgeRegistries
|
|||||||
import ru.dbotthepony.mc.otm.block.entity.decorative.PainterBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.decorative.PainterBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.client.render.FlatRectangleIcon
|
import ru.dbotthepony.mc.otm.client.render.FlatRectangleIcon
|
||||||
import ru.dbotthepony.mc.otm.client.render.ItemStackIcon
|
import ru.dbotthepony.mc.otm.client.render.ItemStackIcon
|
||||||
|
import ru.dbotthepony.mc.otm.client.render.renderCheckerboard
|
||||||
import ru.dbotthepony.mc.otm.client.render.renderRect
|
import ru.dbotthepony.mc.otm.client.render.renderRect
|
||||||
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
||||||
import ru.dbotthepony.mc.otm.client.screen.panels.Dock
|
import ru.dbotthepony.mc.otm.client.screen.panels.Dock
|
||||||
@ -53,13 +54,7 @@ class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) :
|
|||||||
|
|
||||||
val color = RGBAColor.rgb(dye?.textColor ?: DyeColor.LIGHT_BLUE.textColor)
|
val color = RGBAColor.rgb(dye?.textColor ?: DyeColor.LIGHT_BLUE.textColor)
|
||||||
|
|
||||||
val bgColor = color.copy(alpha = 0.25f)
|
graphics.renderCheckerboard(0f, 0f, width, height, color = color.copy(alpha = 0.25f))
|
||||||
for (x in 0 ..< width.toInt()) {
|
|
||||||
for (y in 0 ..< height.toInt()) {
|
|
||||||
if ((x + y) % 2 == 0)
|
|
||||||
graphics.renderRect(x.toFloat(), y.toFloat(), 1f, 1f, color = bgColor)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val multiplier = menu.dyeStoredDirect[dye]!!.toFloat() / (if (dye == null) PainterBlockEntity.MAX_WATER_STORAGE.toFloat() else PainterBlockEntity.MAX_STORAGE.toFloat())
|
val multiplier = menu.dyeStoredDirect[dye]!!.toFloat() / (if (dye == null) PainterBlockEntity.MAX_WATER_STORAGE.toFloat() else PainterBlockEntity.MAX_STORAGE.toFloat())
|
||||||
graphics.renderRect(0f, height * (1f - multiplier), width, height * multiplier, color = color)
|
graphics.renderRect(0f, height * (1f - multiplier), width, height * multiplier, color = color)
|
||||||
|
Loading…
Reference in New Issue
Block a user