using gl32 shaders for other runnables

This commit is contained in:
minjaesong
2023-02-28 22:59:32 +09:00
parent e13cfd37b0
commit 2474583a86
9 changed files with 12 additions and 13 deletions

View File

@@ -9,7 +9,6 @@ import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.badlogic.gdx.controllers.Controllers;
import com.badlogic.gdx.graphics.*;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.*;
import com.badlogic.gdx.utils.Disposable;
@@ -51,7 +50,6 @@ import java.lang.reflect.Field;
import java.util.*;
import static net.torvald.terrarum.TerrarumKt.*;
import static org.lwjgl.glfw.GLFW.*;
/**
* The framework's Application Loader
@@ -314,7 +312,7 @@ public class App implements ApplicationListener {
}
public static ShapeRenderer makeShapeRenderer() {
return new ShapeRenderer(5000, MacosGL32Shaders.INSTANCE.createShapeRendererShader());
return new ShapeRenderer(5000, DefaultGL32Shaders.INSTANCE.createShapeRendererShader());
}
public static void main(String[] args) {

View File

@@ -6,7 +6,7 @@ import com.badlogic.gdx.graphics.glutils.ShaderProgram
/**
* Created by minjaesong on 2023-02-28
*/
object MacosGL32Shaders {
object DefaultGL32Shaders {
fun createSpriteBatchShader(): ShaderProgram {
return App.loadShaderFromClasspath("shaders/gl32spritebatch.vert", "shaders/gl32spritebatch.frag")
}

View File

@@ -29,7 +29,7 @@ object ErrorDisp : Screen {
override fun show() {
batch = SpriteBatch()
batch = SpriteBatch(1000, DefaultGL32Shaders.createSpriteBatchShader())
camera = OrthographicCamera(Gdx.graphics.width.toFloat(), Gdx.graphics.height.toFloat())

View File

@@ -9,7 +9,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion
*
* Created by minjaesong on 2021-12-13.
*/
class FlippingSpriteBatch(size: Int = 1000) : SpriteBatch(size, MacosGL32Shaders.createSpriteBatchShader()) {
class FlippingSpriteBatch(size: Int = 1000) : SpriteBatch(size, DefaultGL32Shaders.createSpriteBatchShader()) {
/**
* This function draws the flipped version of the image by giving flipped uv-coord to the SpriteBatch

View File

@@ -33,7 +33,7 @@ class NoModuleDefaultTitlescreen(batch: FlippingSpriteBatch) : IngameInstance(ba
private var gamemode = 0
private val fbatch = SpriteBatch()
private val fbatch = SpriteBatch(1000, DefaultGL32Shaders.createSpriteBatchShader())
private val genericBackdrop = Toolkit.Theme.COL_CELL_FILL.cpy().add(0f,0f,0f,1f)
private val winTenBackdrop = Color(0x1070AAFF)

View File

@@ -10,6 +10,7 @@ import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.unicode.EMDASH
import net.torvald.gdx.graphics.PixmapIO2
import net.torvald.terrarum.DefaultGL32Shaders
import net.torvald.terrarum.gdxClearAndEnableBlend
import net.torvald.terrarum.inUse
import java.awt.BorderLayout
@@ -263,7 +264,7 @@ class SpriteAssemblerPreview: Game() {
override fun create() {
Gdx.graphics.setTitle("Sprite Assembler Preview")
batch = SpriteBatch()
batch = SpriteBatch(1000, DefaultGL32Shaders.createSpriteBatchShader())
renderTexture = Texture(1, 1, Pixmap.Format.RGBA8888)
}

View File

@@ -18,6 +18,7 @@ import com.sudoplay.joise.module.ModuleFractal
import com.sudoplay.joise.module.ModuleScaleOffset
import net.torvald.random.HQRNG
import net.torvald.terrarum.App
import net.torvald.terrarum.DefaultGL32Shaders
import net.torvald.terrarum.concurrent.ThreadExecutor
import net.torvald.terrarum.concurrent.sliceEvenly
import net.torvald.terrarum.inUse
@@ -45,7 +46,7 @@ class NoiseGenerator : ScreenAdapter() {
override fun show() {
Gdx.input.inputProcessor = NoiseGeneratorController(this)
batch = SpriteBatch()
batch = SpriteBatch(1000, DefaultGL32Shaders.createSpriteBatchShader())
camera = OrthographicCamera(App.scr.wf, App.scr.hf)
camera.setToOrtho(true, App.scr.wf, App.scr.hf)

View File

@@ -35,7 +35,7 @@ class UIElemTest : ApplicationAdapter() {
256, false, 0.5f, false
)
batch = SpriteBatch()
batch = SpriteBatch(1000, DefaultGL32Shaders.createSpriteBatchShader())
camera = OrthographicCamera()
camera.setToOrtho(true, 800f, 600f)
camera.update()

View File

@@ -14,8 +14,8 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.glutils.ShaderProgram
import com.sudoplay.joise.Joise
import com.sudoplay.joise.module.*
import net.torvald.unsafe.UnsafeHelper
import net.torvald.random.HQRNG
import net.torvald.terrarum.DefaultGL32Shaders
import net.torvald.terrarum.concurrent.*
import net.torvald.terrarum.gameworld.fmod
import net.torvald.terrarum.inUse
@@ -27,7 +27,6 @@ import java.util.concurrent.Future
import kotlin.math.cos
import kotlin.math.sin
import kotlin.random.Random
import kotlin.coroutines.*
const val NOISEBOX_WIDTH = 768
const val NOISEBOX_HEIGHT = 512
@@ -61,7 +60,7 @@ class WorldgenNoiseSandbox : ApplicationAdapter() {
override fun create() {
font = BitmapFont() // use default because fuck it
batch = SpriteBatch()
batch = SpriteBatch(1000, DefaultGL32Shaders.createSpriteBatchShader())
camera = OrthographicCamera(NOISEBOX_WIDTH.toFloat(), NOISEBOX_HEIGHT.toFloat())
camera.setToOrtho(false) // some elements are pre-flipped, while some are not. The statement itself is absolutely necessary to make edge of the screen as the origin
camera.update()