Text mit Tao Framework in Windows Form



  • Hallo,

    ich schau grad mal durch das Tao Framework mit dem VS 2013 Community, also Open GL in einer Visual C# Windowsform. Es funktioniert auch ganz gut, jedoch kann man kein 2d Text herstellen also mit glutBitmapCharacter, es erscheint stattdessen nur ein weißes Fenster mit einem roten Kreuz. Könnte mir mal jemand verklickern was hier falsch läuft oder wie man das mit Text anstellen könnte?

    der BeispielCode:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using Tao.OpenGl;
    using Tao.Platform;
    using Tao.FreeGlut;
    
    namespace TaoOpenGLTest
    {
        public partial class Form1 : Form
        {
            int w = 500;
            int h = 500;
    
            public Form1()
            {
                InitializeComponent();
    
                this.simpleOpenGlControl1.InitializeContexts();
    
                Gl.glClearDepth(1.0);
                Gl.glClearColor(0, 0, 0, 0);      
                Gl.glEnable(Gl.GL_DEPTH_TEST);
                Gl.glDepthMask(Gl.GL_TRUE);
                Gl.glViewport(0, 0, w, h);
                Gl.glMatrixMode(Gl.GL_PROJECTION);
                Gl.glLoadIdentity();
                Glu.gluPerspective(45.0f, (double)w / (double)h, 0.01f, 5000.0f);
    
                Gl.glEnable(Gl.GL_CULL_FACE);
                Gl.glCullFace(Gl.GL_BACK);          
            }
    
            private void timer1_Tick(object sender, EventArgs e)
            {
                this.simpleOpenGlControl1.Invalidate();
            }
    
            private void simpleOpenGlControl1_Paint(object sender, PaintEventArgs e)
            {
                Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
                Gl.glMatrixMode(Gl.GL_MODELVIEW);
                Gl.glLoadIdentity();
    
                Gl.glTranslated(0, 0, -10);
                Gl.glBegin(Gl.GL_LINE_LOOP);
                Gl.glVertex3d(-1, 1, 0);
                Gl.glVertex3d(-1, -1, 0);
                Gl.glVertex3d(1, -1, 0);
                Gl.glVertex3d(1, 1, 0);
                Gl.glEnd();
    
                Gl.glRasterPos3f(0, 0, 0);    // Set the position for the string (text)
                text("Text");                      // Display the text "Front" 
            }
    
            // Used for the font that will be displayed
            static void text(string c)
            {
                for (int i = 0; i < c.Length; i++)
                {
                    // Render bitmap character
                    Glut.glutBitmapCharacter(Glut.GLUT_BITMAP_TIMES_ROMAN_10, c[i]);
                }
            }
    
        }
    }
    

    Grüße hAYX



  • ok, glutInit() hat gefehlt!

    Grüße hAYX


Anmelden zum Antworten