Exemplo n.º 1
0
        public void Create(Game game)
        {
            this.game = game;

            deviceContext = GetDC(game.Handle);

            PixelFormatDesc pfd = new PixelFormatDesc(1,
                                                      (uint)PFD.DrawToWindow | (uint)PFD.SupportOpenGL | (uint)PFD.DoubleBuffer,
                                                      (byte)PFD.TypeRGBA, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                                      (sbyte)PFD.MainPlane, 0, 0, 0, 0);

            int pf = ChoosePixelFormat(deviceContext, ref pfd);

            if (pf == 0)
            {
                return;
            }

            SetPixelFormat(deviceContext, pf, ref pfd);

            renderContext = WglCreateContext(deviceContext);
            if (renderContext == IntPtr.Zero)
            {
                return;
            }

            WglMakeCurrent(deviceContext, renderContext);

            uint glBuffer = 0;

            GlEnable((uint)GL.Texture2D);
            GlGenTextures(1, new uint[] { glBuffer });
            GlBindTexture((uint)GL.Texture2D, glBuffer);
            GlTexParameteri((uint)GL.Texture2D, (uint)GL.TextureMagFilter, (int)GL.Nearest);
            GlTexParameteri((uint)GL.Texture2D, (uint)GL.TextureMinFilter, (int)GL.Nearest);
            GlTexEnvf((uint)GL.TextureEnv, (uint)GL.TextureEnvMode, (float)GL.Decal);

            ReleaseDC(game.Handle, deviceContext);
        }
Exemplo n.º 2
0
 public unsafe static extern int SetPixelFormat(IntPtr hDC, int iPixelFormat, [In] ref PixelFormatDesc ppfd);
Exemplo n.º 3
0
 public unsafe static extern int ChoosePixelFormat(IntPtr hDC, [In] ref PixelFormatDesc ppfd);