jjgl's picture

How to use WriteStringAt() from TexLib to print text

Project:OpenTK.Text
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:open
Description

Can anyone tell me what I did wrong with following function to print text on viewport? I read a few early discussions but still could not get it work.
Thanks.

  private void DrawText_01()
        {
            //string text = string.Format("Hello! FPS={0:000.0}", fps);
            GL.Color3(Color.Khaki);
            TexUtil.InitTexturing();
 
            //
            // Creating a texture
            //
            int textureId = TexUtil.CreateRGBTexture(2, 2,
                  new byte[] { 
                  255,0,0, // Red
                  0,255,0, // Green
                  0,0,255, // Blue
                  255,255,255 // White
                });
 
 
            TextureFont texFont = new TextureFont(textureId);
 
            // Draw 10% high text at x,y=50%,50% (center of screen) upside-down (180 degrees rotated)
            double height = 10;
            double xpercent = 50;
            double ypercent = 50;
            double rotation = 0;
 
            GL.Color3(Color.Red);
            texFont.WriteString("Test");
 
            texFont.WriteStringAt("Hello", height, xpercent, ypercent, rotation);
        }

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jjgl's picture

#1

Which one is suggested to use WriteStringAt() or TextPrinter(), in order to print text on viewer? I tried both, but no luck yet. Any help will be surely appreciated.