Jump to content

  • Log In with Google      Sign In   
  • Create Account


displaying numbers using opengl


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 phil67rpg   Members   -  Reputation: 767

Like
0Likes
Like

Posted 17 December 2012 - 10:09 PM

I want to display a score number for my breakout game but I am unsure of how to begin.

Sponsor:

#2 Blackarch   Members   -  Reputation: 553

Like
0Likes
Like

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.

Software Engineer | Credited Titles: League of Legends, Hearthstone


#3 phil67rpg   Members   -  Reputation: 767

Like
0Likes
Like

Posted 17 December 2012 - 11:40 PM

I don't want to use shaders yet.

#4 NoAdmiral   Members   -  Reputation: 511

Like
-1Likes
Like

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.

Inspiration from my tea:

"Never wish life were easier. Wish that you were better" -Jim Rohn

 

herwrathmustbedragons.tumblr.com


#5 EVIL_ENT   Members   -  Reputation: 212

Like
0Likes
Like

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

#6 phil67rpg   Members   -  Reputation: 767

Like
0Likes
Like

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.
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 ();
}


#7 phil67rpg   Members   -  Reputation: 767

Like
0Likes
Like

Posted 10 January 2013 - 06:03 PM

well I googled this topic but did not find very much, there has to be a simple way to print numbers to the screen.

#8 RulerOfNothing   Members   -  Reputation: 1160

Like
0Likes
Like

Posted 10 January 2013 - 09:04 PM

Since you have the ability to draw strings to the screen, you should look into how to convert integers into strings in your language of choice.

#9 phil67rpg   Members   -  Reputation: 767

Like
0Likes
Like

Posted 10 January 2013 - 09:20 PM

I am using c++ and opengl




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS