From 736edb506951e257373cedfe39bb87d47de21c6e Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sun, 8 Dec 2019 11:22:46 +0200 Subject: [PATCH] Back to the way it was - we only need the shader if we're using GL 3.0 apparently Let's stick to 2.0 for now --- .../unciv/ui/utils/CameraStageBaseScreen.kt | 42 +------------------ 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt b/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt index 19083bdf31..0c0cffaac9 100644 --- a/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt +++ b/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt @@ -1,6 +1,5 @@ package com.unciv.ui.utils -import com.badlogic.gdx.Application import com.badlogic.gdx.Gdx import com.badlogic.gdx.Input import com.badlogic.gdx.Screen @@ -8,7 +7,6 @@ import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.GL20 import com.badlogic.gdx.graphics.g2d.Batch import com.badlogic.gdx.graphics.g2d.SpriteBatch -import com.badlogic.gdx.graphics.glutils.ShaderProgram import com.badlogic.gdx.scenes.scene2d.* import com.badlogic.gdx.scenes.scene2d.ui.* import com.badlogic.gdx.scenes.scene2d.utils.ClickListener @@ -75,45 +73,7 @@ open class CameraStageBaseScreen : Screen { skin.get(SelectBox.SelectBoxStyle::class.java).listStyle.font = Fonts().getFont(45).apply { data.setScale(20/45f) } skin.get(CheckBox.CheckBoxStyle::class.java).fontColor= Color.WHITE } - internal var batch: Batch = if(Gdx.app.type == Application.ApplicationType.Android) SpriteBatch() else SpriteBatch(1000, createDefaultShader()) - - // This is so the MacOS works with GL 3.0, see https://github.com/yairm210/Unciv/issues/1428 - fun createDefaultShader(): ShaderProgram? { - val vertexShader = ("#version 330 core\n" - + "in vec4 " + ShaderProgram.POSITION_ATTRIBUTE + ";\n" // - + "in vec4 " + ShaderProgram.COLOR_ATTRIBUTE + ";\n" // - + "in vec2 " + ShaderProgram.TEXCOORD_ATTRIBUTE + "0;\n" // - + "uniform mat4 u_projTrans;\n" // - + "out vec4 v_color;\n" // - + "out vec2 v_texCoords;\n" // - + "\n" // - + "void main()\n" // - + "{\n" // - + " v_color = " + ShaderProgram.COLOR_ATTRIBUTE + ";\n" // - + " v_color.a = v_color.a * (255.0/254.0);\n" // - + " v_texCoords = " + ShaderProgram.TEXCOORD_ATTRIBUTE + "0;\n" // - + " gl_Position = u_projTrans * " + ShaderProgram.POSITION_ATTRIBUTE + ";\n" // - + "}\n") - val fragmentShader = ("#version 330 core\n" - + "#ifdef GL_ES\n" // - + "#define LOWP lowp\n" // - + "precision mediump float;\n" // - + "#else\n" // - + "#define LOWP \n" // - + "#endif\n" // - + "in LOWP vec4 v_color;\n" // - + "in vec2 v_texCoords;\n" // - + "out vec4 fragColor;\n" // - + "uniform sampler2D u_texture;\n" // - + "void main()\n" // - + "{\n" // - + " fragColor = v_color * texture(u_texture, v_texCoords);\n" // - + "}") - val shader = ShaderProgram(vertexShader, fragmentShader) - require(shader.isCompiled) { "Error compiling shader: " + shader.log } - return shader - } - + internal var batch: Batch = SpriteBatch() } fun onBackButtonClicked(action:()->Unit){