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

Started by
1 comment, last by CSharper 18 years, 6 months ago
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
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.
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.

This topic is closed to new replies.

Advertisement