b=528013; [webgl] BindFramebuffer checking target against wrong constants; r=vlad

This commit is contained in:
mwsteele@gmail.com 2009-12-07 15:10:04 -08:00
Родитель e611094cfc
Коммит 7712877b10
2 изменённых файлов: 18 добавлений и 23 удалений

Просмотреть файл

@ -284,10 +284,12 @@ protected:
WebGLObjectRefPtr<WebGLBuffer> mBoundElementArrayBuffer; WebGLObjectRefPtr<WebGLBuffer> mBoundElementArrayBuffer;
WebGLObjectRefPtr<WebGLProgram> mCurrentProgram; WebGLObjectRefPtr<WebGLProgram> mCurrentProgram;
nsTArray<nsRefPtr<WebGLFramebuffer> > mBoundColorFramebuffers; // XXX these 3 are wrong types, and aren't used atm (except for the length of the attachments)
nsRefPtr<WebGLFramebuffer> mBoundDepthFramebuffer; nsTArray<WebGLObjectRefPtr<WebGLTexture> > mFramebufferColorAttachments;
nsRefPtr<WebGLFramebuffer> mBoundStencilFramebuffer; nsRefPtr<WebGLFramebuffer> mFramebufferDepthAttachment;
nsRefPtr<WebGLFramebuffer> mFramebufferStencilAttachment;
nsRefPtr<WebGLFramebuffer> mBoundFramebuffer;
nsRefPtr<WebGLRenderbuffer> mBoundRenderbuffer; nsRefPtr<WebGLRenderbuffer> mBoundRenderbuffer;
// lookup tables for GL name -> object wrapper // lookup tables for GL name -> object wrapper

Просмотреть файл

