Jump to content
  • Advertisement
Sign in to follow this  
CSharper

OpenGL I've yet the problems with Drawing a text into screen

This topic is 4814 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi again fellows Thanks for help to answer my question before, but I'M YET IN TROUBLEEEEEE. The CriaFonte and ImprimeTexto are my functions that creates the fonts and prints in screen(teorically). When I start the program nothing is impressed, what's going on? Below the code, thanks for all help: unsigned int CriaFonte(HDC* hdc) { HFONT font; HFONT oldfont; unsigned int iBase = glGenLists(96); glListBase(1000); font = CreateFont(-20, 0, GM_COMPATIBLE, 50, FW_DONTCARE | FW_BOLD, false, false, false, ANSI_CHARSET|DEFAULT_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FF_DONTCARE| DEFAULT_PITCH, "Arial"); oldfont = (HFONT) SelectObject(*hdc, font); wglUseFontBitmaps(*hdc, 32, 96, iBase); SelectObject(*hdc, oldfont); DeleteObject(font); return iBase; } void ImprimeTexto(unsigned int ibase, const char* c) { if(ibase == 0 || c ==NULL) return; glPushAttrib(GL_LIST_BIT); glListBase(ibase - 32); glCallLists(strlen(c), GL_UNSIGNED_BYTE, c); glPopAttrib(); } this code is in my infinite loop in main method: while(!bQuit) { ... else { iFont = CriaFonte(&hdc); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics (SM_CYSCREEN),0); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT); ImprimeTexto(iFont, "caracteres"); glPushMatrix(); interface_Background(bgnd); glPopMatrix(); } } DeletaLista(iFont); DisableOpenGL(hwnd, hdc, hrc); }//end of main method

Share this post


Link to post
Share on other sites
Advertisement
At first glance, I notice that you are calling CriaFonte every tick.

Move:

iFont = CriaFonte(&hdc);

outside of your while loop and call it only once.

Share this post


Link to post
Share on other sites
I've done. I've put the text in screen, I've forget to call SwapBuffers() function. Thanks for your help, now the text don't flick.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!