Were do I put this wrapper? [Resolved]

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
THe Floating Brain
Chaos Rift Junior
Chaos Rift Junior
Posts: 284
Joined: Tue Dec 28, 2010 7:22 pm
Current Project: RTS possible Third Person shooter engine.
Favorite Gaming Platforms: PC, Wii, Xbox 360, GAME CUBE!!!!!!!!!!!!!!!!!!!!!!
Programming Language of Choice: C/C++, Python 3, C#
Location: U.S

Were do I put this wrapper? [Resolved]

Post by THe Floating Brain »

I have a class ( WSL::Member_Components::Lightning_Sprite ). The inheritance for it goes

Code: Select all

      Render_Functonal -> Render_Base <T> -> SFMLType<sfmlType> -> Lightning_Sprite
I wrote the following wrapper for it:

Code: Select all

//I open luabind before I write this.//
luabind::module( WSL::Scripting::Lua.State )[
luabind::class_<WSL::Member_Components::Rendering_System::Base::Render_Functonal>( "RenderFunctonal" )
	.def( luabind::constructor<>() )
];
luabind::module( WSL::Scripting::Lua.State )[
	luabind::class_<WSL::Member_Components::Rendering_System::Base::Render_Base<sf::Sprite>, WSL::Member_Components::Rendering_System::Base::Render_Functonal>( "RenderBase" )
	.def( luabind::constructor<>() )
];
luabind::module( WSL::Scripting::Lua.State )[
	luabind::class_<WSL::Member_Components::Rendering_System::Base::SubBase::SFMLType<sf::Sprite>, WSL::Member_Components::Rendering_System::Base::Render_Base<sf::Sprite>>( "SFMLType" )
	.def( luabind::constructor<>() )
];
//Just the rotate method because im still testing.
luabind::module( WSL::Scripting::Lua.State )[
luabind::class_<WSL::Member_Components::Lightning_Sprite, WSL::Member_Components::Rendering_System::Base::SubBase::SFMLType<sf::Sprite> >( "Lightning_Sprite" )
	.def( luabind::constructor<>() )
	.def( "Rotate", &WSL::Member_Components::Lightning_Sprite::Rotate )
];
In one of the classes in my framework I have the following code:

Code: Select all

luabind::globals( WSL::Scripting::Lua.State )[ "sprite" ] = spr[0].MakePointer( refrence[0] );
Basically it registers a global with Lua (a global Lightning_Sprite to be exact).
Now, I know the wrapper and this code is good because I got it to work before, but I had to put the wrapper in the constructor of my Positional class ( the class the code above is from ) and multiple instantiation did not like that very much. So, I have tried to put this wrapper all over the place and it just keeps being stubborn, I either get compiler errors or when I do the line above I get a unreferenced pointer and the IDE brings me either to class_registry.hpp or class_cache.hpp. PLEASE HELP!

Thanks for reading :mrgreen:

P.s I know I can sometimes have trouble getting my point across if any clarification is needed please let me know.


-----EDIT-----:
FIXED!
I was half asleep when I wrote this but I will explain what happened so anyone with this problem can know.
I was reconstruction the lua_State in every .obj file so when I made my wrapper it was being allocated to a different lua stack then the file was being run in.
Here is the solution. Make a pointer to the lua state in main or whatever then pass it into the object were the script is going to be run and do the following code:

Code: Select all

//I have a class containing my lua pointer.//
//I also have a singleton with a pointer to the container.//
luabind::globals( engine->lua->State )[ "sprite" ] = &mySprite;
"Why did we say we were going to say we were going to change the world tomorrow yesterday? Maybe you can." - Myself

ImageImage
User avatar
GroundUpEngine
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 835
Joined: Sun Nov 08, 2009 2:01 pm
Current Project: mixture
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Location: UK

Re: Were do I put this wrapper? [Resolved]

Post by GroundUpEngine »

Coding late at night has it's advantages and disadvantages lol... ;) I did the same thing with vertex buffers and kept making new ones every time but didn't notice, tested the program in college the next day and badly segfault/crashed a computer :lol:
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Were do I put this wrapper? [Resolved]

Post by Falco Girgis »

Holy JESUS, you like namespaces... It's like being at work...
Obscurity
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 16
Joined: Mon Oct 10, 2011 9:33 pm

Re: Were do I put this wrapper? [Resolved]

Post by Obscurity »

GyroVorbis wrote:Holy JESUS, you like namespaces... It's like being at work...
You forgot your name-space there. :twisted:
User avatar
EccentricDuck
Chaos Rift Junior
Chaos Rift Junior
Posts: 305
Joined: Sun Feb 21, 2010 11:18 pm
Current Project: Isometric "2.5D" Airship Game
Favorite Gaming Platforms: PS2, SNES, GBA, PC
Programming Language of Choice: C#, Python, JScript
Location: Edmonton, Alberta

Re: Were do I put this wrapper? [Resolved]

Post by EccentricDuck »

GyroVorbis wrote:Holy JESUS, you like namespaces... It's like being at work...
It's like programming in Java again.
User avatar
THe Floating Brain
Chaos Rift Junior
Chaos Rift Junior
Posts: 284
Joined: Tue Dec 28, 2010 7:22 pm
Current Project: RTS possible Third Person shooter engine.
Favorite Gaming Platforms: PC, Wii, Xbox 360, GAME CUBE!!!!!!!!!!!!!!!!!!!!!!
Programming Language of Choice: C/C++, Python 3, C#
Location: U.S

Re: Were do I put this wrapper? [Resolved]

Post by THe Floating Brain »

GyroVorbis wrote:Holy JESUS, you like namespaces...
That I do :mrgreen:
EccentricDuck wrote:It's like programming in Java again.
**Starts rapidly deleting namespaces** :lol:
"Why did we say we were going to say we were going to change the world tomorrow yesterday? Maybe you can." - Myself

ImageImage
Post Reply