I'm trying to render a string to screen and I can't get it to work
I use freeglut
and visual studio 2013
. This is my glutinit
:
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH | GLUT_ALPHA); // Double buffering, RGB format
glutInitWindowSize(width, heigth);
glutInitWindowPosition(0, 0);
glutCreateWindow("Project Demeter");
glClearColor(1.0, 1.0, 1.0, 1.0);
glColor3f(1.0, 1.0, 1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, width, heigth, 0.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEnable(GL_BLEND);
glEnable(GL_POINT_SMOOTH);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
and my text drawing:
void text::draw()
{
glColor3ub(_color[0], _color[1], _color[2]);
glRasterPos2f(_x, _y);
glDisable(GL_TEXTURE);
glDisable(GL_TEXTURE_2D);
for (char& c : _str)
{
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, c);
}
}
however nothing is drawn on the screen when i create a text as such:
float clr[3] = { 0, 0, 0 };
text* txt = new text(&DrawList, "test1234", clr, 600, 600);
does anyone know what im doing wrong and how i can fix this?
EDIT: by request the constructor:
text::text(std::list<item*>* BaseList, const string str, const float color[3], int x, int y)
:item(BaseList)
{
if (str == "")
{
assert(0);
}
_str = str;
_x = x;
_y = y;
if (!color) { // When a null pointer is passed to this function
_color[0] = 0;// black is used
_color[1] = 0;
_color[2] = 0;
}
else { //else copy it over
copy_array(color, _color);
}
}
EDIT2: so i tested it on a windows 8 machine and it worked there? wtf? im using w7 normally. this is very strange.