mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
opengl: Remove GlslHighpSupported
This commit is contained in:
parent
85d39699d3
commit
d46d9ac7c2
@ -14,12 +14,6 @@
|
||||
|
||||
package graphics
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/internal/opengl"
|
||||
)
|
||||
|
||||
type shaderId int
|
||||
|
||||
const (
|
||||
@ -28,18 +22,17 @@ const (
|
||||
)
|
||||
|
||||
func shader(id shaderId) string {
|
||||
str := shaders[id]
|
||||
if !opengl.GetContext().GlslHighpSupported() {
|
||||
str = strings.Replace(str, "highp ", "", -1)
|
||||
str = strings.Replace(str, "lowp ", "", -1)
|
||||
}
|
||||
return str
|
||||
return shaders[id]
|
||||
}
|
||||
|
||||
var shaders = map[shaderId]string{
|
||||
shaderVertexModelview: `
|
||||
#ifdef GL_ES
|
||||
#if defined(GL_ES)
|
||||
precision highp float;
|
||||
#else
|
||||
#define lowp
|
||||
#define mediump
|
||||
#define highp
|
||||
#endif
|
||||
|
||||
uniform highp mat4 projection_matrix;
|
||||
@ -47,7 +40,7 @@ attribute highp vec2 vertex;
|
||||
attribute highp vec2 tex_coord;
|
||||
attribute highp vec4 geo_matrix_body;
|
||||
attribute highp vec2 geo_matrix_translation;
|
||||
varying highp vec2 vertex_out_tex_coord;
|
||||
varying vec2 vertex_out_tex_coord;
|
||||
|
||||
void main(void) {
|
||||
vertex_out_tex_coord = tex_coord;
|
||||
@ -61,14 +54,22 @@ void main(void) {
|
||||
}
|
||||
`,
|
||||
shaderFragmentTexture: `
|
||||
#ifdef GL_ES
|
||||
#if defined(GL_ES)
|
||||
precision mediump float;
|
||||
#else
|
||||
#define lowp
|
||||
#define mediump
|
||||
#define highp
|
||||
#endif
|
||||
|
||||
uniform lowp sampler2D texture;
|
||||
uniform lowp mat4 color_matrix;
|
||||
uniform lowp vec4 color_matrix_translation;
|
||||
#if defined(GL_ES) && defined(GL_FRAGMENT_PRECISION_HIGH)
|
||||
varying highp vec2 vertex_out_tex_coord;
|
||||
#else
|
||||
varying vec2 vertex_out_tex_coord;
|
||||
#endif
|
||||
|
||||
void main(void) {
|
||||
lowp vec4 color = texture2D(texture, vertex_out_tex_coord);
|
||||
|
@ -355,10 +355,6 @@ func (c *Context) DeleteShader(s Shader) {
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Context) GlslHighpSupported() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (c *Context) NewProgram(shaders []Shader) (Program, error) {
|
||||
var program Program
|
||||
if err := c.runOnContextThread(func() error {
|
||||
|
@ -310,15 +310,6 @@ func (c *Context) DeleteShader(s Shader) {
|
||||
gl.DeleteShader(s.Object)
|
||||
}
|
||||
|
||||
func (c *Context) GlslHighpSupported() bool {
|
||||
gl := c.gl
|
||||
// headless-gl library may not define getShaderPrecisionFormat.
|
||||
if gl.Get("getShaderPrecisionFormat") == js.Undefined {
|
||||
return false
|
||||
}
|
||||
return gl.Call("getShaderPrecisionFormat", gl.FRAGMENT_SHADER, gl.HIGH_FLOAT).Get("precision").Int() != 0
|
||||
}
|
||||
|
||||
func (c *Context) NewProgram(shaders []Shader) (Program, error) {
|
||||
gl := c.gl
|
||||
p := gl.CreateProgram()
|
||||
|
@ -270,17 +270,6 @@ func (c *Context) DeleteShader(s Shader) {
|
||||
gl.DeleteShader(mgl.Shader(s))
|
||||
}
|
||||
|
||||
func (c *Context) GlslHighpSupported() bool {
|
||||
gl := c.gl
|
||||
_, _, precision := gl.GetShaderPrecisionFormat(mgl.FRAGMENT_SHADER, mgl.HIGH_FLOAT)
|
||||
// On Android emulators, precision might be a wrong value (#239).
|
||||
// TODO: If possible, check if this is running on an emulator.
|
||||
if 64 <= precision {
|
||||
return false
|
||||
}
|
||||
return precision != 0
|
||||
}
|
||||
|
||||
func (c *Context) NewProgram(shaders []Shader) (Program, error) {
|
||||
gl := c.gl
|
||||
p := gl.CreateProgram()
|
||||
|
Loading…
Reference in New Issue
Block a user