// Gets called every frame HRESULT CRomList::OnGetSourceDataText( XUIMessageGetSourceText *pGetSourceTextData, BOOL& bHandled) { if( ( 0 == pGetSourceTextData->iData ) && ( ( pGetSourceTextData->bItemData ) ) ) { LPCWSTR lpszwBuffer = MultiCharToUniChar((char *)m_ListData[pGetSourceTextData->iItem].c_str()); pGetSourceTextData->szText = lpszwBuffer; bHandled = TRUE; } return S_OK; }
void SDL_GL_RenderTextCyrillic(char *text, int fontId, SDL_Color color, SDL_Rect *location) { SDL_Surface *initial; SDL_Surface *intermediary; int w,h; GLuint texture; TTF_Font *fnt = NULL; switch (fontId) { case 12: fnt = fnt_12pt; break; case 16: fnt = fnt_16pt; break; case 24: fnt = fnt_24pt; break; case 32: fnt = fnt_32pt; break; case 42: fnt = fnt_42pt; break; default: fnt = fnt_16pt; break; } wchar_t *utext = MultiCharToUniChar(text); /* Use SDL_TTF to render our text */ Uint16* stext = new Uint16[strlen(text)+1]; for (size_t i = 0; i < strlen(text); ++i) { stext[i] = utext[i]; } stext[strlen(text)] = 0; initial = TTF_RenderUNICODE_Blended(fnt,stext,color); delete[] stext; /* Convert the rendered text to a known format */ w = nextpoweroftwo(initial->w); h = nextpoweroftwo(initial->h); intermediary = SDL_CreateRGBSurface(0, w, h, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); SDL_BlitSurface(initial, 0, intermediary, 0); /* Tell GL about our new texture */ glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexImage2D(GL_TEXTURE_2D, 0, 4, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, intermediary->pixels ); /* GL_NEAREST looks horrible, if scaled... */ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); /* prepare to render our texture */ glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture); glColor3f(1.0f, 1.0f, 1.0f); /* Draw a quad at location */ glBegin(GL_QUADS); glTexCoord2f(0.0f, 1.0f); glVertex2f(location->x , location->y); glTexCoord2f(1.0f, 1.0f); glVertex2f((float)(location->x + w), location->y); glTexCoord2f(1.0f, 0.0f); glVertex2f((float)(location->x + w), (float)(location->y - h)); glTexCoord2f(0.0f, 0.0f); glVertex2f(location->x , (float)(location->y - h)); glEnd(); /* Clean up */ SDL_FreeSurface(initial); SDL_FreeSurface(intermediary); glDeleteTextures(1, &texture); }