Exemple #1
0
        /// <summary>
        /// OpenGLの初期設定を行います。
        /// </summary>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (IsDesignMode)
            {
                return;
            }

            GL.Enable(EnableCap.Texture2D);
            GL.Enable(EnableCap.Blend);
            GL.Enable(EnableCap.CullFace);
            GL.CullFace(CullFaceMode.Back);
            GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest);

            // 背景色の更新
            UpdateClearColor();

            GLElements
            .Where(_ => _ != null)
            .ForEach(_ => _.InitializeOpenGL(this));
            this.glInitialized = true;

            // Viewportを更新しておきます。
            UpdateViewport();
        }
Exemple #2
0
        /// <summary>
        /// OpenGLの初期設定を行います。
        /// </summary>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (IsDesignMode)
            {
                return;
            }

            GLWrap.Wrap(() => GL.Enable(EnableCap.Texture2D));
            GLWrap.Wrap(() => GL.Enable(EnableCap.Blend));
            GLWrap.Wrap(() => GL.Disable(EnableCap.Lighting));
            GLWrap.Wrap(() => GL.Enable(EnableCap.CullFace));
            GLWrap.Wrap(() => GL.CullFace(CullFaceMode.Back));
            //GLWrap.Wrap(() => GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Fastest));

            // 背景色の更新
            BackColorChanged += OnBackColorChanged;

            GLElements
            .Where(_ => _ != null)
            .ForEach(_ => _.InitializeOpenGL(this));
            this.glInitialized = true;

            // Viewportを更新しておきます。
            UpdateViewport();
        }
Exemple #3
0
        /// <summary>
        /// マウスボタンが離されたときに呼ばれます。
        /// </summary>
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);

            GLElements
            .Where(_ => _ != null)
            .ForEach(_ => _.OnMouseUp(e));
        }
Exemple #4
0
        /// <summary>
        /// 描画処理を行います。
        /// </summary>
        public void DoRender()
        {
            if (IsDesignMode)
            {
                return;
            }

            MakeCurrent();

            GLWrap.Wrap(() => GL.Clear(ClearBufferMask.ColorBufferBit));
            GLWrap.Wrap(() => GL.LoadIdentity());

            this.renderBuffer.Render();

            GLElements
            .Where(_ => _ != null)
            .ForEach(_ => _.DoRender());

            SwapBuffers();
        }
Exemple #5
0
        /// <summary>
        /// ハンドルが閉じられたときに呼ばれます。
        /// </summary>
        protected override void OnHandleDestroyed(EventArgs e)
        {
            if (IsDesignMode)
            {
                base.OnHandleDestroyed(e);
                return;
            }

            GLElements
            .Where(_ => _ != null)
            .ForEach(_ => _.Terminate());
            GLElements.Clear();

            // このOpenGLに登録されているすべてのテクスチャを削除します。
            if (this.glInitialized)
            {
                GLUtil.Texture.DeleteAll(Context);
            }

            base.OnHandleDestroyed(e);
        }
Exemple #6
0
        /// <summary>
        /// 毎フレームごとの更新処理を行います。
        /// </summary>
        public void DoEnterFrame(TimeSpan elapsedTime)
        {
            if (IsDesignMode)
            {
                return;
            }

            MakeCurrent();

            this.renderBuffer.Clear();

            GLElements
            .Where(_ => _ != null)
            .ForEach(_ =>
            {
                // 一時的にZOrderの下駄をはかせます。
                this.renderBuffer.BaseZOrder = _.BaseZOrder;
                _.DoEnterFrame(elapsedTime, this.renderBuffer);
            });

            TextureDisposer.Update(Context);
        }
Exemple #7
0
        /// <summary>
        /// ハンドルが閉じられたときに呼ばれます。
        /// </summary>
        protected override void OnHandleDestroyed(EventArgs e)
        {
            if (IsDesignMode)
            {
                base.OnHandleDestroyed(e);
                return;
            }

            GLElements
            .Where(_ => _ != null)
            .ForEach(_ => _.Terminate());
            GLElements.Clear();

            // このOpenGLに登録されているすべてのテクスチャを削除します。
            if (this.glInitialized)
            {
                // このメソッドに失敗してVisual Studioが落ちることがあるため、
                // 念のため例外を潰しておく
                Util.SafeCall(() => Texture.DeleteAll(Context));
            }

            base.OnHandleDestroyed(e);
        }