Hi, I'm having a problem (of course...).
I load a few different surfaces, for example... a background and foreground. In between the two I want to paint a number of objects, all of which are stored in a vector container.
It seems like they are being stored in the vector just fine, but the surfaces never load. I've done a few tests, like the width of the surface etc., and it returns less than 1 every time.
Other surfaces (background/foreground) work fine. The vector stored surfaces do not.
Anybody have a clue why this would be? Here is a largely trimmed down version of the code. both classes. I just loop through the vector and check each .graphic and/or blit it.
Thanks, hope you guys can help!
I load a few different surfaces, for example... a background and foreground. In between the two I want to paint a number of objects, all of which are stored in a vector container.
It seems like they are being stored in the vector just fine, but the surfaces never load. I've done a few tests, like the width of the surface etc., and it returns less than 1 every time.
Other surfaces (background/foreground) work fine. The vector stored surfaces do not.
Anybody have a clue why this would be? Here is a largely trimmed down version of the code. both classes. I just loop through the vector and check each .graphic and/or blit it.
Thanks, hope you guys can help!
- Code:
class Object
{
public:
CGapiSurface graphic;
double xPos;
double yPos;
int objectType;
Object()
{
xPos = 160;
yPos = 120;
};
void loadGraphic(int objType, const TCHAR* pImageFile)
{
objectType = objType;
graphic.CreateSurface(GDSURFACE_SYSTEMMEMORY, pImageFile);
COLORREF controlPixel;
graphic.GetPixel(0, 0, &controlPixel);
graphic.SetColorKey(controlPixel);
};
~Object()
{
graphic.FreeSurface();
};
};
class ObjectManager
{
public:
int howManyObjects;
int maxObjs;
std::vector<Object> objectList;
ObjectManager()
{
howManyObjects = 0;
maxObjs = 2;
for (int i=0; i<maxObjs; i++)
{
spawnObj(P_TYPE_ONE, TEXT("\\graphicTemplate.bmp"));
}
};
int spawnObj(int objType, const TCHAR* pImageFile)
{
Object newObj;
newObj.loadGraphic(objType, pImageFile);
howManyObjects += 1;
objectList.push_back(newObj);
return howManyObjects;
return 0;
};
~ObjectManager(){};
};