Original Post
Been trying to build an OpenGL 2d engine for a few 2d projects that I've either always wanted to build, or would like to build and have gotten other people to do the hard work for (design doc, concept, etc... ;)). My problem lies in that I'm trying to make "UI Strings" that can contain text and images. I'm using a vector to store the structs which consist of either a string or a sprite, and an identifier to tell which type it is. According to MSDN, glCallLists() doesn't clear any state changes that it makes. This *seems* to be true, as when I put multiple pieces of text in it they display next to each other right. However, when I try to shove an image between them, it displays itself at the origin of the string. This is my UI string rendering function:
void cUIString::Draw()
{
int i;
GLenum Error;
// preserve OGL state outside of here
glPushMatrix();
glPushAttrib(GL_LIST_BIT);
// set up color (looks odd if called after position is set up)
glColor3f(1.0f, 1.0f, 1.0f);
// set up the position
glLoadIdentity();
glTranslatef(xPos, yPos, 0.0f);
glRasterPos2f(0.0f, 0.0f);
for(i = 0; i < MyData.size(); i++)
{
if(MyData.ElementType == UISTRING_TEXT)
{
glListBase((unsigned int)MyFont->GetDispListName() - 32);
glCallLists(strlen(MyData.Text), GL_UNSIGNED_BYTE, MyData.Text);
}
else
{
// funny translations
glPushMatrix();
glTranslatef(0.0f, -MyData.Sprite.GetYSize(), 0.0f);
MyData.Sprite.Draw();
glTranslatef(MyData.Sprite.GetXSize(), 0.0f, 0.0f);
glPopMatrix();
}
}
glPopAttrib();
glPopMatrix();
Error = glGetError();
if(Error != GL_NO_ERROR)
{
MessageBox(NULL, "ERROR", "A GL Error has occured in cUIString::Draw", MB_OK);
PostQuitMessage(0);
}
glLoadIdentity();
}