Ok no probs, I have the following code:
for(loop=1;loop<183; loop++)
{
cx = float(loop%26)/26.0f;
cy = float(loop/7)/7.0f;
glNewList(m_iDisplaySquare+loop, GL_COMPILE);
glBegin(GL_QUADS);
//Bottom Left
glTexCoord2f(cx,1-cy-0.1f); // Texture Coord (Bottom Left)
glVertex2i(-15.3f,-25.6f); // Vertex Coord (Bottom Left)
//Bottom Right
glTexCoord2f(cx+0.03846f,1-cy-0.1f); // Texture Coord (Bottom Right)
glVertex2i(15.3f,-25.6f); // Vertex Coord (Bottom Right)
//Top Right
glTexCoord2f(cx+0.03846f,1-cy); // Texture Coord (Top Right)
glVertex2i(15.3f,25.6f); // Vertex Coord (Top Right)
//Top Left
glTexCoord2f(cx,1-cy); // Texture Coord (Top Left)
glVertex2i(-15.3f,25.6f); // Vertex Coord (Top Left)
glEnd(); // Done Building Our Quad (Character)
glTranslated(30.6,0,0); // Move To The Right Of The Character
glEndList(); // Done Building The Display List
}
for(loop=1;loop<183; loop++)
{
cx = float(loop%26)/26.0f;
cy = float(loop/7)/7.0f;
glNewList(m_iDisplaySquare+loop, GL_COMPILE);
glBegin(GL_QUADS);
//Bottom Left
glTexCoord2f(cx,1-cy-0.1f); // Texture Coord (Bottom Left)
glVertex2i(-15.3f,-25.6f); // Vertex Coord (Bottom Left)
//Bottom Right
glTexCoord2f(cx+0.03846f,1-cy-0.1f); // Texture Coord (Bottom Right)
glVertex2i(15.3f,-25.6f); // Vertex Coord (Bottom Right)
//Top Right
glTexCoord2f(cx+0.03846f,1-cy); // Texture Coord (Top Right)
glVertex2i(15.3f,25.6f); // Vertex Coord (Top Right)
//Top Left
glTexCoord2f(cx,1-cy); // Texture Coord (Top Left)
glVertex2i(-15.3f,25.6f); // Vertex Coord (Top Left)
glEnd(); // Done Building Our Quad (Character)
glTranslated(30.6,0,0); // Move To The Right Of The Character
glEndList(); // Done Building The Display List
}
To copy to clipboard, switch view to plain text mode
This creates the list and allocates different parts of the .bmp to my quads.
void GLWidget
::Print(int x,
int y,
QString *sText,
int set
) //'set' is used for selecting the font set i.e. we can have a set of bold, a set of italicized, as set of normal fonts etc... {
if (set>1)
{
set=1;
}
glBindTexture(GL_TEXTURE_2D, texture[1]);
glDisable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glPushMatrix(); // Store The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
glOrtho(0,619,0,486,-1,1); // Set Up An Ortho Screen
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glPushMatrix(); // Store The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix
//This line positions the text
glTranslated(x,y,0); // Position The Text (0,0 - Bottom Left)
glListBase(m_iDisplaySquare+1-32+(128*set)); // Choose The Font Set (0 or 1)
glCallLists(sText->size(),GL_UNSIGNED_BYTE,sText); // Write The Text To The Screen
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glPopMatrix(); // Restore The Old Projection Matrix
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glPopMatrix(); // Restore The Old Projection Matrix
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
}
void GLWidget::Print(int x, int y, QString *sText, int set) //'set' is used for selecting the font set i.e. we can have a set of bold, a set of italicized, as set of normal fonts etc...
{
if (set>1)
{
set=1;
}
glBindTexture(GL_TEXTURE_2D, texture[1]);
glDisable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glPushMatrix(); // Store The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
glOrtho(0,619,0,486,-1,1); // Set Up An Ortho Screen
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glPushMatrix(); // Store The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix
//This line positions the text
glTranslated(x,y,0); // Position The Text (0,0 - Bottom Left)
glListBase(m_iDisplaySquare+1-32+(128*set)); // Choose The Font Set (0 or 1)
glCallLists(sText->size(),GL_UNSIGNED_BYTE,sText); // Write The Text To The Screen
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glPopMatrix(); // Restore The Old Projection Matrix
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glPopMatrix(); // Restore The Old Projection Matrix
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
}
To copy to clipboard, switch view to plain text mode
This is what I'm using to print. As I said, when I do:
sStringText = "abcdefg";
QString *pStringPointer
= &sStringText;
Print(619/4.63,400, pStringPointer, 0);
QString sStringText;
sStringText = "abcdefg";
QString *pStringPointer = &sStringText;
Print(619/4.63,400, pStringPointer, 0);
To copy to clipboard, switch view to plain text mode
What I get is jibberish. I have 7 lines of text in my .bmp with each line representing a unique set (each one differs by colour). At the moment, I get random letters of random colours popping up. For some reason I keep getting 6 letters popping up despite the fact that abcdefg is obviously a string of 7 characters.
I have gone through the tutorial by NeHe many times and nowhere do I see obvious code that define that say the 3 value in our list is c, nor do I see the evocation of that 3rd element when asking specifically for a c.
Bookmarks