I want to display a score number for my breakout game but I am unsure of how to begin.
8 replies to this topic
Sponsor:
#2 Members - Reputation: 255
Posted 17 December 2012 - 11:36 PM
http://jonmacey.blogspot.com/2011/10/text-rendering-using-opengl-32.html
Found this within 3 seconds of googling.
Found this within 3 seconds of googling.
#4 Members - Reputation: 325
Posted 18 December 2012 - 12:13 AM
I'd suggest buying yourself a copy of C# Game Programming for Serious Game Creation. I see that you're using C++, but that book answers a lot of your questions (looking at your post history), including this one, and I think translating the code from C# (a very easy-to-read language) to C++ might be good practice for you. Alternatively you might find you like C#'s syntax to be more your speed, in which case, great.
Edited by NoAdmiral, 18 December 2012 - 12:16 AM.
#5 Members - Reputation: 167
Posted 18 December 2012 - 12:57 AM
if you are using freeglut you can use the functions glutBitmapString or glutStrokeString
otherwise you will have to create them from scratch:
1. make/search an image with all the numbers you want to display (e.g. search for ascii texture)
2. write/find some code to load images
3. create a texture from it
4. draw some quads with the right texture coordinates to select the correct character from your texture
otherwise you will have to create them from scratch:
1. make/search an image with all the numbers you want to display (e.g. search for ascii texture)
2. write/find some code to load images
3. create a texture from it
4. draw some quads with the right texture coordinates to select the correct character from your texture
#6 GDNet+ - Reputation: 519
Posted 18 December 2012 - 09:03 PM
well I figured out how to print strings to the screen, now I want to print numbers to the screen for scoring purposes.
here is the code I am using.
here is the code I am using.
GLuint fontOffset;
void makeRasterFont(void)
{
GLuint i;
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
fontOffset = glGenLists (128);
for (i = 32; i < 127; i++) {
glNewList(i+fontOffset, GL_COMPILE);
glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, rasters[i-32]);
glEndList();
}
}
void myinit(void)
{
glShadeModel (GL_FLAT);
makeRasterFont();
}
//print the string
void printString(char *s)
{
glPushAttrib (GL_LIST_BIT);
glListBase(fontOffset);
glCallLists(strlen(s), GL_UNSIGNED_BYTE, (GLubyte *) s);
glPopAttrib ();
}






