|
|
View previous topic - View next topic |
Author |
Message |
DeveloperX 202192397
Joined: 04 May 2003 Posts: 1626 Location: Decatur, IL, USA
|
Posted: Tue Apr 17, 2007 10:04 pm Post subject: Question about LUA and C integration |
[quote] |
|
I've got a question for someone who may have had this problem before.
Now, first I know this isn't the lua support line, but I know that at least one person here has used LUA here, and I figured I'd ask someone I know instead of posting on yet another forum.
Question: How can I pass my allegro BITMAP* pointer back to lua, and have it passed around my lua script, and returned back to my C host?
BITMAP* GetDoubleBuffer();
For this function, I tried this code:
Code: |
Binder bind (pLuaState);
bind.pushnumber(GetDoubleBuffer()
return 1;
|
Binder just wraps up common functionality in a class. I've tested it with ints, doubles, a C-strings, without any trouble.
But, I cannot pass my pointer......I thought that technically a pointer was a number... _________________ Principal Software Architect
Rambling Indie Games, LLC
See my professional portfolio
|
|
Back to top |
|
|
Bjorn Demon Hunter
Joined: 29 May 2002 Posts: 1425 Location: Germany
|
Posted: Tue May 01, 2007 11:24 pm Post subject: |
[quote] |
|
You should use lua_pushlightuserdata for putting your pointers on the Lua stack. When retrieving such data as arguments to C functions, optionally use luaL_checktype with LUA_TLIGHTUSERDATA to check the argument type before using lua_touserdata to get the pointer.
I hope this is still useful to you...
|
|
Back to top |
|
|
DeveloperX 202192397
Joined: 04 May 2003 Posts: 1626 Location: Decatur, IL, USA
|
|
Back to top |
|
|
|
Page 1 of 1 |
All times are GMT
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|