Beispiel #1
0
        void InitGL()
        {
            gl.ShadeModel(gl.GL_SMOOTH);
            gl.ClearColor(0.0f, 0.0f, 0.0f, 0.5f);
            gl.ClearDepthf(1.0f);
            //gl.Enable(gl.GL_DEPTH_TEST);
            gl.BlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA);
            gl.DepthFunc(gl.GL_LEQUAL);
            gl.Hint(gl.GL_PERSPECTIVE_CORRECTION_HINT, gl.GL_NICEST);
            myFont        = new OpenGLFont(new Font(FontFamily.GenericSerif, 12, FontStyle.Regular));
            myHugeFont    = new OpenGLFont(new Font(FontFamily.GenericSerif, 32, FontStyle.Regular));
            myLeftAligned = new GlyphRun(myHugeFont, "hello world", float.PositiveInfinity, float.PositiveInfinity, OpenGLTextAlignment.Left, true);
            myCentered    = new GlyphRun(myFont, "centered text", ClientSize.Width, ClientSize.Height, OpenGLTextAlignment.Center, true);
            myJustified   = new GlyphRun(myFont, "this text blob is really long and hopefully it will be justified to the edges as the lines wrap and stuff", ClientSize.Width, ClientSize.Height, OpenGLTextAlignment.Justified, true);
            myTexture     = Texture.LoadStream(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("TestOpenGLES.BitmapBrush.bmp"), false);

            myLeftAligned.ApplyTextureShader((glyphPos) =>
            {
                float left   = glyphPos.TopLeft.X / myLeftAligned.Width;
                float top    = glyphPos.TopLeft.Y / myLeftAligned.Height;
                float right  = glyphPos.TopRight.X / myLeftAligned.Width;
                float bottom = glyphPos.BottomLeft.Y / myLeftAligned.Height;
                return(new GlyphTexCoords(left, top, right, bottom));
            }
                                             );

            myLeftAligned.Texture = myTexture;

            myJustified.ApplyColorShader((glyphPos) =>
            {
                GlyphColors colors = new GlyphColors();
                colors.TopLeft     = new Vector4f(1, 0, 0, 1);
                colors.BottomLeft  = new Vector4f(0, 1, 0, 1);
                colors.TopRight    = new Vector4f(1, 0, 0, 1);
                colors.BottomRight = new Vector4f(0, 0, 1, 1);

                return(colors);
            }
                                         );
        }