From: <axl...@us...> - 2009-06-13 02:35:27
|
Revision: 315 http://hgengine.svn.sourceforge.net/hgengine/?rev=315&view=rev Author: axlecrusher Date: 2009-06-13 02:35:10 +0000 (Sat, 13 Jun 2009) Log Message: ----------- error checking Modified Paths: -------------- Mercury2/adv_set.c Mercury2/src/GLHeaders.h Mercury2/src/MercuryFBO.cpp Mercury2/src/RenderBuffer.cpp Added Paths: ----------- Mercury2/src/GLHelpers.cpp Mercury2/src/GLHelpers.h Modified: Mercury2/adv_set.c =================================================================== --- Mercury2/adv_set.c 2009-06-13 01:13:21 UTC (rev 314) +++ Mercury2/adv_set.c 2009-06-13 02:35:10 UTC (rev 315) @@ -12,7 +12,7 @@ src/MercuryFile.cpp src/MercuryTimer.cpp src/MercuryMessageManager.cpp src/MercuryVertex.cpp \ src/MercuryPlane.cpp src/BoundingBox.cpp src/Shader.cpp src/RenderGraph.cpp src/Frustum.cpp \ src/Camera.cpp src/MercuryInput.cpp src/MQuaternion.cpp src/ModuleManager.cpp src/MercuryFBO.cpp \ - src/RenderBuffer.cpp" + src/RenderBuffer.cpp src/GLHelpers.cpp" SOURCES="$SOURCES src/MercuryFileDriverDirect.cpp src/MercuryFileDriverMem.cpp \ src/MercuryFileDriverPacked.cpp src/MercuryFileDriverZipped.cpp" Modified: Mercury2/src/GLHeaders.h =================================================================== --- Mercury2/src/GLHeaders.h 2009-06-13 01:13:21 UTC (rev 314) +++ Mercury2/src/GLHeaders.h 2009-06-13 02:35:10 UTC (rev 315) @@ -18,4 +18,19 @@ #include <GL/freeglut.h> #endif +#include <GLHelpers.h> + +#define GLERRORCHECK { \ +uint32_t e = glGetError(); \ +if ( e != GL_NO_ERROR ) { \ +printf("GL Error:%s\n", GlError2String(e).c_str()); \ +assert(0); } } + +#define CHECKFBO { \ +uint32_t e = glCheckFramebufferStatus(GL_FRAMEBUFFER); \ +if ( e != GL_FRAMEBUFFER_COMPLETE ) { \ +printf("GL FBO Error:%s\n", GlError2String(e).c_str()); \ +assert(0); } } + + #endif \ No newline at end of file Added: Mercury2/src/GLHelpers.cpp =================================================================== --- Mercury2/src/GLHelpers.cpp (rev 0) +++ Mercury2/src/GLHelpers.cpp 2009-06-13 02:35:10 UTC (rev 315) @@ -0,0 +1,72 @@ +#include <GLHeaders.h> +#include <GLHelpers.h> + +MString GlError2String(uint32_t e) +{ + switch (e) + { + case GL_INVALID_ENUM: + return "Invalid Enum"; + case GL_INVALID_VALUE: + return "Invalid Value"; + case GL_INVALID_OPERATION: + return "Invalid Operation"; + case GL_STACK_OVERFLOW: + return "Stack Overflow"; + case GL_STACK_UNDERFLOW: + return "Stack Underflow"; + case GL_OUT_OF_MEMORY: + return "Out of Memory"; + case GL_INVALID_FRAMEBUFFER_OPERATION: + return "Invalid FBO Operation"; + case GL_FRAMEBUFFER_UNSUPPORTED: + return "FBO Unsupported"; + case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: + return "FBO Incomplete Attachment"; + case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: + return "FBO Incomplete Missing Attachment"; +// case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS: +// return "FBO Incomplete Dimensions"; +// case GL_FRAMEBUFFER_INCOMPLETE_FORMATS: +// return "FBO Incomplete Formats"; + case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: + return "FBO Incomplete Draw Buffer"; + case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: + return "FBO Incomplete Read Buffer"; + case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: + return "FBO Incomplete Multisample"; + } + return "Unknown Error"; +} + +/**************************************************************************** + * Copyright (C) 2009 by Joshua Allen * + * * + * * + * All rights reserved. * + * * + * Redistribution and use in source and binary forms, with or without * + * modification, are permitted provided that the following conditions * + * are met: * + * * Redistributions of source code must retain the above copyright * + * notice, this list of conditions and the following disclaimer. * + * * Redistributions in binary form must reproduce the above * + * copyright notice, this list of conditions and the following * + * disclaimer in the documentation and/or other materials provided * + * with the distribution. * + * * Neither the name of the Mercury Engine nor the names of its * + * contributors may be used to endorse or promote products derived * + * from this software without specific prior written permission. * + * * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + ***************************************************************************/ Added: Mercury2/src/GLHelpers.h =================================================================== --- Mercury2/src/GLHelpers.h (rev 0) +++ Mercury2/src/GLHelpers.h 2009-06-13 02:35:10 UTC (rev 315) @@ -0,0 +1,36 @@ +#include <global.h> +#include <MercuryUtil.h> + +MString GlError2String(uint32_t e); + +/**************************************************************************** + * Copyright (C) 2009 by Joshua Allen * + * * + * * + * All rights reserved. * + * * + * Redistribution and use in source and binary forms, with or without * + * modification, are permitted provided that the following conditions * + * are met: * + * * Redistributions of source code must retain the above copyright * + * notice, this list of conditions and the following disclaimer. * + * * Redistributions in binary form must reproduce the above * + * copyright notice, this list of conditions and the following * + * disclaimer in the documentation and/or other materials provided * + * with the distribution. * + * * Neither the name of the Mercury Engine nor the names of its * + * contributors may be used to endorse or promote products derived * + * from this software without specific prior written permission. * + * * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + ***************************************************************************/ Modified: Mercury2/src/MercuryFBO.cpp =================================================================== --- Mercury2/src/MercuryFBO.cpp 2009-06-13 01:13:21 UTC (rev 314) +++ Mercury2/src/MercuryFBO.cpp 2009-06-13 02:35:10 UTC (rev 315) @@ -17,6 +17,8 @@ { m_initiated = true; glGenFramebuffersEXT(1, &m_fboID); + CHECKFBO; + GLERRORCHECK; } void MercuryFBO::PreRender(const MercuryMatrix& matrix) @@ -30,6 +32,8 @@ if (m_lastRendered != m_fboID) { glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fboID); +// CHECKFBO; //Incomplete FBO + GLERRORCHECK; m_lastRendered = m_fboID; // m_lastInStask = m_lastRendered; } @@ -46,10 +50,15 @@ // glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_lastInStask); // m_lastRendered = m_lastInStask; + + RenderableNode::PostRender(matrix); + GLERRORCHECK; + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); //unbind - m_lastRendered = 0; + CHECKFBO; + GLERRORCHECK; - RenderableNode::PostRender(matrix); + m_lastRendered = 0; } uint32_t MercuryFBO::m_lastRendered = NULL; Modified: Mercury2/src/RenderBuffer.cpp =================================================================== --- Mercury2/src/RenderBuffer.cpp 2009-06-13 01:13:21 UTC (rev 314) +++ Mercury2/src/RenderBuffer.cpp 2009-06-13 02:35:10 UTC (rev 315) @@ -37,6 +37,9 @@ void RenderBuffer::Render(const MercuryNode* node) { glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_bufferID); +// CHECKFBO; //missing attachment + GLERRORCHECK; + if ( NeedResize() ) AllocateSpace(); //attach to FBO @@ -47,25 +50,31 @@ glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GLAttachPoint(), GL_TEXTURE_2D, m_textureID, 0); else glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GLAttachPoint(), GL_RENDERBUFFER_EXT, m_bufferID); + CHECKFBO; + GLERRORCHECK; } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + GLERRORCHECK; } void RenderBuffer::PostRender(const MercuryNode* node) { - static uint32_t t = time(NULL); - if ( (m_type == TEXTURE) && (time(NULL) > (t+3))) -// if (false) + GLERRORCHECK; + if ( m_type == TEXTURE ) { glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); + GLERRORCHECK; + glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); + GLERRORCHECK; + // printf("active %d\n", Texture::NumberActiveTextures() ); //this works with a "normal" texture, FBO texture is still white @@ -75,6 +84,7 @@ glBindTexture(GL_TEXTURE_2D, m_textureID); glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); + GLERRORCHECK; glBegin(GL_QUADS); glTexCoord2d(0,1); @@ -88,8 +98,10 @@ glTexCoord2d(0,0); glVertex3i(-1, 1, -1); + glEnd(); + GLERRORCHECK; glBindTexture(GL_TEXTURE_2D, 0); // glActiveTexture( GL_TEXTURE0 ); @@ -97,9 +109,13 @@ // glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisable( GL_TEXTURE_2D ); + GLERRORCHECK; + glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); + + GLERRORCHECK; } } @@ -107,12 +123,11 @@ { m_initiated = true; glGenRenderbuffersEXT(1, &m_bufferID); - - if (m_type == TEXTURE) - { - glGenTextures(1, &m_textureID); - printf("texture rb %d\n", m_textureID); - } + CHECKFBO; + GLERRORCHECK; + if (m_type == TEXTURE) glGenTextures(1, &m_textureID); + CHECKFBO; + GLERRORCHECK; } void RenderBuffer::AllocateSpace() @@ -127,6 +142,7 @@ } else glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GLType(), m_width, m_height); + GLERRORCHECK; } bool RenderBuffer::NeedResize() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |