Page 1 of 2

Texture loading problem

PostPosted: Mon Jul 13, 2009 4:00 pm
by barney
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.

Re: Texture loading problem

PostPosted: Mon Jul 13, 2009 11:37 pm
by trinitrone100
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.

Re: Texture loading problem

PostPosted: Tue Jul 14, 2009 9:54 am
by barney
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 :) !

Re: Texture loading problem

PostPosted: Tue Jul 14, 2009 11:21 am
by trinitrone100
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.

Re: Texture loading problem

PostPosted: Tue Jul 14, 2009 11:47 am
by Odin_KG
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!

Re: Texture loading problem

PostPosted: Tue Jul 14, 2009 11:50 am
by barney
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 ?

Re: Texture loading problem

PostPosted: Tue Jul 14, 2009 12:02 pm
by Odin_KG
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);
   }
...
...
...
...

Re: Texture loading problem

PostPosted: Tue Jul 14, 2009 12:13 pm
by barney
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!

Re: Texture loading problem

PostPosted: Tue Jul 14, 2009 12:40 pm
by barney
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?

Re: Texture loading problem

PostPosted: Tue Jul 14, 2009 12:55 pm
by Odin_KG
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".