Hi all,
I’m new here, so excuse me if I do something wrong (and excuse me for my english, I’ll try to be correct…)
I’ve tried to make a research with the search function, but I’ve found nothing.
I’m trying to write a program which needs the presence of a text string in the glut window, at coordinates (x,y). The string needs to be written over a GL_QUADS.
Part of the code I’ve written is here:
void keyboard::display (void) //METHOD: DISPLAY
{
glClearColor(0.6f, 0.6f, 0.8f, 1.0f); // Clear the background of our window to the chosen colour
glClear(GL_COLOR_BUFFER_BIT); //Clear the colour buffer
glLoadIdentity(); // Load the Identity Matrix to reset our drawing locations
glTranslatef(0.0f, 0.0f, -5.0f); //Push eveything 5 units back into the scene, otherwise we won't see the primitive
m_renderPrimitive(); // Render the primitive
glutPostRedisplay();
glFlush();
}
void keyboard::m_renderPrimitive (void) //METHOD: renderPRIMITIVE
{
//Drawing the keyboard
m_drawChoices();
m_drawOctave();
}
void keyboard::m_drawChoices()
{
keyboard key;
glBegin(GL_QUADS); //"Support" of keyboard
glColor3f(0.2f, 0.2f, 0.2f);
glVertex3f(-5.0f, 3.0f, 0.0f);
glVertex3f(5.0f, 3.0f, 0.0f);
glVertex3f(5.0f, -2.5f, 0.0f);
glVertex3f(-5.0f, -2.5f, 0.0f);
glEnd();
m_drawDisp();
}
void keyboard::m_drawDisp() //That's the method with the text to render!
{
std::string message="Welcome";
glColor3f(1.0, 0.2, 0.2); //a great red
glRasterPos2i(-1.5, 3);
glutBitmapString(GLUT_BITMAP_TIMES_ROMAN_24, (const unsigned char*)message.c_str()); //This is a feature of freeglut, needs
//"freeglut.h"!
}
The method that gives me problems is keyboard::m_drawDisp(), which is the last I’ve written. I’ve reported the other methods too, so you can see all the GL_functions that I call.
I’ve problems with glRasterPos2i. The x coordinate functions well, the y coordinate not. It displays text only if y coordinate is 2<y<2.9, else it displays nothing… notice that if I change y between 2 and 2.9 the y position of the text DOESN’T change, it remains always in the same place… (with x coordinate I have no problems).
I’m using freeglut libs, with gcc4.7 on Fedora 17, if this could be an help.
Thank you for the attention, I hope on a response