mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-16 13:34:06 +09:00
adding test code to export fboRGB
This commit is contained in:
@@ -2,7 +2,6 @@ package net.torvald.terrarum.worlddrawer
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.*
|
||||
import com.badlogic.gdx.graphics.glutils.FrameBuffer
|
||||
import com.badlogic.gdx.math.Matrix4
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.AppLoader.printdbg
|
||||
@@ -347,43 +346,34 @@ internal object BlocksDrawer {
|
||||
drawTiles(FLUID)
|
||||
}
|
||||
|
||||
internal fun drawWall(projectionMatrix: Matrix4, backbuffer: FrameBuffer) {
|
||||
// blend normal
|
||||
Gdx.gl.glEnable(GL20.GL_TEXTURE_2D)
|
||||
Gdx.gl.glEnable(GL20.GL_BLEND)
|
||||
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA)
|
||||
internal fun drawWall(projectionMatrix: Matrix4) {
|
||||
gdxSetBlendNormal()
|
||||
|
||||
renderUsingBuffer(WALL, projectionMatrix, backbuffer)
|
||||
renderUsingBuffer(WALL, projectionMatrix)
|
||||
}
|
||||
|
||||
internal fun drawTerrain(projectionMatrix: Matrix4, backbuffer: FrameBuffer) {
|
||||
// blend normal
|
||||
Gdx.gl.glEnable(GL20.GL_TEXTURE_2D)
|
||||
Gdx.gl.glEnable(GL20.GL_BLEND)
|
||||
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA)
|
||||
internal fun drawTerrain(projectionMatrix: Matrix4) {
|
||||
gdxSetBlendNormal()
|
||||
|
||||
renderUsingBuffer(TERRAIN, projectionMatrix, backbuffer)
|
||||
renderUsingBuffer(FLUID, projectionMatrix, backbuffer)
|
||||
renderUsingBuffer(TERRAIN, projectionMatrix)
|
||||
renderUsingBuffer(FLUID, projectionMatrix)
|
||||
}
|
||||
|
||||
internal fun drawFront(projectionMatrix: Matrix4, drawWires: Boolean, backbuffer: FrameBuffer) {
|
||||
internal fun drawFront(projectionMatrix: Matrix4, drawWires: Boolean) {
|
||||
// blend mul
|
||||
Gdx.gl.glEnable(GL20.GL_TEXTURE_2D)
|
||||
Gdx.gl.glEnable(GL20.GL_BLEND)
|
||||
Gdx.gl.glBlendFunc(GL20.GL_DST_COLOR, GL20.GL_ONE_MINUS_SRC_ALPHA)
|
||||
|
||||
// let's just not MUL on terrain, make it FLUID only...
|
||||
renderUsingBuffer(FLUID, projectionMatrix, backbuffer)
|
||||
renderUsingBuffer(FLUID, projectionMatrix)
|
||||
|
||||
|
||||
|
||||
// blend normal
|
||||
Gdx.gl.glEnable(GL20.GL_TEXTURE_2D)
|
||||
Gdx.gl.glEnable(GL20.GL_BLEND)
|
||||
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA)
|
||||
gdxSetBlendNormal()
|
||||
|
||||
if (drawWires) {
|
||||
renderUsingBuffer(WIRE, projectionMatrix, backbuffer)
|
||||
renderUsingBuffer(WIRE, projectionMatrix)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -685,7 +675,7 @@ internal object BlocksDrawer {
|
||||
|
||||
private var _tilesBufferAsTex: Texture = Texture(1, 1, Pixmap.Format.RGBA8888)
|
||||
|
||||
private fun renderUsingBuffer(mode: Int, projectionMatrix: Matrix4, backbuffer: FrameBuffer) {
|
||||
private fun renderUsingBuffer(mode: Int, projectionMatrix: Matrix4) {
|
||||
//Gdx.gl.glClearColor(.094f, .094f, .094f, 0f)
|
||||
//Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
|
||||
|
||||
@@ -728,7 +718,6 @@ internal object BlocksDrawer {
|
||||
_tilesBufferAsTex.dispose()
|
||||
_tilesBufferAsTex = Texture(tilesBuffer)
|
||||
_tilesBufferAsTex.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest)
|
||||
backbuffer.colorBufferTexture.bind(3)
|
||||
tilesTerrainBlend.texture.bind(2)
|
||||
_tilesBufferAsTex.bind(1) // trying 1 and 0...
|
||||
tileAtlas.texture.bind(0) // for some fuck reason, it must be bound as last
|
||||
@@ -740,7 +729,6 @@ internal object BlocksDrawer {
|
||||
shader.setUniformi("tilesAtlas", 0)
|
||||
shader.setUniformi("tilesBlendAtlas", 2)
|
||||
shader.setUniformi("tilemap", 1)
|
||||
shader.setUniformi("backbuffer", 3)
|
||||
shader.setUniformi("tilemapDimension", tilesBuffer.width, tilesBuffer.height)
|
||||
shader.setUniformf("tilesInAxes", tilesInHorizontal.toFloat(), tilesInVertical.toFloat())
|
||||
shader.setUniformi("cameraTranslation", WorldCamera.x fmod TILE_SIZE, WorldCamera.y fmod TILE_SIZE) // usage of 'fmod' and '%' were depend on the for_x_start, which I can't just do naive int div
|
||||
|
||||
Reference in New Issue
Block a user