Register  |  FAQ  |  Search  |  Memberlist  |  Usergroups  |  Log in 
Reply to topic
 video texture and using dlls 
liverol


Joined: 29 Jun 2007
Posts: 45
Reply with quote
hi there,some new suggestions:
so aw is using for creating 3d movies,so why not add some functions to use video texture,people can use some
video for textures to show a real movie in the 3d world(load *.avi/mpg etc.),that's really useful,also,i wonder if there is a way to load Dll directly in lua ,if not ,can you add some function to do this? it's important to extend some functions in aw by using Dlls. like connect the hardware(some external device!)

thanks for reply.
View user's profile Send private message
  
Vincent


Joined: 25 Dec 2006
Posts: 296
Reply with quote
Sure, video textures is useful, we'll try to achieve this feature in the next version, thanks for your advice.

Extending functions by DLL is easy, the require command can load DLL.
Here is a sample:

1. Create a DLL

Code:
//lua_net.cpp




//open
static int net_Open(lua_State* L)
{
   lua_pushstring(L,"net open");
   return 1;
}

//close
static int net_Close(lua_State* L)
{
   lua_pushstring(L,"net close");
   return 1;
}


static const luaL_Reg syslib[] = {
   {"open",      net_Open},
   {"close",      net_Close},
   {NULL, NULL}
};


extern "C"{

__declspec(dllexport)

int luaopen_lua_net(lua_State *L)
{
  luaL_register(L, "net", syslib);
  return 1;
}

}


2. Put the lua_net.dll together with WindsPlayer.exe, then in WindsPlayer's console, type below commands to load & test it:

Code:
require 'lua_net'
print(net.open())
print(net.close())




also see the Programming in Lua.
View user's profile Send private message
  
liverol


Joined: 29 Jun 2007
Posts: 45
Reply with quote
thanks,vincent,that's a fast way!!
for those people who using c++ this is nice,actually,what i mean is a "direct" way,like using lua native function to
load dlls.i find something useful named cinvoke(require this dll and you can load other dlls directly) to make this happen,however,i got stucked when compiled, may you can try this,it's very handy to use this for beginners.

the link is (with source):
http://www.nongnu.org/cinvoke/bindings.html
View user's profile Send private message
  
Vincent


Joined: 25 Dec 2006
Posts: 296
Reply with quote
I can compile the cinvoke successfully, you can download & try it here.
View user's profile Send private message
  
liverol


Joined: 29 Jun 2007
Posts: 45
Reply with quote
thanks,
however,i got a memory error when using the dll.

this is the lua code:(from cinvoke test)

Code:

require("cinvoke_lua")

user32 = clibrary.new("user32.dll", "stdcall")

MessageBox =

user32:get_function(Cint, "MessageBoxA", Cptr,
   Cstring, Cstring, Cint32)

MessageBox(0,

"Hello From Lua", "C/Invoke Message Box", 0);


the error occurred at line 1 when require the dll (i used lua5.14 binary for test)
did you try the dll yourself with lua code?
View user's profile Send private message
  
Vincent


Joined: 25 Dec 2006
Posts: 296
Reply with quote
I can run your codes smoothly in WindsPlayer's console. But I also have compiled another version of cinvoke_lua.dll, you can re-download it to try.
View user's profile Send private message
  
liverol


Joined: 29 Jun 2007
Posts: 45
Reply with quote
i don't know whether i missed something or what, when require the cinvoke dll the program just quit without any
message this time!

you can consider intergrating this into aw if necessary Smile
View user's profile Send private message
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
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic