Debug code not quite right?

Jan 14, 2012 at 4:26 PM

It seems to me that the debug code in OpenGL.cs isn't quite right. I think Begin() should be:

        public void Begin(uint mode)
        {
            // Do PreGLCall now, and PostGLCall AFTER End()
            PreGLCall();
			
            //  Let's remember something important here - you CANNOT call 'glGetError'
            //  between glBegin and glEnd. So we set the 'begun' flag - this'll
            //  turn off error reporting until glEnd.
			glBegin(mode);

            //  Set the begun flag.
            insideGLBegin = true;
        }

And End() should be:

        public void End()
        {
            glEnd();
            
            //  Clear the begun flag.
            insideGLBegin = false;
			
            // This matches Begin()'s PreGLCall()
           PostGLCall();
        }

And PreGLCall() should be:

        protected virtual void PreGLCall()
        {
            //  If we are in debug mode, clear the error flag.
#if DEBUG
            //  GetError() should not be called at all inside glBegin-glEnd
            if (insideGLBegin == false)
            {
                GetError();
            }
#endif

            //  If we are not the current OpenGL object, make ourselves current.
            if (currentOpenGLInstance != this)
            {
            MakeCurrent();
            }
        }
Although it might make sense to not call PreGLCall/PostGLCall at all for things like glVertex which can only be called inside glBegin-glEnd.

Coordinator
Jan 16, 2012 at 3:53 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Jan 16, 2012 at 3:54 PM

Makes sense mbraca - have copied this to a new work item