示例#1
0
        // IntPtr oldContext;
        //    ↑
        // Win32WindowのSelectのネストが出来るようにしようと考えたのだが、
        // 前のコンテキストを保存しておいても、
        //    Select
        //     Select
        //   Update ←このあと、1つ目のSelectのViewに設定しなおす必要があるのだが、
        //            このための復帰処理が難しい
        //  Update
        //        ので、こういう実装は現実的ではないと判断する。
        // 初期化用のhelper関数
        private YanesdkResult InitByHdc_(IntPtr hDc)
        {
            this.hDC = hDc;

            screen_ = new Screen2DGl();
            screen_.BeginDrawDelegate = delegate
            {
                hDC = GetDC(this.hWnd);
            //	oldContext = opengl32.wglGetCurrentContext();
                Opengl32.wglMakeCurrent(this.hDC , this.hRC);
                //	テクスチャー描画が基本なのでテクスチャーを有効にしておかねば
            };
            screen_.EndDrawDelegate = delegate
            {
                SwapBuffers(this.hDC);
                Opengl32.wglMakeCurrent(this.hDC,IntPtr.Zero);
                ReleaseDC(this.hWnd, this.hDC);
            };

            // 描画を行なわないdelegateを渡す。
            // なぜなら、テクスチャの読み込みは、
            // wglMakeCurrentが実行されていないと
            // 正しく読み込まれないので、beginDrawDelegateを行なってから
            // 読み込み、それが終わり次第この
            // delegateを呼び出して、openglのassignを解放してやる必要がある。
            screen_.QuitDrawDelegate = delegate
            {
                Opengl32.wglMakeCurrent(this.hDC , IntPtr.Zero);
            //		opengl32.wglMakeCurrent(this.hDC , oldContext);
                ReleaseDC(this.hWnd, this.hDC);
            };

            YanesdkResult result = CreatePixelFormat(this.hDC);

            if ( result != YanesdkResult.NoError )
                return result;

            // Create a new OpenGL rendering contex
            this.hRC = Opengl32.wglCreateContext(this.hDC);

            // context共有を利用する。
            // 0番は常に生きていると仮定。
            // opengl32.wglShareLists(Singleton<GlInitializer>.Instance.hNullRC,this.hRC);
            //	↑これをやるとthreadが終了しなくなるので
            //    一つ目のRendering Contextだけ解放しないことにする。

            if ( theFirstHRc != IntPtr.Zero )
                Opengl32.wglShareLists(theFirstHRc , this.hRC);
            else
                theFirstHRc = this.hRC;

            ReleaseDC(this.hWnd, this.hDC);

            RECT32 rect = new RECT32();
            //	GetWindowRect((IntPtr)this.hWnd, out rect);

            GetClientRect((IntPtr)this.hWnd, out rect);
            Screen.UpdateView(rect.left - rect.right, rect.bottom - rect.top);

            return YanesdkResult.NoError;
        }
示例#2
0
 static extern bool GetWindowRect(IntPtr hWnd, out RECT32 lpRect);
示例#3
0
 static extern bool GetClientRect(IntPtr hWnd, out RECT32 lpRect);
示例#4
0
 static extern bool GetWindowRect(IntPtr hWnd, out RECT32 lpRect);
示例#5
0
        // IntPtr oldContext;
        //	↑
        // Win32WindowのSelectのネストが出来るようにしようと考えたのだが、
        // 前のコンテキストを保存しておいても、
        //	Select
        //	 Select
        //   Update ←このあと、1つ目のSelectのViewに設定しなおす必要があるのだが、
        //			このための復帰処理が難しい
        //  Update
        //		ので、こういう実装は現実的ではないと判断する。

        // 初期化用のhelper関数
        private YanesdkResult InitByHdc_(IntPtr hDc)
        {
            this.hDC = hDc;

            screen_ = new Screen2DGl();
            screen_.BeginDrawDelegate = delegate
            {
                hDC = GetDC(this.hWnd);
                //	oldContext = opengl32.wglGetCurrentContext();
                Opengl32.wglMakeCurrent(this.hDC, this.hRC);
                //	テクスチャー描画が基本なのでテクスチャーを有効にしておかねば
            };
            screen_.EndDrawDelegate = delegate
            {
                SwapBuffers(this.hDC);
                Opengl32.wglMakeCurrent(this.hDC, IntPtr.Zero);
                ReleaseDC(this.hWnd, this.hDC);
            };

            // 描画を行なわないdelegateを渡す。
            // なぜなら、テクスチャの読み込みは、
            // wglMakeCurrentが実行されていないと
            // 正しく読み込まれないので、beginDrawDelegateを行なってから
            // 読み込み、それが終わり次第この
            // delegateを呼び出して、openglのassignを解放してやる必要がある。
            screen_.QuitDrawDelegate = delegate
            {
                Opengl32.wglMakeCurrent(this.hDC, IntPtr.Zero);
                //		opengl32.wglMakeCurrent(this.hDC , oldContext);
                ReleaseDC(this.hWnd, this.hDC);
            };

            YanesdkResult result = CreatePixelFormat(this.hDC);

            if (result != YanesdkResult.NoError)
            {
                return(result);
            }

            // Create a new OpenGL rendering contex
            this.hRC = Opengl32.wglCreateContext(this.hDC);

            // context共有を利用する。
            // 0番は常に生きていると仮定。
            // opengl32.wglShareLists(Singleton<GlInitializer>.Instance.hNullRC,this.hRC);
            //	↑これをやるとthreadが終了しなくなるので
            //    一つ目のRendering Contextだけ解放しないことにする。

            if (theFirstHRc != IntPtr.Zero)
            {
                Opengl32.wglShareLists(theFirstHRc, this.hRC);
            }
            else
            {
                theFirstHRc = this.hRC;
            }

            ReleaseDC(this.hWnd, this.hDC);

            RECT32 rect = new RECT32();

            //	GetWindowRect((IntPtr)this.hWnd, out rect);

            GetClientRect((IntPtr)this.hWnd, out rect);
            Screen.UpdateView(rect.left - rect.right, rect.bottom - rect.top);

            return(YanesdkResult.NoError);
        }
示例#6
0
 static extern bool GetClientRect(IntPtr hWnd, out RECT32 lpRect);