Page 1 of 1
Using MP with an existing library
Posted:
Wed Feb 08, 2012 8:44 pm
by pecco123
I'm currently using another library to create an OpenGl windows.
Simply by including "Setup::SetupScreen( 800, 600, WINDOWED );", it setups the whole OpenGl environment.
My question is that is it possible or how to edit the OpenGl wrapper so that it works with this already existing windows without creating a new?
Re: Using MP with an existing library
Posted:
Wed Feb 08, 2012 10:07 pm
by Odin_KG
Wrapper is example only. You may delete the initialization of OpenGL if you wish. But you should copy the initialization of Magic Particles to your engine.
Also you may integrate API in your engine without wrapper. API is described in API.chm.
Re: Using MP with an existing library
Posted:
Fri Nov 02, 2012 12:53 am
by Rorakin
Hello,
I'm trying to integrate 2d version of this to a simple 2.5d game engine (IndieLib). My program crashes when I try to set the state of the current emitter. Can anyone tell if I'm making a simple mistake or if I need to modify any of the files I'm using from core, and wrapper/dx ?
Here is what the beginning of my main looks like:
CIndieLib *mI = CIndieLib::Instance();
if (!mI->Init ()) return 0;
GUI *GUI = GUI::Instance();
GUI->Init();
MP_Device_WRAP device(mI->Window->GetWidth(), mI->Window->GetHeight(), mI->Window->GetWnd());
device.Create();
MP_Manager& MP=MP_Manager::GetInstance();
MP_Platform* platform = new MP_Platform_WINDOWS;
MP.Initialization(platform, MAGIC_INTERPOLATION_ENABLE, MAGIC_NOLOOP, MAGIC_CHANGE_EMITTER_DEFAULT, mI->Window->GetWidth(), mI->Window->GetHeight(), 1, 1.f, 0.1f, true);
//MP.LoadAllEmitters();
MP.LoadEmittersFromFile("matrix.ptc");
MP.CloseFiles();
MP.Stop();
HM_EMITTER cur=0;
MP_Emitter* emitter;
emitter = MP.GetEmitter(cur);
emitter->SetState(MAGIC_STATE_UPDATE);
//float cx=((float)mI->Window->GetWidth())/2.f;
//float cy=((float)mI->Window->GetHeight())/2.f;
//HM_EMITTER hmEmitter=MP.GetFirstEmitter();
//while (hmEmitter)
//{
// emitter=MP.GetEmitter(hmEmitter);
// MP_POSITION pos;
Re: Using MP with an existing library
Posted:
Fri Nov 02, 2012 2:07 am
by Rorakin
Ok, I've narrowed the source of the issue by putting breakpoints in the dx2d example (which works for me) and my project that is trying to integrate.
The issue is string related. After these 2 statements execute
std::string ptc_file=GetPathToPTC();
ptc_file+=file;
ptc_file: "0Xjt&" std::basic_string<char,std::char_traits<char>,std::allocator<char> >
The ptc_file is a bunch of strange characters but it should be a file path. Still not sure how I should resolve this though, I have #include "string" would that be causing this?
Re: Using MP with an existing library
Posted:
Fri Nov 02, 2012 11:49 am
by Odin_KG
Did you change GetPathToPTC()? Perhaps GetPathToPTC() returns NULL.
Re: Using MP with an existing library
Posted:
Fri Nov 02, 2012 11:51 pm
by Rorakin
Yes, for some reason ptc_path=wchar_to_utf8(path); is not working in my project, but it is in the dx2d project. I've tried setting making sure all the project settings are the same, that didn't work. Now I'm trying to just figure out how to successfully convert wchar_t * to std::string . I've looked up a solution that uses wcstombs(), but that is also failing me... lol
EDIT:
Ok, nevermind it is not a problem with wchar_to_utf8(path)
std::string asdf;
asdf=wchar_to_utf8(path);
ptc_path=wchar_to_utf8(path);
After these 3 statements asdf correctly populates the path, but ptc_path is null, so maybe because ptc_path is a protected string in mp.h?
EDIT2:
Ok, I figured out the issue. Turns out ptc_path wasn't returning null, I just thought it was because when debugging in release mode, protected variables aren't evaluate-able in the debugger. But I was debugging in debug mode in the other project. So the path was fine after all. The underlying issue was that I put matrix.ptc and textures in the wrong folders... haha
Re: Using MP with an existing library
Posted:
Sat Nov 03, 2012 3:53 am
by Rorakin
Ok, so what functions (in mp_wrap.cpp?) do I need to change in order to render the particles on the highest layer? My 2d game engine seems to render the layer always above the particle layer.
Re: Using MP with an existing library
Posted:
Sat Nov 03, 2012 10:43 am
by Odin_KG
The wrapper does not work with layers. The wrapper is example only. But you can modify the wrapper as you wish. You need to add the property layer in MP_Emitter and unite the rendering of the emitters with your engine.