diff options
Diffstat (limited to 'es_2_0/Program.c')
-rwxr-xr-x | es_2_0/Program.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/es_2_0/Program.c b/es_2_0/Program.c index 1d1f2b9..ab0107d 100755 --- a/es_2_0/Program.c +++ b/es_2_0/Program.c @@ -97,10 +97,15 @@ GLuint GL_APIENTRY ES2ENTRY(CreateProgram)(void) { void GL_APIENTRY ES2ENTRY(DeleteProgram)(GLuint program) { if (program == 0) { return; - } else if (FNPTR(IsProgram)(program) == GL_FALSE) { + } else if (FNPTR(IsProgram) != NULL && FNPTR(IsProgram)(program) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (CCV(nProgramObjectAllocated) == NULL) { ES2INTER(SetError)(GL_INVALID_VALUE); return; } + if (program < CCV(nProgramObjectAllocated)) { GLint nAttachedShaders = 0; FNPTR(GetProgramiv)(program, GL_ATTACHED_SHADERS, &nAttachedShaders); @@ -164,22 +169,25 @@ void GL_APIENTRY ES2ENTRY(DetachShader)(GLuint program, GLuint shader) { if ((GLint)(program) <= 0) { ES2INTER(SetError)(GL_INVALID_VALUE); return; - } else if (FNPTR(IsProgram)(program) == GL_FALSE) { + } else if (FNPTR(IsProgram) != NULL && FNPTR(IsProgram)(program) == GL_FALSE) { ES2INTER(SetError)(GL_INVALID_OPERATION); return; } if ((GLint)(shader) <= 0) { ES2INTER(SetError)(GL_INVALID_VALUE); return; - } else if (FNPTR(IsShader)(shader) == GL_FALSE) { + } else if (FNPTR(IsShader) != NULL && FNPTR(IsShader)(shader) == GL_FALSE) { ES2INTER(SetError)(GL_INVALID_OPERATION); return; } - FNPTR(DetachShader)(program, shader); - pShader = &(CCV(pShaderObject)[shader]); - if (pShader->nAttached > 0) pShader->nAttached--; - if (pShader->nAttached == 0 && pShader->bDeleteStatus == GL_TRUE) { - ES2INTER(ShaderObjectRelease)(pShader); + if (FNPTR(DetachShader) != NULL) + FNPTR(DetachShader)(program, shader); + if (CCV(pShaderObject) != NULL) { + pShader = &(CCV(pShaderObject)[shader]); + if (pShader->nAttached > 0) + pShader->nAttached--; + if (pShader->nAttached == 0 && pShader->bDeleteStatus == GL_TRUE) + ES2INTER(ShaderObjectRelease)(pShader); } } |