the f'ing computer now renders

This commit is contained in:
minjaesong
2021-12-05 11:12:30 +09:00
parent bcae2b0ded
commit 6c62d1e2ae
3 changed files with 9 additions and 13 deletions

Binary file not shown.

View File

@@ -99,13 +99,13 @@ internal class UIHomeComputer : UICanvas(
init { init {
batch = SpriteBatch() batch = SpriteBatch()
camera = OrthographicCamera(560f, 448f) camera = OrthographicCamera(width.toFloat(), height.toFloat())
//val m = Matrix4() //val m = Matrix4()
//m.setToOrtho2D(0f, 0f, width.toFloat(), height.toFloat()) //m.setToOrtho2D(0f, 0f, width.toFloat(), height.toFloat())
batch.projectionMatrix = camera.combined batch.projectionMatrix = camera.combined
} }
private val fbo = FrameBuffer(Pixmap.Format.RGBA8888, 560, 448, true) private val fbo = FrameBuffer(Pixmap.Format.RGBA8888, width, height, true)
override fun updateUI(delta: Float) { override fun updateUI(delta: Float) {
} }
@@ -113,29 +113,25 @@ internal class UIHomeComputer : UICanvas(
override fun renderUI(otherBatch: SpriteBatch, otherCamera: Camera) { override fun renderUI(otherBatch: SpriteBatch, otherCamera: Camera) {
otherBatch.end() otherBatch.end()
fbo.inAction(otherCamera as OrthographicCamera, otherBatch) { fbo.inAction(camera, batch) {
(vm.peripheralTable[1].peripheral as? GraphicsAdapter)?.let { gpu -> (vm.peripheralTable[1].peripheral as? GraphicsAdapter)?.let { gpu ->
val clearCol = gpu.getBackgroundColour() val clearCol = gpu.getBackgroundColour()
Gdx.gl.glClearColor(0f,0f,0f,0f) Gdx.gl.glClearColor(clearCol.r, clearCol.g, clearCol.b, clearCol.a)
//Gdx.gl.glClearColor(clearCol.r, clearCol.g, clearCol.b, clearCol.a) Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
//Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
gpu.render(Gdx.graphics.deltaTime, otherBatch, 0f, 0f, true) gpu.render(Gdx.graphics.deltaTime, batch, drawOffX, drawOffY, true, fbo) // gpu.render will internally end() the fbo then begin() again before using the batch I've fed in
} }
} }
otherBatch.begin() otherBatch.begin()
otherBatch.shader = null
blendNormal(otherBatch)
otherBatch.color = Color.WHITE otherBatch.color = Color.WHITE
otherBatch.draw(fbo.colorBufferTexture, posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat()) otherBatch.draw(fbo.colorBufferTexture, posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
otherBatch.color = Toolkit.Theme.COL_INACTIVE otherBatch.color = Toolkit.Theme.COL_INACTIVE
Toolkit.drawBoxBorder(otherBatch, posX - 1, posY - 1, width + 2, height + 2) Toolkit.drawBoxBorder(otherBatch, posX - 1, posY - 1, width + 2, height + 2)
} }
private fun setCameraPosition(newX: Float, newY: Float) {
// camera.position.set((-newX + width / 2), (-newY + height / 2), 0f) // deliberate integer division
// camera.update()
// batch.projectionMatrix = camera.combined
}
override fun doOpening(delta: Float) { override fun doOpening(delta: Float) {
} }