mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 06:08:30 +09:00
[Feat] (MG_State/Program): GetProgramInfoLog, GetShaderInfoLog
This commit is contained in:
@@ -56,6 +56,14 @@ namespace MobileGL {
|
|||||||
return programObject;
|
return programObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CopyStr(GLsizei bufSize, GLsizei *length, GLchar *dst, const char* src, GLsizei srcLength) {
|
||||||
|
auto sz = std::min(bufSize - 1, srcLength);
|
||||||
|
if (length)
|
||||||
|
*length = sz;
|
||||||
|
memcpy(dst, src, sz);
|
||||||
|
dst[sz] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
void AttachShader_State(GLuint program, GLuint shader) {
|
void AttachShader_State(GLuint program, GLuint shader) {
|
||||||
auto programObject = TryToGetProgramObject(program);
|
auto programObject = TryToGetProgramObject(program);
|
||||||
if (!programObject)
|
if (!programObject)
|
||||||
@@ -168,7 +176,12 @@ namespace MobileGL {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GetProgramInfoLog_State(GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog) {
|
void GetProgramInfoLog_State(GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog) {
|
||||||
THROW_UNIMPL_EXCEPTION;
|
auto programObject = TryToGetProgramObject(program);
|
||||||
|
if (!programObject)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const auto& log = programObject->GetInfoLog();
|
||||||
|
CopyStr(bufSize, length, infoLog, log.c_str(), log.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetShaderiv_State(GLuint shader, GLenum pname, GLint* params) {
|
void GetShaderiv_State(GLuint shader, GLenum pname, GLint* params) {
|
||||||
@@ -176,7 +189,12 @@ namespace MobileGL {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GetShaderInfoLog_State(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog) {
|
void GetShaderInfoLog_State(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog) {
|
||||||
THROW_UNIMPL_EXCEPTION;
|
auto shaderObject = TryToGetShaderObject(shader);
|
||||||
|
if (!shaderObject)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const auto& log = shaderObject->GetInfoLog();
|
||||||
|
CopyStr(bufSize, length, infoLog, log.c_str(), log.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetShaderSource_State(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* source) {
|
void GetShaderSource_State(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* source) {
|
||||||
@@ -192,13 +210,11 @@ namespace MobileGL {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
auto& src = shaderObject->GetShaderSource();
|
auto& src = shaderObject->GetShaderSource();
|
||||||
auto sz = std::min(bufSize - 1, (GLsizei)src.length());
|
CopyStr(bufSize, length, source, src.c_str(), src.length());
|
||||||
if (length)
|
|
||||||
*length = sz;
|
|
||||||
memcpy(source, src.c_str(), sz);
|
|
||||||
source[sz] = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GLint GetUniformLocation_State(GLuint program, const GLchar* name) {
|
GLint GetUniformLocation_State(GLuint program, const GLchar* name) {
|
||||||
THROW_UNIMPL_EXCEPTION;
|
THROW_UNIMPL_EXCEPTION;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ namespace MobileGL {
|
|||||||
void Link();
|
void Link();
|
||||||
void MarkAsDeleted();
|
void MarkAsDeleted();
|
||||||
Vector<SharedPtr<ShaderObject>>& GetAttachedShaders();
|
Vector<SharedPtr<ShaderObject>>& GetAttachedShaders();
|
||||||
|
const String& GetInfoLog() const { return m_infoLog; }
|
||||||
private:
|
private:
|
||||||
const Uint m_id = 0;
|
const Uint m_id = 0;
|
||||||
Vector<SharedPtr<ShaderObject>> m_shaders;
|
Vector<SharedPtr<ShaderObject>> m_shaders;
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
namespace MobileGL {
|
namespace MobileGL {
|
||||||
namespace MG_State {
|
namespace MG_State {
|
||||||
namespace GLState {
|
namespace GLState {
|
||||||
void ShaderObject::SetShaderSource(const std::string& source) {
|
void ShaderObject::SetShaderSource(const String& source) {
|
||||||
m_source = source;
|
m_source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderObject::SetShaderSource(std::string &&source) {
|
void ShaderObject::SetShaderSource(String &&source) {
|
||||||
m_source = Move(source);
|
m_source = Move(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,21 +57,22 @@ namespace MobileGL {
|
|||||||
class ShaderObject {
|
class ShaderObject {
|
||||||
public:
|
public:
|
||||||
ShaderObject(const ShaderStage stage, const Uint id) : m_stage(stage), m_id(id) {}
|
ShaderObject(const ShaderStage stage, const Uint id) : m_stage(stage), m_id(id) {}
|
||||||
void SetShaderSource(const std::string& source);
|
void SetShaderSource(const String& source);
|
||||||
void SetShaderSource(std::string&& source);
|
void SetShaderSource(String&& source);
|
||||||
void Compile();
|
void Compile();
|
||||||
void MarkAsDeleted();
|
void MarkAsDeleted();
|
||||||
|
|
||||||
Uint GetId() const { return m_id; }
|
Uint GetId() const { return m_id; }
|
||||||
ShaderStage GetShaderStage() const { return m_stage; }
|
ShaderStage GetShaderStage() const { return m_stage; }
|
||||||
const std::string& GetShaderSource() const { return m_source; }
|
const String& GetShaderSource() const { return m_source; }
|
||||||
SharedPtr<glslang::TShader> GetCompiledShader() const { return m_shader; }
|
SharedPtr<glslang::TShader> GetCompiledShader() const { return m_shader; }
|
||||||
|
const String& GetInfoLog() const { return m_infoLog; }
|
||||||
private:
|
private:
|
||||||
const Uint m_id = 0;
|
const Uint m_id = 0;
|
||||||
const ShaderStage m_stage;
|
const ShaderStage m_stage;
|
||||||
std::string m_source;
|
String m_source;
|
||||||
SharedPtr<glslang::TShader> m_shader;
|
SharedPtr<glslang::TShader> m_shader;
|
||||||
std::string m_infoLog;
|
String m_infoLog;
|
||||||
|
|
||||||
Bool m_deleteStatus = false;
|
Bool m_deleteStatus = false;
|
||||||
Bool m_compileStatus = false;
|
Bool m_compileStatus = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user