Using MP with an existing library

All information about Magic Particles: news, question, comments, etc.

Using MP with an existing library

Postby pecco123 » Wed Feb 08, 2012 8:44 pm

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?
pecco123
 
Posts: 1
Joined: Wed Feb 08, 2012 8:38 pm

Re: Using MP with an existing library

Postby Odin_KG » Wed Feb 08, 2012 10:07 pm

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.
User avatar
Odin_KG
Administrator
Administrator
 
Posts: 255
Joined: Sat May 09, 2009 10:53 pm

Re: Using MP with an existing library

Postby Rorakin » Fri Nov 02, 2012 12:53 am

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;
Rorakin
 
Posts: 4
Joined: Fri Nov 02, 2012 12:43 am

Re: Using MP with an existing library

Postby Rorakin » Fri Nov 02, 2012 2:07 am

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?
Rorakin
 
Posts: 4
Joined: Fri Nov 02, 2012 12:43 am

Re: Using MP with an existing library

Postby Odin_KG » Fri Nov 02, 2012 11:49 am

Did you change GetPathToPTC()? Perhaps GetPathToPTC() returns NULL.
User avatar
Odin_KG
Administrator
Administrator
 
Posts: 255
Joined: Sat May 09, 2009 10:53 pm

Re: Using MP with an existing library

Postby Rorakin » Fri Nov 02, 2012 11:51 pm

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
Rorakin
 
Posts: 4
Joined: Fri Nov 02, 2012 12:43 am

Re: Using MP with an existing library

Postby Rorakin » Sat Nov 03, 2012 3:53 am

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.
Rorakin
 
Posts: 4
Joined: Fri Nov 02, 2012 12:43 am

Re: Using MP with an existing library

Postby Odin_KG » Sat Nov 03, 2012 10:43 am

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.
User avatar
Odin_KG
Administrator
Administrator
 
Posts: 255
Joined: Sat May 09, 2009 10:53 pm


Return to Magic Particles

Who is online

Users browsing this forum: No registered users and 6 guests

cron