1
Graphics / R6025 Error, pure virtual function call
« on: September 04, 2011, 09:09:01 pm »
Thanks guys, I am going to read into this stuff and thanks for helping again
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
sf::Image sub;
sub.LoadFromFile("Assets//submarine.png");
sub.CreateMaskFromColor(sf::Color::White);
player plyr1 = player(sf::Vector2<float>(10,10), sf::Sprite(sub), &world.GetWindow()->GetInput(), world.GetWindow());
world.entityList.push_back(&plyr1);
void BaseEntity::Draw(float frameTime)
{
renderWindow->Draw(sprite);
}
#pragma once
#include <SFML\Graphics.hpp>
class BaseEntity
{
protected:
sf::RenderWindow * renderWindow;
public:
sf::Vector2<float> position;
sf::Sprite sprite;
BaseEntity();
BaseEntity(sf::Vector2<float>, sf::Sprite);
virtual void Draw(float);
virtual void Think(float);
};
#pragma once
#include <SFML\Graphics.hpp>
#include "BaseEntity.h"
class player : public BaseEntity
{
const sf::Input * input;
public:
// Physics variables :
sf::Vector2<float> velocity;
sf::Vector2<float> acceleration;
sf::Vector2<float> friction;
sf::Vector2<float> maxAccelerationSpeed;
player(sf::Vector2<float>, sf::Sprite, const sf::Input*, sf::RenderWindow *);
void Draw(float);
void Think(float);
};
#include "player.h"
player::player(sf::Vector2<float> pos, sf::Sprite spr, const sf::Input * inp, sf::RenderWindow * window) : BaseEntity()
{
//Physics :
velocity = sf::Vector2<float>(0,0);
acceleration = sf::Vector2<float>(5,5);
friction = sf::Vector2<float>(0.97f,0.97f);
maxAccelerationSpeed = sf::Vector2<float>(25,25);
position = pos;
sprite = spr;
input = inp;
renderWindow = window;
}
void player::Draw(float frameTime)
{
BaseEntity::Draw(frameTime);
}
renderWindow->Draw(sprite);
c:\users\quincy\sfml-2.0\laurentgomila-sfml-79d5217\include\sfml\window\window.hpp(500): error C2248: 'sf::NonCopyable::NonCopyable' : cannot access private member declared in class 'sf::NonCopyable'
1> c:\users\quincy\sfml-2.0\laurentgomila-sfml-79d5217\include\sfml\system\noncopyable.hpp(67) : see declaration of 'sf::NonCopyable::NonCopyable'
1> c:\users\quincy\sfml-2.0\laurentgomila-sfml-79d5217\include\sfml\system\noncopyable.hpp(42) : see declaration of 'sf::NonCopyable'
1> This diagnostic occurred in the compiler generated function 'sf::Window::Window(const sf::Window &)'
1>c:\users\quincy\sfml-2.0\laurentgomila-sfml-79d5217\include\sfml\graphics\rendertarget.hpp(304): error C2248: 'sf::NonCopyable::NonCopyable' : cannot access private member declared in class 'sf::NonCopyable'
1> c:\users\quincy\sfml-2.0\laurentgomila-sfml-79d5217\include\sfml\system\noncopyable.hpp(67) : see declaration of 'sf::NonCopyable::NonCopyable'
1> c:\users\quincy\sfml-2.0\laurentgomila-sfml-79d5217\include\sfml\system\noncopyable.hpp(42) : see declaration of 'sf::NonCopyable'
1> This diagnostic occurred in the compiler generated function 'sf::RenderTarget::RenderTarget(const sf::RenderTarget &)'
//Some includes
int main()
{
World world = World(sf::VideoMode(1280, 1024, 32), "Sfml is finaly set up properly !");
while(world.GetWindow().IsOpened())
{
double frameTime = world.GetWindow().GetFrameTime() / 1000;
std::cout << "Frametime in sec : " << frameTime;
world.Think(frameTime);
world.Draw(frameTime);
}
return EXIT_SUCCESS;
}
//.h
#pragma once
#include <SFML\Graphics.hpp>
#include <string>
class World
{
private:
sf::RenderWindow RenderWindow;
public:
sf::RenderWindow &GetWindow() {return RenderWindow;}
void Think(double);
void Draw(double);
World(sf::VideoMode, std::string);
~World();
};
//.cpp
#include "World.h"
World::World(sf::VideoMode videoMode, std::string title)
{
RenderWindow.Create(videoMode, title);
}
World::~World()
{
}
void World::Draw(double frameTime)
{
RenderWindow.Clear();
//Do drawing in between
RenderWindow.Display();
}
void World::Think(double frameTime)
{
sf::Event event;
while (RenderWindow.PollEvent(event))
{
// Close window : exit
if (event.Type == sf::Event::Closed)
RenderWindow.Close();
}
}
sf::RenderWindow &GetWindow() {return RenderWindow;}
while(world.GetWindow().IsOpened())
foreach (Shader shader in globalShaders)
{
Program.renderImage.Draw(new Sprite(Program.renderImage.Image), shader);
}
void main()
{
gl_FragColor = gl_Color;
}
public void DrawSprite(Sprite sprite, Vector2 position, Rectangle subRectangle)
{
if (viewPort.Intersects(new Rectangle(position.X - subRectangle.X, position.Y - subRectangle.Y, sprite.Width, sprite.Height)))
{
sprite.Position = position - new Vector2(viewPort.X, viewPort.Y);
sprite.SubRect = new IntRect((int)subRectangle.X, (int)subRectangle.Y, (int)(subRectangle.X + subRectangle.Width), (int)(subRectangle.Y + subRectangle.Height));
Program.renderImage.Draw(sprite);
}
}