Ejemplo n.º 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));
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
        private void InitializeGL(uint sceneWindowId)
        {
            m_uint_DC = WGL.GetDC(sceneWindowId);
            WGL.wglSwapBuffers(m_uint_DC);

            initPixelFormat();
            initRenderingContext();
            initRenderingGL();
            initPerspective();

            m_xTranslate = -7;
            m_yTranslate = -3;
            m_zTranslate = -10;

            m_helicopter.Init();
            m_skyBox.Init();
            m_skyscraper.Init();
            m_light.Init();
        }
Ejemplo n.º 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));
        }