Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML and Thor 1.1  (Read 2376 times)

0 Members and 1 Guest are viewing this topic.

game_maker

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
    • Email
SFML and Thor 1.1
« on: January 31, 2013, 05:12:10 pm »
Hi!

I am getting errors, and I can not find the problem.

main.cpp
#include <iostream>
#include <SFML/Graphics.hpp>
#include "GameManager.h"

using namespace std;

int main()
{
    ...
    GameManager game;

    game.Init();
    game.Load();

    while (window.isOpen())
    {
        ...
        window.clear();
        game.Draw(window);
        window.display();
    }
    return 0;
}
 

GameManager.cpp
#include "GameManager.h"
#include "Resource.h"
GameManager::GameManager(){};
GameManager::~GameManager(){};
phResource rmgr;
 Textura textura = rmgr.sprite_add("Bairros.png");
 sf::Sprite sprite(*textura);
...
void GameManager::Draw(sf::RenderWindow &window)
{
    window.draw(sprite);
}
...
 

ObjectManager.cpp
#include "ObjectManager.h"
...
 

Resource.cpp
#include "Resource.h"

phResource::phResource(){}
phResource::~phResource(){}

Textura phResource::sprite_add(std::string p)
{
TextureKey key = TextureKey::FromFile(p);
return (mgr.Acquire(key));
}
void phResource::sprite_delete(TextureKey key)
{
mgr.Release(key);
}
 

GameManager.h
#ifndef GERAL_H
#define GERAL_H
#include <string>
#include <iostream>
#include <SFML/Graphics.hpp>
#define ScreenWidth 800
#define ScreenHeight 600

class GameManager
{
    public:
        GameManager();
        ~GameManager();

    //Main functions
        void Init();
        void Load();
        void Update(sf::Event event);
        ...
        void Draw(sf::RenderWindow &window);
    //Keyboard
     ...
};

#endif
 

ObjectManager.h
#ifndef OBJECTMANAGER_H
#define OBJECTMANAGER_H
#include <string>
#include <iostream>
#include <SFML/Graphics.hpp>
...
class Objeto
{
public:
   ...
};
#endif
 

Resource.h
#ifndef PH_RESOURCE_H
#define PH_RESOURCE_H
#include<Thor/Resources.hpp>

using thor::Resources::TextureKey;
typedef thor::ResourcePtr<sf::Texture> Textura;

class phResource
{
public:
    thor::ResourceManager<sf::Texture> mgr;

    phResource();
    ~phResource();
    Textura sprite_add(std::string p);
    void sprite_delete(TextureKey key);
};

#endif
 

The errors:

obj\Release\Resource.o:Resource.cpp|| undefined reference to `_imp___ZN4thor9Resources10TextureKey8FromFileERKSsRKN2sf4RectIiEES3_'|
obj\Release\Resource.o:Resource.cpp:(.text$_ZNSt8_Rb_treeIN4thor9Resources10TextureKeyESt4pairIKS2_NS0_6detail12ResourceSlotIN2sf7TextureEEEESt10_Select1stISA_ESt4lessIS2_ESaISA_EE4findERS4_[__ZNSt8_Rb_treeIN4thor9Resources10TextureKeyESt4pairIKS2_NS0_6detail12ResourceSlotIN2sf7TextureEEEESt10_Select1stISA_ESt4lessIS2_ESaISA_EE4findERS4_]+0x1f)||undefined reference to `_imp___ZN4thor9ResourcesltERKNS0_10TextureKeyES3_'
|
obj\Release\Resource.o:Resource.cpp:(.text$_ZNSt8_Rb_treeIN4thor9Resources10TextureKeyESt4pairIKS2_NS0_6detail12ResourceSlotIN2sf7TextureEEEESt10_Select1stISA_ESt4lessIS2_ESaISA_EE10_M_insert_EPKSt18_Rb_tree_node_baseSJ_RKSA_[__ZNSt8_Rb_treeIN4thor9Resources10TextureKeyESt4pairIKS2_NS0_6detail12ResourceSlotIN2sf7TextureEEEESt10_Select1stISA_ESt4lessIS2_ESaISA_EE10_M_insert_EPKSt18_Rb_tree_node_baseSJ_RKSA_]+0x19d)||undefined reference to `_imp___ZN4thor9ResourcesltERKNS0_10TextureKeyES3_'|
obj\Release\Resource.o:Resource.cpp:(.text$_ZNSt8_Rb_treeIN4thor9Resources10TextureKeyESt4pairIKS2_NS0_6detail12ResourceSlotIN2sf7TextureEEEESt10_Select1stISA_ESt4lessIS2_ESaISA_EE16_M_insert_uniqueERKSA_[__ZNSt8_Rb_treeIN4thor9Resources10TextureKeyESt4pairIKS2_NS0_6detail12ResourceSlotIN2sf7TextureEEEESt10_Select1stISA_ESt4lessIS2_ESaISA_EE16_M_insert_uniqueERKSA_]+0x12)||undefined reference to `_imp___ZN4thor9ResourcesltERKNS0_10TextureKeyES3_'
|
obj\Release\Resource.o:Resource.cpp:(.text$_ZNSt8_Rb_treeIN4thor9Resources10TextureKeyESt4pairIKS2_NS0_6detail12ResourceSlotIN2sf7TextureEEEESt10_Select1stISA_ESt4lessIS2_ESaISA_EE16_M_insert_uniqueERKSA_[__ZNSt8_Rb_treeIN4thor9Resources10TextureKeyESt4pairIKS2_NS0_6detail12ResourceSlotIN2sf7TextureEEEESt10_Select1stISA_ESt4lessIS2_ESaISA_EE16_M_insert_uniqueERKSA_]+0x55)||undefined reference to `_imp___ZN4thor9ResourcesltERKNS0_10TextureKeyES3_'|
obj\Release\Resource.o:Resource.cpp:(.text$_ZN4thor15ResourceManagerIN2sf7TextureENS_9Resources10TextureKeyEE11AddResourceERKS4_[__ZN4thor15ResourceManagerIN2sf7TextureENS_9Resources10TextureKeyEE11AddResourceERKS4_]+0x62)||undefined reference to `_imp___ZNK4thor9Resources10TextureKey4LoadEv'
|
||=== Build finished: 6 errors, 0 warnings (0 minutes, 5 seconds) ===|
 

I am using: Windows 7, SFML 2.0, Code::Blocks (MinGW), Thor 1.1.

Thanks in advance.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: SFML and Thor 1.1
« Reply #1 on: January 31, 2013, 05:19:34 pm »
Thor 1.1 is not compatible with the newest SFML. You should use the latest Git revision of Thor.

The Resources API is slightly different meanwhile, you can work with std::shared_ptr for example.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

game_maker

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
    • Email
Re: SFML and Thor 1.1
« Reply #2 on: January 31, 2013, 05:22:05 pm »
shared_ptr belongs to C++11, right?

Thanks Nexus.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: SFML and Thor 1.1
« Reply #3 on: January 31, 2013, 05:24:23 pm »
Yes. It has already been available in TR1 and Boost, but for Thor 2, you need C++11 anyway.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

game_maker

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
    • Email
Re: SFML and Thor 1.1
« Reply #4 on: January 31, 2013, 05:40:01 pm »
I downloaded the GIT version. Now it works perfectly.

Thor is amazing!

Thanks!