开发者

wglUseFontBitmaps is not drawing on screen

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/


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