b=612334; fix webgl program-test test; r=bjacob

This commit is contained in:
Vladimir Vukicevic 2010-11-16 20:33:04 -08:00
parent fe5e4b6c3b
commit 628a93151e
2 changed files with 15 additions and 9 deletions

View File

@ -1253,21 +1253,21 @@ public:
return mAttachedShaders.RemoveElement(shader);
}
PRBool HasBothShaderTypesAttached() {
PRBool haveVertex = PR_FALSE;
PRBool haveFrag = PR_FALSE;
PRBool HasAttachedShaderOfType(GLenum shaderType) {
for (PRUint32 i = 0; i < mAttachedShaders.Length(); ++i) {
if (mAttachedShaders[i]->ShaderType() == LOCAL_GL_FRAGMENT_SHADER)
haveFrag = PR_TRUE;
else if (mAttachedShaders[i]->ShaderType() == LOCAL_GL_VERTEX_SHADER)
haveVertex = PR_TRUE;
if (haveFrag && haveVertex)
if (mAttachedShaders[i]->ShaderType() == shaderType) {
return PR_TRUE;
}
}
return PR_FALSE;
}
PRBool HasBothShaderTypesAttached() {
return
HasAttachedShaderOfType(LOCAL_GL_VERTEX_SHADER) &&
HasAttachedShaderOfType(LOCAL_GL_FRAGMENT_SHADER);
}
PRBool NextGeneration()
{
if (!(mGeneration+1).valid())

View File

@ -162,6 +162,12 @@ WebGLContext::AttachShader(nsIWebGLProgram *pobj, nsIWebGLShader *shobj)
!GetConcreteObjectAndGLName("attachShader: shader", shobj, &shader, &shadername))
return NS_OK;
// Per GLSL ES 2.0, we can only have one of each type of shader
// attached. This renders the next test somewhat moot, but we'll
// leave it for when we support more than one shader of each type.
if (program->HasAttachedShaderOfType(shader->ShaderType()))
return ErrorInvalidOperation("AttachShader: only one of each type of shader may be attached to a program");
if (!program->AttachShader(shader))
return ErrorInvalidOperation("AttachShader: shader is already attached");