@ -409,17 +409,8 @@ WebGLContext::BindFramebuffer(GLenum target, nsIWebGLFramebuffer *fb)
MakeContextCurrent(); MakeContextCurrent();
if (target >= LOCAL_GL_COLOR_ATTACHMENT0 && if (target != LOCAL_GL_FRAMEBUFFER) {
target < (LOCAL_GL_COLOR_ATTACHMENT0 + mBoundColorFramebuffers.Length())) return ErrorMessage("glBindFramebuffer: target must be GL_FRAMEBUFFER");
{
int targetOffset = target - LOCAL_GL_COLOR_ATTACHMENT0;
mBoundColorFramebuffers[targetOffset] = wfb;
} else if (target == LOCAL_GL_DEPTH_ATTACHMENT) {
mBoundDepthFramebuffer = wfb;
} else if (target == LOCAL_GL_STENCIL_ATTACHMENT) {
mBoundStencilFramebuffer = wfb;
} else {
return ErrorMessage("glBindFramebuffer: invalid target");
} }
gl->fBindFramebuffer(target, wfb ? wfb->GLName() : 0); gl->fBindFramebuffer(target, wfb ? wfb->GLName() : 0);
@ -436,7 +427,7 @@ WebGLContext::BindRenderbuffer(GLenum target, nsIWebGLRenderbuffer *rb)
return ErrorMessage("glBindRenderbuffer: renderbuffer has already been deleted!"); return ErrorMessage("glBindRenderbuffer: renderbuffer has already been deleted!");
if (target != LOCAL_GL_RENDERBUFFER) if (target != LOCAL_GL_RENDERBUFFER)
return ErrorMessage("glBindRenderbuffer: invalid target"); return ErrorMessage("glBindRenderbuffer: target must be GL_RENDERBUFFER");
MakeContextCurrent(); MakeContextCurrent();
@ -1094,9 +1085,9 @@ WebGLContext::FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum r
return ErrorMessage("glFramebufferRenderbuffer: renderbuffer has already been deleted!"); return ErrorMessage("glFramebufferRenderbuffer: renderbuffer has already been deleted!");
if (target != LOCAL_GL_FRAMEBUFFER) if (target != LOCAL_GL_FRAMEBUFFER)
return ErrorMessage("glFramebufferRenderbuffer: target must be LOCAL_GL_FRAMEBUFFER"); return ErrorMessage("glFramebufferRenderbuffer: target must be GL_FRAMEBUFFER");
if ((attachment < LOCAL_GL_COLOR_ATTACHMENT0 || attachment >= LOCAL_GL_COLOR_ATTACHMENT0 + mBoundColorFramebuffers.Length()) && if ((attachment < LOCAL_GL_COLOR_ATTACHMENT0 || attachment >= LOCAL_GL_COLOR_ATTACHMENT0 + mFramebufferColorAttachments.Length()) &&
attachment != LOCAL_GL_DEPTH_ATTACHMENT && attachment != LOCAL_GL_DEPTH_ATTACHMENT &&
attachment != LOCAL_GL_STENCIL_ATTACHMENT) attachment != LOCAL_GL_STENCIL_ATTACHMENT)
return ErrorMessage("glFramebufferRenderbuffer: invalid attachment"); return ErrorMessage("glFramebufferRenderbuffer: invalid attachment");
@ -1115,10 +1106,10 @@ WebGLContext::FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum r
NS_IMETHODIMP NS_IMETHODIMP
WebGLContext::FramebufferTexture2D(GLenum target, WebGLContext::FramebufferTexture2D(GLenum target,
GLenum attachment, GLenum attachment,
GLenum textarget, GLenum textarget,
nsIWebGLTexture *wtex, nsIWebGLTexture *wtex,
GLint level) GLint level)
{ {
WebGLTexture *tex = static_cast<WebGLTexture*>(wtex); WebGLTexture *tex = static_cast<WebGLTexture*>(wtex);
@ -1128,7 +1119,7 @@ WebGLContext::FramebufferTexture2D(GLenum target,
if (target != LOCAL_GL_FRAMEBUFFER) if (target != LOCAL_GL_FRAMEBUFFER)
return ErrorMessage("glFramebufferTexture2D: target must be GL_FRAMEBUFFER"); return ErrorMessage("glFramebufferTexture2D: target must be GL_FRAMEBUFFER");
if ((attachment < LOCAL_GL_COLOR_ATTACHMENT0 || attachment >= LOCAL_GL_COLOR_ATTACHMENT0 + mBoundColorFramebuffers.Length()) && if ((attachment < LOCAL_GL_COLOR_ATTACHMENT0 || attachment >= LOCAL_GL_COLOR_ATTACHMENT0 + mFramebufferColorAttachments.Length()) &&
attachment != LOCAL_GL_DEPTH_ATTACHMENT && attachment != LOCAL_GL_DEPTH_ATTACHMENT &&
attachment != LOCAL_GL_STENCIL_ATTACHMENT) attachment != LOCAL_GL_STENCIL_ATTACHMENT)
return ErrorMessage("glFramebufferTexture2D: invalid attachment"); return ErrorMessage("glFramebufferTexture2D: invalid attachment");
@ -1141,6 +1132,8 @@ WebGLContext::FramebufferTexture2D(GLenum target,
if (level != 0) if (level != 0)
return ErrorMessage("glFramebufferTexture2D: level must be 0"); return ErrorMessage("glFramebufferTexture2D: level must be 0");
// XXXXX we need to store/reference this attachment!
MakeContextCurrent(); MakeContextCurrent();
gl->fFramebufferTexture2D(target, attachment, textarget, tex->GLName(), level); gl->fFramebufferTexture2D(target, attachment, textarget, tex->GLName(), level);
@ -2934,7 +2927,7 @@ WebGLContext::ValidateGL()
//fprintf(stderr, "GL_MAX_TEXTURE_UNITS: %d\n", val); //fprintf(stderr, "GL_MAX_TEXTURE_UNITS: %d\n", val);
gl->fGetIntegerv(LOCAL_GL_MAX_COLOR_ATTACHMENTS, &val); gl->fGetIntegerv(LOCAL_GL_MAX_COLOR_ATTACHMENTS, &val);
mBoundColorFramebuffers.SetLength(val); mFramebufferColorAttachments.SetLength(val);
#ifdef DEBUG_vladimir #ifdef DEBUG_vladimir
gl->fGetIntegerv(LOCAL_GL_IMPLEMENTATION_COLOR_READ_FORMAT, &val); gl->fGetIntegerv(LOCAL_GL_IMPLEMENTATION_COLOR_READ_FORMAT, &val);