GetError() private méthode

private GetError ( ) : uint
Résultat uint
        protected vec3[] FillPickedGeometrysPosition(uint[] indexes)
        {
            var positions = new vec3[indexes.Length];

            OpenGL.BindBuffer(BufferTarget.ArrayBuffer, this.positionBufferPtr.BufferId);
            for (int i = 0; i < indexes.Length; i++)
            {
                int offset = (int)(indexes[i] * this.positionBufferPtr.DataSize * this.positionBufferPtr.DataTypeByteLength);
                //IntPtr pointer = GL.MapBuffer(BufferTarget.ArrayBuffer, MapBufferAccess.ReadOnly);
                IntPtr pointer = OpenGL.MapBufferRange(BufferTarget.ArrayBuffer,
                                                       offset,
                                                       1 * this.positionBufferPtr.DataSize * this.positionBufferPtr.DataTypeByteLength,
                                                       MapBufferRangeAccess.MapReadBit);
                if (pointer.ToInt32() != 0)
                {
                    unsafe
                    {
                        var array = (vec3 *)pointer.ToPointer();
                        positions[i] = array[0];
                    }
                }
                else
                {
                    ErrorCode error = (ErrorCode)OpenGL.GetError();
                    Debug.WriteLine(string.Format(
                                        "Error:[{0}] MapBufferRange failed: buffer ID: [{1}]", error, this.positionBufferPtr.BufferId));
                }
                OpenGL.UnmapBuffer(BufferTarget.ArrayBuffer);
            }

            OpenGL.BindBuffer(BufferTarget.ArrayBuffer, 0);

            return(positions);
        }
        protected vec3[] FillPickedGeometrysPosition(uint firstIndex, int indexCount)
        {
            int offset = (int)(firstIndex * this.positionBufferPtr.DataSize * this.positionBufferPtr.DataTypeByteLength);

            OpenGL.BindBuffer(BufferTarget.ArrayBuffer, this.positionBufferPtr.BufferId);
            //IntPtr pointer = GL.MapBuffer(BufferTarget.ArrayBuffer, MapBufferAccess.ReadOnly);
            IntPtr pointer = OpenGL.MapBufferRange(BufferTarget.ArrayBuffer,
                                                   offset,
                                                   indexCount * this.positionBufferPtr.DataSize * this.positionBufferPtr.DataTypeByteLength,
                                                   MapBufferRangeAccess.MapReadBit);
            var positions = new vec3[indexCount];

            if (pointer.ToInt32() != 0)
            {
                unsafe
                {
                    var array = (vec3 *)pointer.ToPointer();
                    for (uint i = 0; i < indexCount; i++)
                    {
                        positions[i] = array[i];
                    }
                }
            }
            else
            {
                ErrorCode error = (ErrorCode)OpenGL.GetError();
                throw new Exception(string.Format(
                                        "Error:[{0}] MapBufferRange failed: buffer ID: [{1}]", error, this.positionBufferPtr.BufferId));
            }
            OpenGL.UnmapBuffer(BufferTarget.ArrayBuffer);
            OpenGL.BindBuffer(BufferTarget.ArrayBuffer, 0);

            return(positions);
        }
        protected vec3[] FillPickedGeometrysPosition(uint firstIndex, int indexCount)
        {
            int offset = (int)(firstIndex * this.PositionBuffer.Config.GetDataSize() * this.PositionBuffer.Config.GetDataTypeByteLength());
            //IntPtr pointer = GL.MapBuffer(BufferTarget.ArrayBuffer, MapBufferAccess.ReadOnly);
            IntPtr pointer = this.PositionBuffer.MapBufferRange(
                offset,
                indexCount * this.PositionBuffer.Config.GetDataSize() * this.PositionBuffer.Config.GetDataTypeByteLength(),
                MapBufferRangeAccess.MapReadBit);
            var positions = new vec3[indexCount];

            if (pointer.ToInt64() != 0)
            {
                unsafe
                {
                    var array = (vec3 *)pointer.ToPointer();
                    for (uint i = 0; i < indexCount; i++)
                    {
                        positions[i] = array[i];
                    }
                }
            }
            else
            {
                ErrorCode error = (ErrorCode)OpenGL.GetError();
                if (error != ErrorCode.NoError)
                {
                    throw new Exception(string.Format(
                                            "Error:[{0}] glMapBufferRange failed: buffer ID: [{1}]", error, this.PositionBuffer.BufferId.ToString()));
                }
            }
            this.PositionBuffer.UnmapBuffer();

            return(positions);
        }
