Trouble Custom Font Open GL

I'm having trouble trying to adapt (the red book font tutorial) and create my own font. So far the issue I'm having is that my makeFont Function doesn't appear to store my "pseudo fonts" for display.

I don't quite understand why the polygons I put aren't being displayed.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
void makeFont(void)
{
    GLuint i;
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    fontOffset = glGenLists (128);
    for (i = 32; i < 58; i++) {
        glNewList(i+fontOffset, GL_COMPILE);
           draw_ball();
        glEndList();
    }

	for (i = 58; i < 96; i++) {
        glNewList(i+fontOffset, GL_COMPILE);
           draw_ball2();
        glEndList();
    }
	for (i = 96; i < 127; i++) {
        glNewList(i+fontOffset, GL_COMPILE);
           draw_ball3();
        glEndList();
    }
}

void Init(void)
{
    glShadeModel (GL_FLAT);//this can be flat or smooth
    makeFont();
}

void printString(char *s)
{
    glPushAttrib (GL_LIST_BIT);
    glListBase(fontOffset);
    glCallLists(strlen(s), GL_UNSIGNED_BYTE, (GLubyte *) s);
    glPopAttrib ();
}

void display(void)
{
    GLfloat white[3] = { 1.0, 0.0, 0.0 };//colour change
    int i, j;
    char teststring[33];

    glClear(GL_COLOR_BUFFER_BIT);
    glColor3fv(white);
    for (i = 32; i < 127; i += 32) {
        glRasterPos2i(20, 200 - 18*i/32);
        for (j = 0; j < 32; j++)
            teststring[j] = (char) (i+j);
        teststring[32] = 0;
        printString(teststring);
    }
    
    printString("The quick brown fox jumps");
    
    printString("over a lazy dog.");
	glEnd();
    glFlush ();
	glutSwapBuffers();
}


Header file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef _FONTS_H_H
#define _FONTS_H_H

#define PI 3.1415926535898 
GLint circle_points = 145445; 
void MyCircle2f(GLfloat centerx, GLfloat centery, GLfloat radius){
  GLint i;
  GLdouble angle;
  glBegin(GL_POLYGON); 
  for (i = 0; i < circle_points; i++) {    
    angle = 2*PI*i/circle_points; 
    glVertex2f(centerx+radius*cos(angle), centery+radius*sin(angle)); 
  } 
  glEnd();
}

GLfloat RadiusOfBall = 15.;
// Draw the ball, centered at the origin
static void draw_ball() {
  glColor3f(0.6,0.3,0.);
  MyCircle2f(0.,0.,RadiusOfBall);
 }

static void draw_ball2() {
  glColor3f(0.0,0.0,1.0);
  MyCircle2f(0.,0.,RadiusOfBall);
 }

static void draw_ball3() {
  glColor3f(0.0,1.0,0.);
  MyCircle2f(0.,0.,RadiusOfBall);
 }

static void draw_ball4() {
  glColor3f(1.0,0.0,0.);
  MyCircle2f(0.,0.,RadiusOfBall);
 }
#endif 

Topic archived. No new replies allowed.