Results 1 to 3 of 3

Thread: font please?

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2002
    Posts
    5

    font please?

    hi
    i used glut but i'd like to use a better font than the 7 that glut supplies
    i'm trying to use nehe's font tutorial (#13) and i managed to add it to my console app and get it to compile
    but nothing shows up! i hate to do this, but i don't know of any other way to explain it so i've pasted the font code below (only three functions, it's short, i promise!):

    #ifndef FONTS_H
    #define FONTS_H

    #include <windows.h>
    #include <math.h>
    #include <stdio.h>
    #include <stdarg.h>
    #include <gl\gl.h>
    #include <gl\glu.h>
    #include <gl\glaux.h>
    #include <GL\glut.h>
    #include "Fonts.h"

    HDC hDC=NULL; // Private GDI Device Context
    HGLRC hRC=NULL; // Permanent Rendering Context
    HWND hWnd=NULL; // Holds Our Window Handle
    HINSTANCE hInstance; // Holds The Instance Of The Application

    GLuint base; // Base Display List For The Font Set
    GLfloat cnt1; // 1st Counter Used To Move Text & For Coloring
    GLfloat cnt2; // 2nd Counter Used To Move Text & For Coloring

    bool keys[256];
    bool active=TRUE;
    bool fullscreen=TRUE;

    LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);


    GLvoid BuildFont(GLvoid)
    {
    HFONT font;
    HFONT oldfont;
    base = glGenLists(96);
    font = CreateFont( -24, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS,
    ANTIALIASED_QUALITY, FF_DONTCARE|DEFAULT_PITCH,
    "Courier");

    oldfont = (HFONT)SelectObject(hDC, font);
    wglUseFontBitmaps(hDC, 32, 96, base); SelectObject(hDC, oldfont); DeleteObject(font);
    }

    GLvoid KillFont(GLvoid)
    {
    glDeleteLists(base, 96);
    }

    GLvoid glPrint(const char *fmt, ...)
    {
    char text[256]; va_list ap; // Pointer To List Of Arguments

    if (fmt == NULL) return;
    va_start(ap, fmt); // Parses The String For Variables

    vsprintf(text, fmt, ap); // And Converts Symbols To Actual Numbers
    va_end(ap);
    // Results Are Stored In Text

    glPushAttrib(GL_LIST_BIT); // Pushes The Display List Bits
    glListBase(base - 32); // Sets The Base Character to 32
    glCallLists(strlen(text), GL_UNSIGNED_BYTE, text);
    // Draws The Display List Text
    glPopAttrib(); // Pops The Display List Bits
    }

  2. #2
    Senior Member Regular Contributor
    Join Date
    Oct 2002
    Posts
    201

    Re: font please?

    use glRasterPos() to set the x and y corridinates of the text

  3. #3
    Guest

    Re: font please?

    i recommend using GLFont instead (it's free), search for it at google... .

    ------------------------------------
    PLUG: http://nomad.openglforums.com
    ------------------------------------

Similar Threads

  1. font problem???
    By ayortanli in forum OpenGL: Linux
    Replies: 4
    Last Post: 05-17-2005, 02:20 AM
  2. font help
    By naruto in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-20-2004, 12:30 AM
  3. More font fun.
    By CatAtWork in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 08-13-2003, 09:56 PM
  4. OS X 3D Font
    By in forum OpenGL: macOS
    Replies: 1
    Last Post: 10-21-2002, 01:02 PM
  5. Regarding Font
    By suresh kannan in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-15-2001, 04:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean