Permalink
Browse files

Make the blend font API not need a surface just to get the screen's f…

…ormat
  • Loading branch information...
creationix committed Jul 25, 2011
1 parent 1f101fa commit 13dc86e50296d9f8e3aee61a0f137ecdc54683ad
Showing with 8 additions and 8 deletions.
  1. +1 −1 examples/Fonts.js
  2. +7 −7 src/sdl.cc
View
@@ -30,7 +30,7 @@ setInterval(function () {
now = after;
SDL.fillRect(screen, null, 0);
var message = (Math.floor(100000 / delta) / 100) + "fps";
- var s = TTF.renderTextBlended(screen, font, message, 0xffffff);
+ var s = TTF.renderTextBlended(font, message, 0xffffff);
SDL.blitSurface(s, null, screen, [10, 10]);
SDL.freeSurface(s);
SDL.flip(screen);
View
@@ -818,17 +818,17 @@ static Handle<Value> sdl::TTF::OpenFont(const Arguments& args) {
static Handle<Value> sdl::TTF::RenderTextBlended(const Arguments& args) {
HandleScope scope;
- if (!(args.Length() == 4 && args[0]->IsObject() && args[1]->IsObject() && args[2]->IsString() && args[3]->IsNumber())) {
- return ThrowException(Exception::TypeError(String::New("Invalid arguments: Expected TTF::RenderTextBlended(Surface, Font, String, Number)")));
+ if (!(args.Length() == 3 && args[0]->IsObject() && args[1]->IsString() && args[2]->IsNumber())) {
+ return ThrowException(Exception::TypeError(String::New("Invalid arguments: Expected TTF::RenderTextBlended(Font, String, Number)")));
}
- SDL_Surface* screen = UnwrapSurface(args[0]->ToObject());
- TTF_Font* font = UnwrapFont(args[1]->ToObject());
- String::Utf8Value text(args[2]);
- int colorCode = args[3]->Int32Value();
+ SDL_PixelFormat* vfmt = SDL_GetVideoInfo()->vfmt;
+ TTF_Font* font = UnwrapFont(args[0]->ToObject());
+ String::Utf8Value text(args[1]);
+ int colorCode = args[2]->Int32Value();
Uint8 r, g, b;
- SDL_GetRGB(colorCode, screen->format, &r, &g, &b);
+ SDL_GetRGB(colorCode, vfmt, &r, &g, &b);
SDL_Color color;
color.r = r;

0 comments on commit 13dc86e

Please sign in to comment.