FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sprite & Texture loading problem

 
Post new topic   Reply to topic     Forum Index -> ArcLib
View previous topic :: View next topic  
Author Message
zane.sims



Joined: 07 Aug 2007
Posts: 40

PostPosted: Sun Nov 30, 2008 3:19 pm    Post subject: Sprite & Texture loading problem Reply with quote

Hello,

I have been trying to get as much information about how features of arc work by looking over the source code, but I have ran into a problem. If what I am assuming is incorrect, please let me know. I understand Texture to ignore attempts to re-load the same file into memory. I have a large 2 dimensional array of sprites (arclib-sprite) and was filling them with the same texture just to have a starting point...sorta like a giant tile map where all the tiles use the same texture. The file used is a 32x32 pixel png image. I figure that it will load the file one time and then coast on by the others really quick. According to the arc.log file, it does seem to be loading the texture only once, but it is taking forever to load. Something like 30+ seconds. When I look at my task manager, it indicates that my memory has now an additional 146-ish MB extra taken up.

A simplified version of the problem is below:

Code:
module test;

import arc.window;
import arc_sprite.sprite;
import tango.io.FileConduit;
      
int main()
{
   ushort i = 0;
   ushort j = 0;

    arc.window.open("Game", 800, 600, true);

    Sprite tiles[][];

   tiles.length = 400;
                  
   for(i=0;i<400;++i)
   {
      tiles[i].length = 300;
   
      for(j=0;j<300;++j)
      {
         tiles[i][j] = new Sprite(COLLISION_TYPE.BOX);
         tiles[i][j].addFrame("img.png", "static", -1, null);
      }
   }
   
   log("done loading");

    arc.window.close();

    return 0;
}
      
void log(char[] msg)
{
   FileConduit file    = new FileConduit("log.txt", FileConduit.WriteAppending);
   file.output.write(msg);
   file.close();
}


After commenting out the line that calls addFrame, it takes about 2 seconds to complete. Why is this taking so long? If this is by my error or misuse, then please feel free to correct me.

Thanks for your time and patience,
Zane
_________________
わたしがプログラマだよ!
Back to top
View user's profile Send private message
deadimp



Joined: 22 Oct 2008
Posts: 28

PostPosted: Sun Dec 28, 2008 5:03 pm    Post subject: Reply with quote

Look at the implementation of addFrame to see how it handles loading the Texture... If it is, in fact, using the static constructor to load the texture then something strange is afoot in the core.
Otherwise, it's something with arc_sprite.

I'll look at it soon, but not at this moment.
_________________
deadimp.org
> MegaMan X Crossfire - MegaMan X fan game

Beginning D; Basic experience in PHP, C++, Java, C#, MySQL, HTML, CSS, JavaScript, VB
Back to top
View user's profile Send private message
clayasaurus



Joined: 21 May 2004
Posts: 857

PostPosted: Fri Jan 16, 2009 2:19 pm    Post subject: Reply with quote

Can you send me the image file, too, so I can try to reproduce the error?
clayasaurus at gmail dot com.

Thanks
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> ArcLib All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group