Jump to content
  • Advertisement
Sign in to follow this  
e_pech

CString and glCallLists

This topic is 3724 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

I have a problem with CString and glCallLists. This is my code: ------------------------------------------------------------------- LOGFONT lf; HFONT hFont, hOldFont; GLYPHMETRICSFLOAT agmf[256]; memset(&lf,0,sizeof(LOGFONT)); lf.lfHeight = -20 ; lf.lfWeight = FW_NORMAL ; lf.lfCharSet = ANSI_CHARSET ; lf.lfOutPrecision = OUT_DEFAULT_PRECIS ; lf.lfClipPrecision = CLIP_DEFAULT_PRECIS ; lf.lfQuality = DEFAULT_QUALITY ; lf.lfPitchAndFamily = FF_DONTCARE|DEFAULT_PITCH; lstrcpy (lf.lfFaceName, L"Arial") ; hFont = CreateFontIndirect(&lf); hOldFont = (HFONT) SelectObject(hDC,(HGDIOBJ)hFont); if (!(wglUseFontOutlines(hDC, 0, 255, 1000, 0.0f, 0.15f, WGL_FONT_LINES, agmf))) MessageBox(L"wglUseFontOutlines failed!",L"GLFont",MB_OK); DeleteObject(SelectObject(hDC,hOldFont)); glListBase(1000); // indicate start of display lists CStringW x = L"HOLA"; glCallLists(x.GetAllocLength(), GL_BYTE, x); ------------------------------------------------------------------- I want to output the text stored in CString variable 'x'. When I do that, what I get is the 'H' then a Square (like a character that cannot be displayed) the 'O' and another Square. Can any one help me find out why is that?

Share this post


Link to post
Share on other sites
Advertisement
You are creating a CStringW, so I assume each character occupies two bytes, while you are saying to glCallLists() that it occupies just one. Try passing it GL_UNSIGNED_SHORT. If that doesn't work, try using CStringA.

Share this post


Link to post
Share on other sites
Seems to be a unicode problem. In UTF16 unicode each character is encoded with 2 bytes, one of them indicating the original ASCII character.

glCallLists does interpret the string in bytes which gets you 2 output 'characters' for 1 input character. Try GL_SHORT instead of GL_BYTE or use a non-unicode - i.e. single byte - string.

Share this post


Link to post
Share on other sites
AWESOME!! THANKS!! I Tried both suggestions, they both worked. I still used CStringW however I used GL_UNSIGNED_SHORT and it worked, it also worked with GL_SHORT... thanks to both of you!!

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!