|
@@ -228,6 +228,8 @@ int WindowSDL::initializeFont() {
|
228
|
228
|
return -2;
|
229
|
229
|
}
|
230
|
230
|
|
|
231
|
+ glGenTextures(1, &mFontTexture);
|
|
232
|
+
|
231
|
233
|
mFontInit = true;
|
232
|
234
|
return 0;
|
233
|
235
|
}
|
|
@@ -248,22 +250,38 @@ void WindowSDL::writeString(WindowString *s) {
|
248
|
250
|
return;
|
249
|
251
|
}
|
250
|
252
|
|
251
|
|
- SDL_Surface *window = SDL_GetWindowSurface(mWindow);
|
252
|
|
- if (window == NULL) {
|
253
|
|
- printf("SDL_GetWindowSurface Error: %s\n", SDL_GetError());
|
254
|
|
- return;
|
|
253
|
+ GLenum textureFormat;
|
|
254
|
+ if (surface->format->BytesPerPixel == 4) {
|
|
255
|
+ if (surface->format->Rmask == 0x000000FF)
|
|
256
|
+ textureFormat = GL_RGBA;
|
|
257
|
+ else
|
|
258
|
+ textureFormat = GL_BGRA_EXT;
|
|
259
|
+ } else {
|
|
260
|
+ textureFormat = GL_RGB;
|
255
|
261
|
}
|
256
|
262
|
|
257
|
|
- SDL_Rect destination;
|
258
|
|
- destination.x = s->x;
|
259
|
|
- destination.y = s->y;
|
260
|
|
- destination.w = (int)((float)surface->w * s->scale);
|
261
|
|
- destination.h = (int)((float)surface->h * s->scale);
|
|
263
|
+ glBindTexture(GL_TEXTURE_2D, mFontTexture);
|
|
264
|
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
265
|
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
266
|
+ glTexImage2D(GL_TEXTURE_2D, 0, surface->format->BytesPerPixel, surface->w, surface->h, 0, textureFormat, GL_UNSIGNED_BYTE, surface->pixels);
|
262
|
267
|
|
263
|
|
- if (SDL_BlitScaled(surface, NULL, window, &destination) != 0) {
|
264
|
|
- printf("SDL_BlitScaled Error: %s\n", SDL_GetError());
|
265
|
|
- return;
|
266
|
|
- }
|
|
268
|
+ glEnter2D(mWidth, mHeight);
|
|
269
|
+
|
|
270
|
+ glBegin(GL_QUADS);
|
|
271
|
+ glTexCoord2f(0.0f, 0.0f);
|
|
272
|
+ glVertex2i(s->x, s->y);
|
|
273
|
+
|
|
274
|
+ glTexCoord2f(0.0f, 1.0f);
|
|
275
|
+ glVertex2i(s->x, (int)((float)surface->h * s->scale));
|
|
276
|
+
|
|
277
|
+ glTexCoord2f(1.0f, 1.0f);
|
|
278
|
+ glVertex2i((int)((float)surface->w * s->scale), (int)((float)surface->h * s->scale));
|
|
279
|
+
|
|
280
|
+ glTexCoord2f(1.0f, 0.0f);
|
|
281
|
+ glVertex2i((int)((float)surface->w * s->scale), s->y);
|
|
282
|
+ glEnd();
|
|
283
|
+
|
|
284
|
+ glExit2D();
|
267
|
285
|
|
268
|
286
|
SDL_FreeSurface(surface);
|
269
|
287
|
}
|