I'm using the latest release(2.0.11) and AppGameKit is not releasing memory.
I'm loading an image that is 640x960 which takes up 4mb of video memory; I see the memory go up exactly 4 mb using the task manager but when I release the memory nothing happens.
I'm using Visual Studio 2008.
So what am I not understanding????
Here is code wrapping the AppGameKit commands in a class:
// Includes
#include "template.h"
#include <string.h>
// Namespace
using namespace AGK;
app App;
unsigned int Image; //default image
unsigned int sprite; //sprite for default image
float xpos,ypos;
int _index;
class CSimpleSpriteAndImage
{
private:
unsigned int Image; //default image
unsigned int sprite; //sprite for default image
float xpos,ypos;
int _index;
public:
CSimpleSpriteAndImage(const char *img, int index )
{
Image = agk::LoadImage(img);
sprite = agk::CreateSprite(Image);
agk::SetSpriteSize(sprite,100.00f,-1.00f);
agk::SetSpritePosition(sprite, 0.00f, 0.0f);
agk::SetSpriteDepth(sprite,2);
_index = index;
}
~CSimpleSpriteAndImage()
{
agk::DeleteSprite(sprite);
agk::DeleteImage(Image);
}
void SetSize(float scaleX, float scaleY)
{
agk::SetSpriteSize(sprite, scaleX, scaleY);
return;
}
void SetPositionOfSprite(float x, float y)
{
agk::SetSpritePosition(sprite,x,y);
return;
}
void RepositionSprite()
{
agk::SetSpritePosition(sprite, -400.00f, 0.0f);
return;
}
void SetSpriteDepth(int depth)
{
agk::SetSpriteDepth(sprite,depth);
return;
}
void SetColorOfSprite(int r, int g, int b)
{
agk::SetSpriteColor(sprite,r,g,b,255);
return;
}
unsigned int GetSprite()
{
return sprite;
}
int ReturnIndex()
{
return _index;
}
void SetAlphaOfSprite(int alpha)
{
agk::SetSpriteColorAlpha(sprite,alpha);
return;
}
};
CSimpleSpriteAndImage *img;
// Begin app, called once at the start
void app::Begin( void )
{
}
// Main loop, called every frame
void app::Loop ( void )
{
if(agk::GetRawKeyReleased(67)) //key C
{
img = new CSimpleSpriteAndImage("pics/o.jpg",1);
}
if(agk::GetRawKeyReleased(68)) //key D
{
delete img; img=NULL;
}
agk::Sync();
}
// Called when the app ends
void app::End ( void )
{
}
Here is the code without wrapping with the same results:
// Includes
#include "template.h"
#include <string.h>
// Namespace
using namespace AGK;
app App;
unsigned int Image; //default image
unsigned int sprite; //sprite for default image
float xpos,ypos;
int _index;
// Begin app, called once at the start
void app::Begin( void )
{
}
// Main loop, called every frame
void app::Loop ( void )
{
if(agk::GetRawKeyReleased(67)) //key C
{
Image = agk::LoadImage("pics/o.jpg");
sprite = agk::CreateSprite(Image);
agk::SetSpriteSize(sprite,100.00f,-1.00f);
agk::SetSpritePosition(sprite, 0.00f, 0.0f);
agk::SetSpriteDepth(sprite,2);
}
if(agk::GetRawKeyReleased(68)) //key D
{
agk::DeleteSprite(sprite);
agk::DeleteImage(Image);
}
agk::Sync();
}
// Called when the app ends
void app::End ( void )
{
}
Prove Your Worthiness
KG2Entertainment.com