Sign in to follow this  
orcfan32

Can Lua create a SDL_Surface?

Recommended Posts

That's not really a problem - if it was, then you wouldn't really be able to use any library with Lua. What happens instead is that you just get back an object that you can treat as an SDL_Surface. It doesn't need to have a specific type as such. Typically in Lua this might be a table containing methods that apply to SDL_Surfaces, plus a Userdata item containing a pointer to the actual surface itself.

http://lua-users.org/wiki/LuaModuleLuaSdl

Share this post


Link to post
Share on other sites
One slight problem: since Lua can't recognize a SDL_Surface by default, I tried this:
int x;
int y;
SDL_Surface *source = NULL;
SDL_Surface *dest = NULL;

if (lua_isnumber(LuaVM, 1))
{
x = lua_tointeger(LuaVM, 1);
}
if (lua_isnumber(LuaVM, 2))
{
y = lua_tointeger(LuaVM, 2);
}
if (lua_islightuserdata(LuaVM, 3))
{
source = lua_touserdata(LuaVM, 3);
}
if (lua_islightuserdata(LuaVM, 4))
{
dest = lua_touserdata(LuaVM, 4);
}

But when I go to compile it, it gives me:
error C2440: '=' : cannot convert from 'void *' to 'struct SDL_Surface *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast


Is there an easy way to fix this or am I doing something horribly wrong?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this