Example #1
0
        private FontBitmapEntry CreateFontBitmapEntry(OpenGL gl, string faceName, int height)
        {
            //  Make the OpenGL instance current.
            gl.MakeCurrent();

            //  Create the font based on the face name.
            var hFont = Win32.CreateFont(height, 0, 0, 0, Win32.FW_NORMAL, 0, 0, 0, Win32.DEFAULT_CHARSET,
                                         Win32.OUT_OUTLINE_PRECIS, Win32.CLIP_DEFAULT_PRECIS, Win32.CLEARTYPE_QUALITY, Win32.FIXED_PITCH, faceName);

            //  Select the font handle.
            var hOldObject = Win32.SelectObject(gl.RenderContextProvider.DeviceContextHandle, hFont);

            //  Create the list base.
            var listBase = gl.GenLists(255);

            //  Create the font bitmaps.
            bool result = Win32.wglUseFontBitmaps(gl.RenderContextProvider.DeviceContextHandle, 0, 255, listBase);

            //  Reselect the old font.
            Win32.SelectObject(gl.RenderContextProvider.DeviceContextHandle, hOldObject);

            //  Free the font.
            Win32.DeleteObject(hFont);

            //  Create the font bitmap entry.
            if (result)
            {
                var fbe = new FontBitmapEntry()
                {
                    HDC       = gl.RenderContextProvider.DeviceContextHandle,
                    HRC       = gl.RenderContextProvider.RenderContextHandle,
                    FaceName  = faceName,
                    Height    = height,
                    ListBase  = listBase,
                    ListCount = 255
                };

                //  Add the font bitmap entry to the internal list.
                fontBitmapEntries.Add(fbe);
                return(fbe);
            }
            else
            {
                return(null);
            }
        }
Example #2
0
        private FontBitmapEntry CreateFontBitmapEntry(OpenGL gl, string faceName, int height)
        {
            //  Make the OpenGL instance current.
            gl.MakeCurrent();

            //  Create the font based on the face name.
            IntPtr hFont = Win32.CreateFont(height, 0, 0, 0, Win32.FW_DONTCARE, 0, 0, 0, Win32.DEFAULT_CHARSET, 
                Win32.OUT_OUTLINE_PRECIS, Win32.CLIP_DEFAULT_PRECIS, Win32.CLEARTYPE_QUALITY, Win32.VARIABLE_PITCH, faceName);
            
            //  Select the font handle.
            IntPtr hOldObject = Win32.SelectObject(gl.RenderContextProvider.DeviceContextHandle, hFont);

            //  Create the font bitmaps.
            bool result = Win32.wglUseFontBitmaps(gl.RenderContextProvider.DeviceContextHandle, 0, 255, nextListBase);

            //  Reselect the old font.
            Win32.SelectObject(gl.RenderContextProvider.DeviceContextHandle, hOldObject);

            //  Free the font.
            Win32.DeleteObject(hFont);

            //  Create the font bitmap entry.
            FontBitmapEntry fbe = new FontBitmapEntry()
            {
                HDC = gl.RenderContextProvider.DeviceContextHandle,
                HRC = gl.RenderContextProvider.RenderContextHandle,
                FaceName = faceName,
                Height = height,
                ListBase = nextListBase,
                ListCount = 255
            };

            //  Add the font bitmap entry to the internal list.
            fontBitmapEntries.Add(fbe);
            
            //  Shift the list base.
            nextListBase += 1000;

            return fbe;
        }
Example #3
0
        private FontBitmapEntry CreateFontBitmapEntry(OpenGL gl, string faceName, int height)
        {
            //  Make the OpenGL instance current.
            gl.MakeCurrent();

            //  Create the font based on the face name.
            var hFont = Win32.CreateFont(height, 0, 0, 0, Win32.FW_NORMAL, 0, 0, 0, Win32.DEFAULT_CHARSET, 
                Win32.OUT_OUTLINE_PRECIS, Win32.CLIP_DEFAULT_PRECIS, Win32.CLEARTYPE_QUALITY, Win32.FIXED_PITCH, faceName);
            
            //  Select the font handle.
            var hOldObject = Win32.SelectObject(gl.RenderContextProvider.DeviceContextHandle, hFont);

            //  Create the list base.
            var listBase = gl.GenLists(255);

            //  Create the font bitmaps.
            bool result = Win32.wglUseFontBitmaps(gl.RenderContextProvider.DeviceContextHandle, 0, 255, listBase);

            //  Reselect the old font.
            Win32.SelectObject(gl.RenderContextProvider.DeviceContextHandle, hOldObject);

            //  Free the font.
            Win32.DeleteObject(hFont);

            //  Create the font bitmap entry.
            if (result)
            {
                var fbe = new FontBitmapEntry()
                {
                    HDC = gl.RenderContextProvider.DeviceContextHandle,
                    HRC = gl.RenderContextProvider.RenderContextHandle,
                    FaceName = faceName,
                    Height = height,
                    ListBase = listBase,
                    ListCount = 255
                };

                //  Add the font bitmap entry to the internal list.
                fontBitmapEntries.Add(fbe);
                return fbe;
            }
            else return null;
            
        }