Texture loading problem

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

Texture loading problem

Postby barney » Mon Jul 13, 2009 4:00 pm

Hi, I'm developing a game using hge magic particles, it's an awesome program, and everything worked till 2 days ago fine.
But when I tried to implement the effect to my game, it crashed. I bug-checked it and it seems there is a problem with texture-loading function.
Strangely, that doesn't happen, when I compile the HGE example with the SDK.
Here is my code
Code: Select all
if(hge->System_Initiate())
{
MP=new MP_Manager();
   MP->Initialization(MAGIC_INTERPOLATION_DEFAULT, MAGIC_NOLOOP, MAGIC_CHANGE_EMITTER_AND_PARTICLES , 0);
   MP->LoadEmittersFromFile("data/firefings.ptc");
   MP->LoadTextures("data/textures",1024,1024,1,0.1f);
   MP->CloseFiles();
   MP->Stop();

As I said, the ptc file loads right but the texture folder doesn't. What should I do before loading the textures?
Thank you.
barney
 
Posts: 11
Joined: Mon Jul 13, 2009 3:55 pm

Re: Texture loading problem

Postby trinitrone100 » Mon Jul 13, 2009 11:37 pm

You need to set a full path for textures and problem will be fixed.
The error in this string: texture_from=hge->Texture_Load(path.c_str(),0,false);
We do not know why HGE do not loads textures from relative path. We think what it is the bug of HGE and we will try to check it tomorrow.
trinitrone100
Administrator
Administrator
 
Posts: 16
Joined: Mon Apr 13, 2009 3:20 pm

Re: Texture loading problem

Postby barney » Tue Jul 14, 2009 9:54 am

Actually I tried that too, but it didn't solve the problem. As I said, I can load textures in the HGE wrapper example with a relative path, there is no problem there, but when I implement the same code to my game, there is no result, so, since magic library isn't open source I need to know what happens when you try to load a texture( in Magic->OpenFile). This way I can find something in my game that blocks proper texture loading. Thanks for your interest, and great editor by the way :) !
barney
 
Posts: 11
Joined: Mon Jul 13, 2009 3:55 pm

Re: Texture loading problem

Postby trinitrone100 » Tue Jul 14, 2009 11:21 am

There is the GetCurrentDirectory function in Windows, which returns the current folder. When your loads a debug-project, the current folder in Windows placed in "debug/../" and in "debug" for HGE. Try to see the GetCurrentDirectory function.
trinitrone100
Administrator
Administrator
 
Posts: 16
Joined: Mon Apr 13, 2009 3:20 pm

Re: Texture loading problem

Postby Odin_KG » Tue Jul 14, 2009 11:47 am

I need to know what happens when you try to load a texture

Magic API does not load the textures.

The textures are external and internal. The internal textures are stored in ptc-files. But both type of textures you load via HGE.

If you wish you can send me the source code of your project (support@astralax.com).

Thanks for your interest, and great editor by the way

Thank you!
User avatar
Odin_KG
Administrator
Administrator
 
Posts: 249
Joined: Sat May 09, 2009 10:53 pm

Re: Texture loading problem

Postby barney » Tue Jul 14, 2009 11:50 am

Sorry, I tried it now too, but it didn't help neither :?

What do you think that can cause such a problem, working on one code, and not working on another?

Hmm, so how can i use internal textures, without using MP->LoadTextures ?
barney
 
Posts: 11
Joined: Mon Jul 13, 2009 3:55 pm

Re: Texture loading problem

Postby Odin_KG » Tue Jul 14, 2009 12:02 pm

What do you think that can cause such a problem, working on one code, and not working on another?

I can't answer without source code.

how can i use internal textures, without using MP->LoadTextures ?

LoadTextures is needed or you can rewrite this function.

Code: Select all
void MP_Atlas_WRAP::LoadFrame(MAGIC_TEXTURE* magic_texture, const char* texture_folder)
{
   HTEXTURE texture_from;
   if (magic_texture->data)
                // INTERNAL TEXTURE 
      texture_from=hge->Texture_Load(magic_texture->data,magic_texture->length,false);
   else
   {
                // EXTERNAL TEXTURE
      std::string path=texture_folder;
      path+=magic_texture->file;
      char* path2=hge->Resource_MakePath(path.c_str());
      texture_from=hge->Texture_Load(path2,0,false);
   }
...
...
...
...
User avatar
Odin_KG
Administrator
Administrator
 
Posts: 249
Joined: Sat May 09, 2009 10:53 pm

Re: Texture loading problem

Postby barney » Tue Jul 14, 2009 12:13 pm

Hey look what I've just found!
I've bug traced the program and it went till MP_Manager::AddFrameToAtlas and there it went till if (!m_atlas[index])
{
m_atlas[index]=new MP_Atlas_WRAP(magic_texture->texture_width,magic_texture->texture_height);
}

Then I thought maybe the data passed could be wrong and I was right. I checked the path of the magic_texture parameter and it is:
C/Program Files/Magic Particles/Sample/1.png
A complete wrong path my game was located in E. I think that was the problem and I'm trying to find why it was passed wrong.
Thanks for your help!
barney
 
Posts: 11
Joined: Mon Jul 13, 2009 3:55 pm

Re: Texture loading problem

Postby barney » Tue Jul 14, 2009 12:40 pm

That's strange, because i just loaded another ptc file and it used its first png 26.png and it's path follows as:

C/Program Files/Magic Particles (Dev) Free/Textures/26.png

Why doesn't it searches it in the data/texture folder?
barney
 
Posts: 11
Joined: Mon Jul 13, 2009 3:55 pm

Re: Texture loading problem

Postby Odin_KG » Tue Jul 14, 2009 12:55 pm

Variable "magic_texture->path" is path to texture when it was loaded in editor. Variable "magic_texture->path" is not important.

Variable "magic_texture->file" is file name for loading of texture. This variable addes to "data/textures".
User avatar
Odin_KG
Administrator
Administrator
 
Posts: 249
Joined: Sat May 09, 2009 10:53 pm

Next

Return to Magic Particles

Who is online

Users browsing this forum: No registered users and 7 guests

cron