Exemple #4
0
        /// <summary>
        /// Check if error exists.
        /// </summary>
        public static void CheckError()
        {
            ErrorCode error = (ErrorCode)OpenGL.GetError();

            if (error != ErrorCode.NoError)
            {
                //var stack = new StackTrace();
                //StackFrame frame = stack.GetFrame(1);

                Debug.WriteLine(string.Format("OpenGL error: {0}", error));
            }
        }
Exemple #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            RenderContext renderContext = this.renderContext;

            if (renderContext == null)
            {
                base.OnPaint(e);
                return;
            }

            stopWatch.Reset();
            stopWatch.Start();

            //	Make sure it's our instance of openSharpGL that's active.
            renderContext.MakeCurrent();

            if (this.designMode)
            {
                try
                {
                    DesignModeRender();
                }
                catch (Exception)
                {
                }
            }
            else
            {
                //	If there is a draw handler, then call it.
                DoOpenGLDraw(e);
            }

            //	Blit our offscreen bitmap.
            Graphics graphics      = e.Graphics;
            IntPtr   deviceContext = graphics.GetHdc();

            renderContext.Blit(deviceContext);
            graphics.ReleaseHdc(deviceContext);

            stopWatch.Stop();

            {
                ErrorCode error = (ErrorCode)OpenGL.GetError();
                if (error != ErrorCode.NoError)
                {
                    Debug.WriteLine(string.Format("{0}: OpenGL error: {1}", this.fullname, error));
                }
            }

            this.FPS = 1000.0 / stopWatch.Elapsed.TotalMilliseconds;
        }
        protected vec3[] FillPickedGeometrysPosition(uint[] indexes)
        {
            var positions = new vec3[indexes.Length];

            this.PositionBuffer.Bind();
            for (int i = 0; i < indexes.Length; i++)
            {
                int offset = (int)(indexes[i] * this.PositionBuffer.Config.GetDataSize() * this.PositionBuffer.Config.GetDataTypeByteLength());
                //IntPtr pointer = GL.MapBuffer(BufferTarget.ArrayBuffer, MapBufferAccess.ReadOnly);
                IntPtr pointer = this.PositionBuffer.MapBufferRange(
                    offset,
                    1 * this.PositionBuffer.Config.GetDataSize() * this.PositionBuffer.Config.GetDataTypeByteLength(),
                    MapBufferRangeAccess.MapReadBit, false);
                if (pointer.ToInt64() != 0)
                {
                    unsafe
                    {
                        var array = (vec3 *)pointer.ToPointer();
                        positions[i] = array[0];
                    }
                }
                else
                {
                    ErrorCode error = (ErrorCode)OpenGL.GetError();
                    if (error != ErrorCode.NoError)
                    {
                        Debug.WriteLine(string.Format(
                                            "Error:[{0}] glMapBufferRange failed: buffer ID: [{1}]", error, this.PositionBuffer.BufferId.ToString()));
                    }
                }
                this.PositionBuffer.UnmapBuffer(false);
            }
            this.PositionBuffer.Unbind();

            return(positions);
        }
Exemple #7
0
        public void swapColorAttachment(Framebuffer other, int index)
        {
            FramebufferTexture tmp = m_color[index];

            m_color[index]       = other.m_color[index];
            other.m_color[index] = tmp;

            glBindFramebuffer(OpenGL.GL_FRAMEBUFFER_EXT, framebufferId[0]);
            glFramebufferTexture2D(OpenGL.GL_FRAMEBUFFER_EXT,
                                   attachment_id[index], m_color[index].glTarget(), m_color[index].glID(), 0);
            glBindFramebuffer(OpenGL.GL_FRAMEBUFFER_EXT, 0);

            glBindFramebuffer(OpenGL.GL_FRAMEBUFFER_EXT, other.framebufferId[0]);
            glFramebufferTexture2D(OpenGL.GL_FRAMEBUFFER_EXT,
                                   attachment_id[index], other.m_color[index].glTarget(), other.m_color[index].glID(), 0);
            glBindFramebuffer(OpenGL.GL_FRAMEBUFFER_EXT, 0);

            ErrorCode error = (ErrorCode)OpenGL.GetError();

            if (error != ErrorCode.NoError)
            {
                throw new Exception(string.Format("OpenGL Error: {0}", error));
            }
        }