Cannot get text to be displayed
I have just recently started working with OpenGL in school and am having trouble getting text to be displayed on the screen. I am not familiar with all the functions yet, this was just a blank screen code provided by my proof in which I injected my own code for the text.
Code:
#include <windows.h>
#include <math.h>
#include <stdio.h>
#include <time.h>
#include <GL/gl.h>
#include <GL/glut.g>
#include <iostream>
#define GLUT_DISABLE_ATEXIT_HACK
#define win_width 640
#define win_height 480
int font = (int)GLUT_BITMAP_8_BY_13;
using namespace std;
void renderBitmapString(float x, float y, void *font, char *string)
{
char *c;
glRasterPos2f(x, y);
for (c=string; *c != '\0'; c++)
{
glutBitmapCharacter(font, *c);
}
}
void init() {
glClearColor(0.3f, 0.0f, 0.0f, 1.0f);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0,0,win_width,win_height);
gluOrtho2D(0.0f, 256.0f, 0.0f, 256.0f);
} // end init()
void display() {
glClear(GL_COLOR_BUFFER_BIT);
glutSwapBuffers();
renderBitmapString(50,50,(void *)font,"Testing Bitmap Text");
} // end display()
int main(int argc, char* argv[]) {
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(win_width, win_height);
glutCreateWindow("Snipa");
init();
glutDisplayFunc(display);
glutMainLoop();
}
The window apears, and I can change the background colour accordingly, but no text, any advice would be great, thanks.