コード例 #1
0
        /// <summary>
        /// Applies the state object's values to the OpenGL context.
        /// </summary>
        public void Apply()
        {
            switch (stateType)
            {
            case OpenGLStateType.None:
                break;

            case OpenGLStateType.ActiveTexture:
                Apply_ActiveTexture();
                break;

            case OpenGLStateType.BindTexture2D:
                Apply_BindTexture2D();
                break;

            case OpenGLStateType.BindVertexArrayObject:
                Apply_BindVertexArrayObject();
                break;

            case OpenGLStateType.BindArrayBuffer:
                Apply_BindArrayBuffer();
                break;

            case OpenGLStateType.BindElementArrayBuffer:
                Apply_BindElementArrayBuffer();
                break;

            case OpenGLStateType.BindFramebuffer:
                Apply_BindFramebuffer();
                break;

            case OpenGLStateType.BindRenderbuffer:
                Apply_BindRenderbuffer();
                break;

            case OpenGLStateType.UseProgram:
                Apply_UseProgram();
                break;

            default:
                throw new InvalidOperationException();
            }

            OpenGLState.VerifyCache();
        }
コード例 #2
0
        /// <summary>
        /// Resets the OpenGL context to its values prior to this object's application.
        /// </summary>
        public void Dispose()
        {
            if (disposed)
            {
                return;
            }

            switch (stateType)
            {
            case OpenGLStateType.None:
                break;

            case OpenGLStateType.ActiveTexture:
                Dispose_ActiveTexture();
                break;

            case OpenGLStateType.BindTexture2D:
                Dispose_BindTexture2D();
                break;

            case OpenGLStateType.BindVertexArrayObject:
                Dispose_BindVertexArrayObject();
                break;

            case OpenGLStateType.BindArrayBuffer:
                Dispose_BindArrayBuffer();
                break;

            case OpenGLStateType.BindElementArrayBuffer:
                Dispose_BindElementArrayBuffer();
                break;

            case OpenGLStateType.BindFramebuffer:
                Dispose_BindFramebuffer();
                break;

            case OpenGLStateType.BindRenderbuffer:
                Dispose_BindRenderbuffer();
                break;

            case OpenGLStateType.UseProgram:
                Dispose_UseProgram();
                break;

            case OpenGLStateType.CreateTexture2D:
                Dispose_CreateTexture2D();
                break;

            case OpenGLStateType.CreateArrayBuffer:
                Dispose_CreateArrayBuffer();
                break;

            case OpenGLStateType.CreateElementArrayBuffer:
                Dispose_CreateElementArrayBuffer();
                break;

            case OpenGLStateType.CreateFramebuffer:
                Dispose_CreateFramebuffer();
                break;

            case OpenGLStateType.CreateRenderbuffer:
                Dispose_CreateRenderbuffer();
                break;

            default:
                throw new InvalidOperationException();
            }

            OpenGLState.VerifyCache();

            disposed = true;
            pool.Release(this);
        }