c++ - Drawing large text with GLUT? -


i have created tic-tac-toe game school, , finished. thing have left when wins, want box pop on screen , in big text "x wins" or "o wins" depending on one.

i've found drawing text in opengl complicated. since isn't crucial assignment, i'm not looking complicated or , don't need super nice. also, want change code. also, want size of text variable driven when re-size window.

this text drawing function looks like. draws small.

note: mtext int [2] data member holds want draw text

void fullgame::drawtext(const char *string) const {     glcolor3d(1, 1, 1);      void *font = glut_bitmap_times_roman_24;      glblendfunc(gl_src_alpha, gl_one_minus_src_alpha);     glenable(gl_blend);      int len, i;     glrasterpos2d(mtext[0], mtext[1]);     len = (int)strlen(string);     (i = 0; < len; i++)     {         glutbitmapcharacter(font, string[i]);     }      gldisable(gl_blend); } 

short answer:

you drawing bitmap characters cannot resized since given in pixels. try using stroke character or string 1 of following functions: glutstrokecharacter, glutstrokestring. stroke fonts can resized using glscalef.

long answer:

actually, instead of printing text character character have used:

glutbitmapstring(glut_bitmap_times_roman_24, "text appear!"); 

here font size in pixel scaling not work in direct usage.

please note glutbitmapstring introduced in freeglut, open source alternative opengl utility toolkit (glut) library. more details in font rendering: http://freeglut.sourceforge.net/docs/api.php#fontrendering

i advice using freeglut rather original glut.

1 - glut`s last release before year 2000 has missing features: http://www.lighthouse3d.com/cg-topics/glut-and-freeglut/

2 - 2 of common glut replacements openglut , freeglut, both of open source projects.

if decide using freeglut should have following include:

#include < gl/freeglut.h> 

having said need scaling text, therefore can use glutstrokestring more flexible bitmap string,e.g., can resized visually. can try:

glscalef(0.005,0.005,1); glutstrokestring(glut_stroke_roman, (unsigned char*)"the game over!"); 

hope helps!


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -