Skip to content

Commit

Permalink
Beginning to create a cros platform graphics API
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeSilva committed Jun 20, 2016
1 parent 715e2e1 commit 8424504
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -67,7 +67,7 @@ include_directories("source/")
include_directories("source-SFML/")

file(GLOB_RECURSE Foo_SOURCES "source/*.cpp" "source-SFML/*.cpp")
file(GLOB_RECURSE Foo_HEADERS "source/*.hpp" "source-SFML/*.cpp")
file(GLOB_RECURSE Foo_HEADERS "source/*.hpp" "source-SFML/*.hpp")

set (Foo_INCLUDE_DIRS "")
foreach (_headerFile ${Foo_HEADERS})
Expand Down
File renamed without changes.
File renamed without changes
7 changes: 7 additions & 0 deletions assets/gfx/mobs.grit
@@ -0,0 +1,7 @@
#An 8 bit sprite
-gB8
#A tiled image
-gt
-th 16
#The Transperant colour of 0xFF00FF
-gT FF00FF
Binary file added assets/gfx/mobs.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 9 additions & 9 deletions source-SFML/TextureManager.cpp → source-SFML/SFMLGraphics.cpp
Expand Up @@ -17,28 +17,28 @@

#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include "TextureManager.hpp"
#include "SFMLGraphics.hpp"

TextureManager::TextureManager(const sf::Vector2f &SIZE) : rectangle({})
SFMLGraphics::SFMLGraphics(const sf::Vector2f &SIZE) : rectangle({})
{
resize(SIZE);
}

TextureManager::TextureManager(const TextureManager& orig) { }
SFMLGraphics::SFMLGraphics(const SFMLGraphics& orig) { }

TextureManager::~TextureManager() { }
SFMLGraphics::~SFMLGraphics() { }

bool TextureManager::loadTexture()
bool SFMLGraphics::loadTexture()
{
if (!image.loadFromFile("gfx/texture.png"))
if (!image.loadFromFile("gfx/blocks.png"))
return false;
image.createMaskFromColor(sf::Color(255, 0, 255));
texture.loadFromImage(image);
texture.setSmooth(false);
return true;
}

void TextureManager::resize(const sf::Vector2f &SIZE)
void SFMLGraphics::resize(const sf::Vector2f &SIZE)
{
sf::Color skyColors[2] = {
{10, 30, 100},
Expand All @@ -55,12 +55,12 @@ void TextureManager::resize(const sf::Vector2f &SIZE)
rectangle = temp;
}

sf::Texture &TextureManager::getTexture()
sf::Texture &SFMLGraphics::getTexture()
{
return texture;
}

void TextureManager::drawSky(sf::RenderWindow &window)
void SFMLGraphics::drawSky(sf::RenderWindow &window)
{
std::array<sf::Vertex, 4> temp(rectangle);
const sf::Vector2i &pos = window.mapCoordsToPixel(sf::Vector2f(0, 0));
Expand Down
Expand Up @@ -27,12 +27,12 @@ class Vertex;
class RenderWindow;
}

class TextureManager
class SFMLGraphics
{
public:
TextureManager(const sf::Vector2f &SIZE);
TextureManager(const TextureManager& orig);
virtual ~TextureManager();
SFMLGraphics(const sf::Vector2f &SIZE);
SFMLGraphics(const SFMLGraphics& orig);
virtual ~SFMLGraphics();
bool loadTexture();
sf::Texture &getTexture();
void resize(const sf::Vector2f &SIZE);
Expand Down
4 changes: 2 additions & 2 deletions source-SFML/main.cpp
Expand Up @@ -4,7 +4,7 @@
#include "World/Entities/Entity.hpp"
#include "World/WorldRenderer.hpp" // renderer
#include "World/World.hpp"
#include "TextureManager.hpp"
#include "SFMLGraphics.hpp"
#include "EntityHandler.hpp" // world
#include <memory>
#include <iostream> // world
Expand All @@ -22,7 +22,7 @@ int main()

sf::Clock deltaClock;

TextureManager textureManager(view.getSize());
SFMLGraphics textureManager(view.getSize());
if (!textureManager.loadTexture())
return 1;

Expand Down

0 comments on commit 8424504

Please sign in to comment.