コード例 #1
0
        public static RenderingContext FromBitmapInfo(
            BitmapInfo bitmapInfo,
            PixelFormatDescriptor pfd,
            out IntPtr bitmapHandle)
        {
            IntPtr dc           = WGL.GetDC(IntPtr.Zero);
            IntPtr compatibleDc = WGL.CreateCompatibleDC(dc);

            WGL.ReleaseDC(IntPtr.Zero, dc);
            IntPtr ppvBits;

            bitmapHandle = WGL.CreateDIBSection(compatibleDc, ref bitmapInfo, DIBDataType.RgbColors, out ppvBits, IntPtr.Zero, 0U);
            if (bitmapHandle == IntPtr.Zero)
            {
                throw new InternalException("Error in CreateDIBSection", (Exception) new Win32Exception(Marshal.GetLastWin32Error()));
            }
            if (WGL.SelectObject(compatibleDc, bitmapHandle) == IntPtr.Zero)
            {
                throw new InternalException("SelectObject failed");
            }
            int    pixelFormatIndex = RenderingContext.smethod_0(compatibleDc, pfd);
            IntPtr context          = WGL.wglCreateContext(compatibleDc);

            if (context == IntPtr.Zero)
            {
                throw new InternalException("Error in wglCreateContext", (Exception) new Win32Exception(Marshal.GetLastWin32Error()));
            }
            return(new RenderingContext(IntPtr.Zero, compatibleDc, true, context, pixelFormatIndex));
        }
コード例 #2
0
ファイル: Scene.cs プロジェクト: OdedRadi/Helicopter_3D
        private void initRenderingContext()
        {
            m_uint_RC = WGL.wglCreateContext(m_uint_DC);

            if (m_uint_RC == 0)
            {
                MessageBox.Show("Unable to get rendering context");
                return;
            }
            if (WGL.wglMakeCurrent(m_uint_DC, m_uint_RC) == 0)
            {
                MessageBox.Show("Unable to make rendering context current");
                return;
            }
        }
コード例 #3
0
        public static RenderingContext FromWindowHandle(
            IntPtr windowHandle,
            PixelFormatDescriptor pfd)
        {
            IntPtr dc = WGL.GetDC(windowHandle);

            WGL.wglSwapBuffers(dc);
            int    pixelFormatIndex = RenderingContext.smethod_0(dc, pfd);
            IntPtr context          = WGL.wglCreateContext(dc);

            if (context == IntPtr.Zero)
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }
            return(new RenderingContext(windowHandle, dc, false, context, pixelFormatIndex));
        }
コード例 #4
0
        public static RenderingContext FromWindowHandle(
            IntPtr windowHandle,
            int pixelFormatIndex)
        {
            IntPtr dc = WGL.GetDC(windowHandle);

            WGL.wglSwapBuffers(dc);
            PixelFormatDescriptor empty = PixelFormatDescriptor.Empty;

            if (WGL.SetPixelFormat(dc, pixelFormatIndex, ref empty) == 0)
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }
            IntPtr context = WGL.wglCreateContext(dc);

            if (context == IntPtr.Zero)
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }
            return(new RenderingContext(windowHandle, dc, false, context, pixelFormatIndex));
        }