TODO: make an async version so this can be used in loops or parallel load images
| 880 | |
| 881 | // TODO: make an async version so this can be used in loops or parallel load images |
| 882 | static Handle<Value> sdl::IMG::Load(const Arguments& args) { |
| 883 | HandleScope scope; |
| 884 | |
| 885 | if (!(args.Length() == 1 && args[0]->IsString())) { |
| 886 | return ThrowException(Exception::TypeError(String::New("Invalid arguments: Expected IMG::Load(String)"))); |
| 887 | } |
| 888 | |
| 889 | String::Utf8Value file(args[0]); |
| 890 | |
| 891 | SDL_Surface *image; |
| 892 | image=IMG_Load(*file); |
| 893 | if(!image) { |
| 894 | return ThrowException(Exception::Error(String::Concat( |
| 895 | String::New("IMG::Load: "), |
| 896 | String::New(IMG_GetError()) |
| 897 | ))); |
| 898 | } |
| 899 | |
| 900 | return scope.Close(WrapSurface(image)); |
| 901 | } |
| 902 | |
| 903 | static Handle<Value> sdl::WM::SetCaption(const Arguments& args) { |
| 904 | HandleScope scope; |
nothing calls this directly
no test coverage detected