예제 #1
0
        private FontOutlineEntry CreateFontOutlineEntry(OpenGL gl, string faceName,
                                                        float deviation, float extrusion, FontOutlineFormat fontOutlineFormat)
        {
            //  Make the OpenGL instance current.
            gl.MakeCurrent();

            //  Create the font based on the face name.
            var hFont = Win32.CreateFont(12, 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.
            var hOldObject = Win32.SelectObject(gl.RenderContextProvider.DeviceContextHandle, hFont);

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

            //  Create space for the glyph metrics.
            var glyphMetrics = new GLYPHMETRICSFLOAT[255];

            //  Create the font bitmaps.
            bool result = Win32.wglUseFontOutlines(gl.RenderContextProvider.DeviceContextHandle, 0, 255, listBase,
                                                   deviation, extrusion, (int)fontOutlineFormat, glyphMetrics);

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

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

            //  If we failed to create the font outlines, bail out now.
            if (result == false)
            {
                return(null);
            }

            //  Create the font bitmap entry.
            var foe = new FontOutlineEntry()
            {
                HDC               = gl.RenderContextProvider.DeviceContextHandle,
                HRC               = gl.RenderContextProvider.RenderContextHandle,
                FaceName          = faceName,
                ListBase          = listBase,
                ListCount         = 255,
                Deviation         = deviation,
                Extrusion         = extrusion,
                FontOutlineFormat = fontOutlineFormat,
                GlyphMetrics      = glyphMetrics
            };

            //  Add the font bitmap entry to the internal list.
            fontOutlineEntries.Add(foe);

            return(foe);
        }
예제 #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.
            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);
            }
        }
예제 #3
0
        private FontOutlineEntry CreateFontOutlineEntry(OpenGL gl, string faceName, int height,
                                                        float deviation, float extrusion, FontOutlineFormat fontOutlineFormat)
        {
            //  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_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.
            var hOldObject = Win32.SelectObject(gl.RenderContextProvider.DeviceContextHandle, hFont);

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

            //  Create the font bitmaps.
            bool result = Win32.wglUseFontOutlines(gl.RenderContextProvider.DeviceContextHandle, 0, 255, listBase,
                                                   deviation, extrusion, (int)fontOutlineFormat, IntPtr.Zero);

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

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

            //  Create the font bitmap entry.
            var foe = new FontOutlineEntry()
            {
                HDC               = gl.RenderContextProvider.DeviceContextHandle,
                HRC               = gl.RenderContextProvider.RenderContextHandle,
                FaceName          = faceName,
                Height            = height,
                ListBase          = listBase,
                ListCount         = 255,
                Deviation         = deviation,
                Extrusion         = extrusion,
                FontOutlineFormat = fontOutlineFormat
            };

            //  Add the font bitmap entry to the internal list.
            fontOutlineEntries.Add(foe);

            return(foe);
        }
예제 #4
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;
            
        }
예제 #5
0
        private FontOutlineEntry CreateFontOutlineEntry(OpenGL gl, string faceName, int height,
            float deviation, float extrusion, FontOutlineFormat fontOutlineFormat)
        {
            //  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_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.
            var hOldObject = Win32.SelectObject(gl.RenderContextProvider.DeviceContextHandle, hFont);
            
            //  Create the list base.
            var listBase = gl.GenLists(1);

            //  Create the font bitmaps.
            bool result = Win32.wglUseFontOutlines(gl.RenderContextProvider.DeviceContextHandle, 0, 255, listBase,
                deviation, extrusion, (int)fontOutlineFormat, IntPtr.Zero);

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

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

            //  Create the font bitmap entry.
            var foe = new FontOutlineEntry()
            {
                HDC = gl.RenderContextProvider.DeviceContextHandle,
                HRC = gl.RenderContextProvider.RenderContextHandle,
                FaceName = faceName,
                Height = height,
                ListBase = listBase,
                ListCount = 255,
                Deviation = deviation,
                Extrusion = extrusion,
                FontOutlineFormat = fontOutlineFormat
            };

            //  Add the font bitmap entry to the internal list.
            fontOutlineEntries.Add(foe);

            return foe;
        }
예제 #6
0
 /// <summary>
 /// This function generates the display list. You must call it before you call
 /// anything else!
 /// </summary>
 /// <param name="gl">OpenGL</param>
 public virtual void Generate(OpenGL gl)
 {
     //	Generate one list.
     list = gl.GenLists(1);
 }