Skip to content

Instantly share code, notes, and snippets.

@FlyingJester
Created November 25, 2013 02:03
Show Gist options
  • Save FlyingJester/7635146 to your computer and use it in GitHub Desktop.
Save FlyingJester/7635146 to your computer and use it in GitHub Desktop.
template <class TSim>
TS_Texture getTextureFromImage(TSim *a) {
return a->texture;
}
v8Function spritebatcherAddImage(V8ARGS){
if(args.Length()==0){
THROWERROR(" Error: Called with fewer than one argument.");
}
TS_SpriteBatchTextureType type = TS_SpriteBatchTextureType::INVALID;
SDL_Surface *surf = NULL;
TS_Texture tex = 0;
v8::Local<v8::Object> textureObj = v8::Local<v8::Object>::Cast(args[0]);
if(textureObj->InternalFieldCount()<2){
fprintf(stderr, "[" PLUGINNAME "] %s Error: Invalid object for argument 0. Using wrong graphics plugin?\n", __func__);
}
if(textureObj->GetInternalField(1)->Uint32Value()==*(TS_SDL_GL_GetSurfaceIDDL())){
TS_SpriteBatchTextureType type = TS_SpriteBatchTextureType::SDL_SURFACE;
SDL_Surface *surf = (SDL_Surface*)textureObj->GetAlignedPointerFromInternalField(0);
}
else if(textureObj->GetInternalField(1)->Uint32Value()==*(TS_SDL_GL_GetImageIDDL())){
TS_SpriteBatchTextureType type = TS_SpriteBatchTextureType::SDL_SURFACE;
tex = getTextureFromImage(textureObj->GetAlignedPointerFromInternalField(0)); //GetAlignedPointer returns a void *.
}
return v8::Undefined();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment