//Main.cpp
#include "stdafx.h"
#include <SFML\System.hpp>
#include <SFML\Window.hpp>
#include <SFML\Graphics.hpp>
#include <string>
#include "Layer.h"
#include <iostream>
int stagew = 1280;
int stageh = 720;
int stagebpp = 32;
int _tmain(int argc, _TCHAR* argv[])
{
Layer lay;
sf::Sprite * spr;
sf::Image ima;
if (ima.LoadFromFile("graphics/tiles.bmp")==true)
std::cout << "good";
spr->SetImage(ima);
lay.push_back(spr);
sf::RenderWindow App(sf::VideoMode(stagew,stageh,stagebpp), "x");
while(App.IsOpened())
{
App.Clear();
App.Draw(lay);// this nor App.Draw((*spr)); will work. they both crash.
App.Display();
}
return 0;
}
why is this crashing?? it post GOOD
here is my layer code
#pragma once
#include <vector>
#include <SFML/Graphics.hpp>
typedef std::vector<sf::Drawable*> FrameSet;
typedef FrameSet::const_iterator itFrame;
class Layer : public sf::Drawable, public FrameSet {
public :
Layer( const sf::Vector2f& Position = sf::Vector2f(0, 0),
const sf::Vector2f& Scale = sf::Vector2f(1, 1),
float Rotation = 0.f,
const sf::Color& Col = sf::Color(255, 255, 255, 255));
virtual ~Layer();
virtual void Render(sf::RenderTarget& Target) const;
};
#include "StdAfx.h"
#include "Layer.h"
#include <iostream>
Layer::Layer( const sf::Vector2f& Position,
const sf::Vector2f& Scale,
float Rotation,
const sf::Color& Col) :
sf::Drawable(Position,Scale,Rotation,Col)
{
};
Layer::~Layer(){
};
void Layer::Render(sf::RenderTarget& Target) const {
for( itFrame i = begin() ;i!=end();i++)
Target.Draw(*(*i));
};