Okay, this has had me stumped for a good hour or two. And I can't seem to figure out why this is happening. I'm working on a game currently, and it involves vectors that hold sprites and things like that. Although, for some reason, the sprites are drawn to the window, and they're just white. They're the correct size, just no color. Obviously I didn't expect anyone to look at my whole game's source code and pick out a problem, so I made a mini program with fake classes that sort of simulate what happens in my game.
//TestClass.h
#pragma once
#include <SFML/Graphics.hpp>
#include "TestClassTwo.h"
class TestClass
{
public:
void Foo();
std::vector <sf::Sprite> Sprites;
private:
};
void TestClass::Foo()
{
TestClass2 T2;
T2.Img.LoadFromFile("SpriteSheet.png");
T2.Spr.SetImage(T2.Img);
Sprites.push_back(T2.Spr);
}
//TestClassTwo.h
#pragma once
#include <SFML/Graphics.hpp>
class TestClass2
{
public:
sf::Sprite Spr;
sf::Image Img;
private:
};
//main.cpp
#include "TestClass.h"
#include "TestClassTwo.h"
int main()
{
sf::RenderWindow Win;
Win.Create(sf::VideoMode(1000,800,32),"Test");
sf::Event Event;
TestClass T1;
T1.Foo();
while(Win.IsOpened())
{
while(Win.GetEvent(Event))
{
if(Event.Type == Event.Closed)
{
Win.Close();
}
}
Win.Clear(sf::Color(0,0,0));
Win.Draw(T1.Sprites[0]);
Win.Display();
}
}
As I said, these classes are short parts of the game that are most definitely causing the problems. I just can't figure out why. Huge thanks in advanced.