wglUseFontBitmaps 未在屏幕上绘制

发布于 2024-11-27 12:05:07 字数 1034 浏览 4 评论 0原文

我之前已经在 gis.stackexchange 中发布了这个问题,但我不确定这实际上是否是发布它的正确位置,因为这更多是一个编码/技术问题。我正在尝试在 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();
}

编辑:由于预先存在的要求,我必须使用 CsGL http://csgl.sourceforge.net/

I've posted this question in gis.stackexchange earlier but I'm not sure if that was in fact the right place to post it, since this is more of a coding/technical question. I'm attempting to draw a character in 3D Space. However, nothing seems to place the character on the screen.

Below is what I'm attempting to do in code: Anyone have any ideas? I'm beyond lost at this point and will admit that I know next to nothing about 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();
}

EDIT: Due to pre-existing requirements I must use CsGL
http://csgl.sourceforge.net/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

神回复 2024-12-04 12:05:07

现在终于可以用了!

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

Finally now it works!

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();
    }
}

Complete working example: http://cl.ly/2Z2m0A2v2U3p1j1m1p00

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文