mirror of
https://github.com/love2d/love-android.git
synced 2026-08-19 04:05:22 +02:00
updated to latest mobile-common (should fix love.touch index problems)
This commit is contained in:
@@ -193,8 +193,16 @@ void Shader::createProgram(const std::vector<GLuint> &shaderids)
|
||||
if (!GLAD_ES_VERSION_2_0 && i <= int(OpenGL::ATTRIB_COLOR))
|
||||
continue;
|
||||
|
||||
OpenGL::VertexAttrib attrib = (OpenGL::VertexAttrib) i;
|
||||
|
||||
// FIXME: We skip this both because pseudo-instancing is temporarily
|
||||
// disabled (see graphics.lua), and because binding a non-existant
|
||||
// attribute name to a location causes a shader linker warning.
|
||||
if (attrib == OpenGL::ATTRIB_PSEUDO_INSTANCE_ID)
|
||||
continue;
|
||||
|
||||
const char *name = nullptr;
|
||||
if (attribNames.find((OpenGL::VertexAttrib) i, name))
|
||||
if (attribNames.find(attrib, name))
|
||||
glBindAttribLocation(program, i, (const GLchar *) name);
|
||||
}
|
||||
|
||||
@@ -254,7 +262,7 @@ void Shader::mapActiveUniforms()
|
||||
}
|
||||
|
||||
// If this is a built-in (LOVE-created) uniform, store the location.
|
||||
BuiltinExtern builtin;
|
||||
BuiltinUniform builtin;
|
||||
if (builtinNames.find(u.name.c_str(), builtin))
|
||||
builtinUniforms[int(builtin)] = u.location;
|
||||
|
||||
@@ -685,19 +693,36 @@ int Shader::getTextureUnit(const std::string &name)
|
||||
return texunit;
|
||||
}
|
||||
|
||||
Shader::UniformType Shader::getExternVariable(const std::string &name, int &components, int &count)
|
||||
{
|
||||
auto it = uniforms.find(name);
|
||||
|
||||
if (it == uniforms.end())
|
||||
{
|
||||
components = 0;
|
||||
count = 0;
|
||||
return UNIFORM_UNKNOWN;
|
||||
}
|
||||
|
||||
components = getUniformTypeSize(it->second.type);
|
||||
count = (int) it->second.count;
|
||||
|
||||
return it->second.baseType;
|
||||
}
|
||||
|
||||
bool Shader::hasVertexAttrib(OpenGL::VertexAttrib attrib) const
|
||||
{
|
||||
return vertexAttributes[int(attrib)] != -1;
|
||||
}
|
||||
|
||||
bool Shader::hasBuiltinExtern(BuiltinExtern builtin) const
|
||||
bool Shader::hasBuiltinUniform(BuiltinUniform builtin) const
|
||||
{
|
||||
return builtinUniforms[int(builtin)] != -1;
|
||||
}
|
||||
|
||||
bool Shader::sendBuiltinFloat(BuiltinExtern builtin, int size, const GLfloat *vec, int count)
|
||||
bool Shader::sendBuiltinFloat(BuiltinUniform builtin, int size, const GLfloat *vec, int count)
|
||||
{
|
||||
if (!hasBuiltinExtern(builtin))
|
||||
if (!hasBuiltinUniform(builtin))
|
||||
return false;
|
||||
|
||||
GLint location = builtinUniforms[int(builtin)];
|
||||
@@ -725,9 +750,9 @@ bool Shader::sendBuiltinFloat(BuiltinExtern builtin, int size, const GLfloat *ve
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Shader::sendBuiltinMatrix(BuiltinExtern builtin, int size, const GLfloat *m, int count)
|
||||
bool Shader::sendBuiltinMatrix(BuiltinUniform builtin, int size, const GLfloat *m, int count)
|
||||
{
|
||||
if (!hasBuiltinExtern(builtin))
|
||||
if (!hasBuiltinUniform(builtin))
|
||||
return false;
|
||||
|
||||
GLint location = builtinUniforms[GLint(builtin)];
|
||||
@@ -818,6 +843,16 @@ bool Shader::isSupported()
|
||||
return GLAD_ES_VERSION_2_0 || (GLAD_VERSION_2_0 && getGLSLVersion() >= "1.2");
|
||||
}
|
||||
|
||||
bool Shader::getConstant(const char *in, UniformType &out)
|
||||
{
|
||||
return uniformTypes.find(in, out);
|
||||
}
|
||||
|
||||
bool Shader::getConstant(UniformType in, const char *&out)
|
||||
{
|
||||
return uniformTypes.find(in, out);
|
||||
}
|
||||
|
||||
StringMap<Shader::ShaderType, Shader::TYPE_MAX_ENUM>::Entry Shader::typeNameEntries[] =
|
||||
{
|
||||
{"vertex", Shader::TYPE_VERTEX},
|
||||
@@ -826,6 +861,17 @@ StringMap<Shader::ShaderType, Shader::TYPE_MAX_ENUM>::Entry Shader::typeNameEntr
|
||||
|
||||
StringMap<Shader::ShaderType, Shader::TYPE_MAX_ENUM> Shader::typeNames(Shader::typeNameEntries, sizeof(Shader::typeNameEntries));
|
||||
|
||||
StringMap<Shader::UniformType, Shader::UNIFORM_MAX_ENUM>::Entry Shader::uniformTypeEntries[] =
|
||||
{
|
||||
{"float", Shader::UNIFORM_FLOAT},
|
||||
{"int", Shader::UNIFORM_INT},
|
||||
{"bool", Shader::UNIFORM_BOOL},
|
||||
{"image", Shader::UNIFORM_SAMPLER},
|
||||
{"unknown", Shader::UNIFORM_UNKNOWN},
|
||||
};
|
||||
|
||||
StringMap<Shader::UniformType, Shader::UNIFORM_MAX_ENUM> Shader::uniformTypes(Shader::uniformTypeEntries, sizeof(Shader::uniformTypeEntries));
|
||||
|
||||
StringMap<OpenGL::VertexAttrib, OpenGL::ATTRIB_MAX_ENUM>::Entry Shader::attribNameEntries[] =
|
||||
{
|
||||
{"VertexPosition", OpenGL::ATTRIB_POS},
|
||||
@@ -836,7 +882,7 @@ StringMap<OpenGL::VertexAttrib, OpenGL::ATTRIB_MAX_ENUM>::Entry Shader::attribNa
|
||||
|
||||
StringMap<OpenGL::VertexAttrib, OpenGL::ATTRIB_MAX_ENUM> Shader::attribNames(Shader::attribNameEntries, sizeof(Shader::attribNameEntries));
|
||||
|
||||
StringMap<Shader::BuiltinExtern, Shader::BUILTIN_MAX_ENUM>::Entry Shader::builtinNameEntries[] =
|
||||
StringMap<Shader::BuiltinUniform, Shader::BUILTIN_MAX_ENUM>::Entry Shader::builtinNameEntries[] =
|
||||
{
|
||||
{"TransformMatrix", Shader::BUILTIN_TRANSFORM_MATRIX},
|
||||
{"ProjectionMatrix", Shader::BUILTIN_PROJECTION_MATRIX},
|
||||
@@ -845,7 +891,7 @@ StringMap<Shader::BuiltinExtern, Shader::BUILTIN_MAX_ENUM>::Entry Shader::builti
|
||||
{"love_ScreenSize", Shader::BUILTIN_SCREEN_SIZE},
|
||||
};
|
||||
|
||||
StringMap<Shader::BuiltinExtern, Shader::BUILTIN_MAX_ENUM> Shader::builtinNames(Shader::builtinNameEntries, sizeof(Shader::builtinNameEntries));
|
||||
StringMap<Shader::BuiltinUniform, Shader::BUILTIN_MAX_ENUM> Shader::builtinNames(Shader::builtinNameEntries, sizeof(Shader::builtinNameEntries));
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
|
||||
Reference in New Issue
Block a user