Update Shader::loadBinary to accept geoshaders too

This commit is contained in:
Cruel
2015-09-03 02:53:00 -04:00
parent cc485004b4
commit 3a4529f192
2 changed files with 13 additions and 16 deletions
+2 -2
View File
@@ -181,9 +181,9 @@ public :
////////////////////////////////////////////////////////////
bool loadFromMemory(const std::string& vertexShader, const std::string& fragmentShader);
bool loadFromResource(const std::string& vertexShader, Type type, bool compiled = true);
bool loadFromResource(const std::string& shader, Type type, bool compiled = true);
bool loadBinary(const Uint8* data, const Uint32 size);
bool loadBinary(const Uint8* data, const Uint32 size, Type type);
////////////////////////////////////////////////////////////
/// \brief Load either the vertex or fragment shader from a custom stream
+11 -14
View File
@@ -90,12 +90,12 @@ bool Shader::loadFromMemory(const std::string& vertexShader, const std::string&
////////////////////////////////////////////////////////////
bool Shader::loadFromResource(const std::string& vertexShader, Type type, bool compiled)
bool Shader::loadFromResource(const std::string& shader, Type type, bool compiled)
{
if (compiled) {
return loadBinary(priv::resources[vertexShader].data, priv::resources[vertexShader].size);
return loadBinary(priv::resources[shader].data, priv::resources[shader].size, type);
} else {
return compile(vertexShader.c_str(), nullptr);
return compile(shader.c_str(), nullptr);
}
}
@@ -351,24 +351,21 @@ bool Shader::compile(const char* vertexShaderCode, const char* fragmentShaderCod
////////////////////////////////////////////////////////////
bool Shader::loadBinary(const Uint8* data, const Uint32 size)
bool Shader::loadBinary(const Uint8* data, const Uint32 size, Type type)
{
if (m_shaderProgram) {
glCheck(glDeleteProgram(m_shaderProgram));
m_shaderProgram = 0;
}
if (!m_shaderProgram)
m_shaderProgram = glCreateProgram();
// Reset the internal state
m_currentTexture = -1;
m_textures.clear();
m_params.clear();
m_shaderProgram = glCreateProgram();
glProgramBinary(m_shaderProgram, GL_VERTEX_SHADER_BINARY, data, (GLsizei)size);
// shaderProgramInit(&shader);
//
// dvlb = DVLB_ParseFile((u32*)data, size);
// shaderProgramSetVsh(&shader, &dvlb->DVLE[0]);
if (type == Vertex)
glProgramBinary(m_shaderProgram, GL_VERTEX_SHADER_BINARY, data, (GLsizei)size);
else if (type == Geometry)
glProgramBinary(m_shaderProgram, GL_GEOMETRY_SHADER_BINARY, data, (GLsizei)size);
return true;
}