bug-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

comp.graphics.api.opengl


From: zoe
Subject: comp.graphics.api.opengl
Date: 20 May 2002 11:05:46 -0700

Hi, 

I need to draw textured font... so i use "glfont" from the following web site:
http://students.cs.byu.edu/~bfish/glfontdl.php

I tried to use the simple program to draw a string.. But can't...
I can draw glRect on the program....

Could anyone help me and tell me how ?? anything wrong???
I am eager to know and wish can do the task.... Please tell me???

thanks 
zoe

//glFont font

#include <windows.h>
#include <gl/glut.h>
#include "glfont.h"

GLFONT font;



// Called to draw scene
void RenderScene(void)
        {
        // Clear the window with current clearing color
        glClear(GL_COLOR_BUFFER_BIT);

        // Set current drawing color to red
        //                 R     G         B
        glColor3f(1.0f, 0.0f, 0.0f);

        // Draw a filled rectangle with current color
        //glRectf(100.0f, 150.0f, 150.0f, 100.0f);


        glFontBegin(&font);
        glScalef(8.0, 8.0, 8.0);
        //glTranslatef(30, 30, 0);
        glFontTextOut("Test string", 5, 5, 0);
        glFontEnd();

        //Destroy the font
        glFontDestroy(&font);

        // Flush drawing commands
    glFlush();
        }

// Setup the rendering state
void SetupRC(void)
    {
    glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
        glEnable(GL_TEXTURE_2D);
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    }


// Called by GLUT library when the window has chanaged size
void ChangeSize(GLsizei w, GLsizei h)
        {
        // Prevent a divide by zero
        if(h == 0)
                h = 1;
                
        // Set Viewport to window dimensions
    glViewport(0, 0, w, h);

        // Reset coordinate system
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();

        // Establish clipping volume (left, right, bottom, top, near, far)
    if (w <= h) 
                glOrtho (0.0f, 250.0f, 0.0f, 250.0f*h/w, 1.0, -1.0);
    else 
                glOrtho (0.0f, 250.0f*w/h, 0.0f, 250.0f, 1.0, -1.0);

        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        }


// Main program entry point
void main(void)
    {
        glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
        glutCreateWindow("glFont");
        glutDisplayFunc(RenderScene);
        glutReshapeFunc(ChangeSize);

        SetupRC();

        glutMainLoop();
    }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]