mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-09 04:38:30 +09:00
[Feat] (MG_Impl/Program): glAttachShader
This commit is contained in:
@@ -57,7 +57,19 @@ namespace MobileGL {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AttachShader_State(GLuint program, GLuint shader) {
|
void AttachShader_State(GLuint program, GLuint shader) {
|
||||||
THROW_UNIMPL_EXCEPTION;
|
auto programObject = TryToGetProgramObject(program);
|
||||||
|
if (!programObject)
|
||||||
|
return;
|
||||||
|
auto shaderObject = TryToGetShaderObject(shader);
|
||||||
|
if (!shaderObject)
|
||||||
|
return;
|
||||||
|
if (!programObject->AttachShader(shaderObject)) {
|
||||||
|
MG_State::pGLContext->RecordError(
|
||||||
|
ErrorCode::InvalidOperation,
|
||||||
|
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||||
|
"`shader` is already attached to `program`."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BindAttribLocation_State(GLuint program, GLuint index, const GLchar* name) {
|
void BindAttribLocation_State(GLuint program, GLuint index, const GLchar* name) {
|
||||||
|
|||||||
@@ -4,8 +4,19 @@
|
|||||||
namespace MobileGL {
|
namespace MobileGL {
|
||||||
namespace MG_State {
|
namespace MG_State {
|
||||||
namespace GLState {
|
namespace GLState {
|
||||||
void ProgramObject::AttachShader(SharedPtr<ShaderObject> shader) {
|
bool ProgramObject::ShaderIsAttached(SharedPtr<ShaderObject> shader) {
|
||||||
|
auto it = std::find_if(m_shaders.begin(), m_shaders.end(),
|
||||||
|
[shader](const SharedPtr<ShaderObject>& s) {
|
||||||
|
return s.get() == shader.get();
|
||||||
|
});
|
||||||
|
return it != m_shaders.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ProgramObject::AttachShader(SharedPtr<ShaderObject> shader) {
|
||||||
|
if (ShaderIsAttached(shader))
|
||||||
|
return false;
|
||||||
m_shaders.emplace_back(shader);
|
m_shaders.emplace_back(shader);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SizeT ProgramObject::DetachShader(SharedPtr<ShaderObject> shader) {
|
SizeT ProgramObject::DetachShader(SharedPtr<ShaderObject> shader) {
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ namespace MobileGL {
|
|||||||
namespace GLState {
|
namespace GLState {
|
||||||
class ProgramObject {
|
class ProgramObject {
|
||||||
public:
|
public:
|
||||||
void AttachShader(SharedPtr<ShaderObject> shader);
|
bool ShaderIsAttached(SharedPtr<ShaderObject> shader);
|
||||||
|
bool AttachShader(SharedPtr<ShaderObject> shader);
|
||||||
SizeT DetachShader(SharedPtr<ShaderObject> shader);
|
SizeT DetachShader(SharedPtr<ShaderObject> shader);
|
||||||
void Link();
|
void Link();
|
||||||
void MarkAsDeleted();
|
void MarkAsDeleted();
|
||||||
|
|||||||
Reference in New Issue
Block a user