wglUseFontBitmaps不在屏幕上绘制

本文关键字:绘制 屏幕 wglUseFontBitmaps | 更新日期: 2023-09-27 18:04:09

我已经在gis中发布了这个问题。但我不确定这是否是发布它的正确地方,因为这更多的是一个编码/技术问题。我正在尝试在3D空间中画一个角色。然而,似乎没有什么东西可以把角色放在屏幕上。

下面是我试图在代码中做的:有人有任何想法吗?我在这一点上迷失了,我承认我对openGL几乎一无所知

double outX = 0;
double outY = 0;
double outZ = 0;
//This allows ArcGlobe to convert a lat lon into a 3D Coordinate system between -1 and 1
myGlobeViewUtil.GeographictoGeocentric(0 ,0 ,0 , out outX , out outY , out outZ);
Font font = new Font("Courier New" , 32.0f , FontStyle.Bold);
uint dbase = GL.genLists(256);
wglUseFontBitmaps(this.Handle, 32, 256 , dbase);
GL.glLoadIdentity();
GL.glTranslatef(0.0f , 0.0f , -1.0f);
GL.glColor3f(1.0f , 0.0f , 0.0f);
GL.glRasterPos3d(geoX , geoY , geoZ);
GLPrint("TEST");

private void GLPrint(string inText)
{
  GL.glPushAttrib(GL.GL_LIST_BIT);
  GL.glListBase(dbase -32);
  GL.glCallLists(text.length , GL.GL_UNSIGNED_SHORT , text);
  GL.glPopattrib();
}

编辑:由于已有的要求,我必须使用CsGLhttp://csgl.sourceforge.net/

wglUseFontBitmaps不在屏幕上绘制

现在终于工作了!

public class OurView : OpenGLControl
{
    readonly GDITextureFont _myGDITextureFont = new GDITextureFont(new Font("Courier New", 32.0f, FontStyle.Bold));
    public override void glDraw()
    {
        OpenGL.glClear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);    // Clear Screen And Depth Buffer
        OpenGL.glLoadIdentity();
        OpenGL.glTranslated(0, 0, -1000); // !!!
        OpenGL.glRotated(35, 1, 1.2, 0.2);
        OpenGL.glScaled(2, 2, 2);
        OpenGL.glPushMatrix();
        OpenGL.glColor3f(1, 1, 0);
        OpenGL.glTranslated(-20, -10, 100);
        _myGDITextureFont.DrawString("Working!");
        OpenGL.glPopMatrix();
    }
    protected override void OnSizeChanged(EventArgs e)
    {
        base.OnSizeChanged(e);
        Size s = Size;
        double aspect_ratio = (double)s.Width / (double)s.Height;
        OpenGL.glMatrixMode(GL.GL_PROJECTION);
        OpenGL.glLoadIdentity();
        // special frustum, to have nice font display
        OpenGL.glFrustum(-s.Width, s.Width, -s.Height, s.Height, 700, 1300);
        OpenGL.glMatrixMode(OpenGL.GL_MODELVIEW);
        OpenGL.glLoadIdentity();
    }
}

完整工作示例:http://cl.ly/2Z2m0A2v2U3p1j1m1p00