Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / LuaBind and DarkGDK issue. Please help

Author
Message
Justin7674
7
Years of Service
User Offline
Joined: 28th Jan 2012
Location:
Posted: 28th Jan 2012 07:59
I have been working very hard to get LuaBind to work with DarkGDK
I noticed LuaBind is console and DarkGDK is windowed. I have had many errors and here is my attempt that I made.


I have all the libraries defined correctly and recieve this error

Can someone please help me I have been trying for days and this is the closest I have gotten.
Mr Bigglesworth
11
Years of Service
User Offline
Joined: 4th Mar 2008
Location:
Posted: 28th Jan 2012 09:31
It looks like you aren't linking something. Have you tried just using straight lua without a wrapper, I found it to be just as easy and doesn't involve some of these hassles.
Justin7674
7
Years of Service
User Offline
Joined: 28th Jan 2012
Location:
Posted: 29th Jan 2012 00:58
I have everything linked as these work seperately. It is an error telling me that the functions where not found or are not accessible in this mode. But, I have no clue how to make it where I can use c++ functions with lua is there any help you can give me there?
Mr Bigglesworth
11
Years of Service
User Offline
Joined: 4th Mar 2008
Location:
Posted: 29th Jan 2012 09:35 Edited at: 29th Jan 2012 19:34
Quote: "I have no clue how to make it where I can use c++ functions with lua is there any help you can give me there?"


So, to bind a DarkGDK function to Lua you need to first make a function to "tell" lua the commands in the function you want to bind. I am going to use "dbSetDisplayMode(iWidth, iHeight, iDepth)". First off make a static int function, and for its parameters put "lua_State *L". In that function you will have to make a variable(s) that contain the data you wish to pass to the DarkGDK function (dbSetDisplayMode in this case) and make them equal to "lua_tonumber(lua_State, parameterNumber)" so for the integer iWidth you would make it equal to "lua_tonumber(L, 1)", L is the luaState and the number 1 is specifing whether it is the first, second, third, ... parameter in "dbSetDisplayMode". Here is the function:



Then you use a function to actually bind the function to lua, it is "lua_register(lua_State, functionNameInLua, Function);" in this case it would look like:
"lua_register(L, "SetDisplayMode", lua_func_dgdk_setdisplaymode);".
That should make a function, and to use it in a lua script you would type "SetDisplayMode(640, 40, 32)".

I attached a class I made that handles initilization/destruction and handling lua, as well as a couple of functions that have been bound to lua (the class is most useful for using the lua_State member). It also has an "Example.cpp" containing an example of how to use the class and 2 lua files it runs that set the display mode and sync the screen.

Attachments

Login to view attachments
Justin7674
7
Years of Service
User Offline
Joined: 28th Jan 2012
Location:
Posted: 3rd Feb 2012 21:35
Oh, Wow, You made it look so easy. You explained it very well I have never had someone online as nice as to explain what and how to do something. I understand now and I thought that I was going to have to go through so much work just to bind one function. Thank you so much and I wish you the best of luck in whatever you are out to do!
Mr Bigglesworth
11
Years of Service
User Offline
Joined: 4th Mar 2008
Location:
Posted: 5th Feb 2012 06:34
Thanks

Login to post a reply

Server time is: 2019-12-13 20:43:12
Your offset time is: 2019-12-13 20:43:12