mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 20:14:05 +09:00
still broken, still renders
because im going to break it once again See my comment in PostProcessor.kt
This commit is contained in:
@@ -2,16 +2,21 @@ package net.torvald.terrarum
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.GL20
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import com.badlogic.gdx.graphics.glutils.FrameBuffer
|
||||
import kotlin.system.measureNanoTime
|
||||
|
||||
/**
|
||||
* Must be called by the App Loader
|
||||
*/
|
||||
object PostProcessor {
|
||||
|
||||
private val batch = SpriteBatch()
|
||||
private lateinit var batch: SpriteBatch // not nulling to save some lines of code
|
||||
private var textureRegion: TextureRegion? = null
|
||||
|
||||
|
||||
private lateinit var lutTex: Texture
|
||||
|
||||
@@ -19,21 +24,48 @@ object PostProcessor {
|
||||
lutTex = Texture(Gdx.files.internal("assets/clut/$filename"))
|
||||
}
|
||||
|
||||
fun draw(screenTexHolder: FrameBuffer) {
|
||||
//Gdx.gl.glClearColor(.094f, .094f, .094f, 1f)
|
||||
fun draw(fbo: FrameBuffer) {
|
||||
//Gdx.gl.glClearColor(.094f, .094f, .094f, 0f)
|
||||
//Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
|
||||
//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)
|
||||
|
||||
|
||||
batch.shader = Terrarum.shader18Bit // essential design decision; 262 144 colours VGA; NOT related with LCD monitor's internals
|
||||
batch.inUse {
|
||||
val texture = screenTexHolder.colorBufferTexture
|
||||
batch.shader.setUniformMatrix("u_projTrans", batch.projectionMatrix)
|
||||
batch.draw(texture, 0f, 0f, texture.width.toFloat(), texture.height.toFloat())
|
||||
if (textureRegion == null) {
|
||||
textureRegion = TextureRegion(fbo.colorBufferTexture)
|
||||
batch = SpriteBatch()
|
||||
}
|
||||
|
||||
|
||||
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0) // don't know why it is needed; it really depresses me
|
||||
// FIXME something's really fucked between sky_gradient and the actual_world_render,
|
||||
// maybe overlaying world over grad
|
||||
// OR mixing lightmap (less likely?)
|
||||
// known symptom: when localising the spritebatch, greyscale lightmap and the UI are the
|
||||
// only thing gets drawn
|
||||
|
||||
|
||||
|
||||
|
||||
Terrarum.debugTimers["GFX.PostProcessor"] = measureNanoTime {
|
||||
|
||||
val shader = AppLoader.shader18Bit
|
||||
|
||||
// no-screen screen renders but the game don't? wtf?
|
||||
|
||||
batch.inUse {
|
||||
|
||||
batch.shader = shader
|
||||
shader.setUniformf("resolution", AppLoader.appConfig.width.toFloat(), AppLoader.appConfig.height.toFloat())
|
||||
batch.draw(textureRegion, 0f, 0f)
|
||||
|
||||
}
|
||||
|
||||
|
||||
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0) // don't know why it is needed; it really depresses me
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user