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

Show Posts

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.


Messages - Viped

Pages: [1]
1
Graphics / Re: I am getting only white screen when rendering
« on: November 21, 2014, 08:36:42 am »
Thanks for all the suggestions. I haven't really ever coded anything in C++, but because it's industry standard I decided to give it a try, so all tips are more than welcome.

2
Graphics / Re: I am getting only white screen when rendering
« on: November 20, 2014, 04:26:26 pm »
Nice. Thanks. That even makes sense now.

3
Graphics / I am getting only white screen when rendering
« on: November 20, 2014, 03:48:32 pm »
Hi all,

I am getting only white screen when rendering "outside" of main loop. I have Renderer class where I have render method and I pass sf::renderWindow by reference to there.

Renderer.cpp
#include "Renderer.h"

#include <iostream>

Renderer::Renderer() {
        sf::Texture tex;
        if (!tex.loadFromFile("background.png")) {
                std::cout << "Error loading file \"background.png\"" << std::endl;
        }

        _background.setTexture(tex);
        std::cout << _background.getTexture() << std::endl;
}

void Renderer::Render(sf::RenderWindow &window) {

        window.clear();
        window.draw(_background);
        window.display();
}

Renderer.h
#ifndef __ImpossiblePlatformer_Renderer_h__
#define __ImpossiblePlatformer_Renderer_h__

#include "SFML\Graphics.hpp"

class Renderer {

public:
        Renderer();
        void Render(sf::RenderWindow &window);

private:
        sf::Sprite _background;
};

#endif

And lastly main.cpp
#include "SFML\Graphics.hpp"

#include "Constants.h"
#include "EventHandler.h"
#include "Renderer.h"
#include <iostream>

int main() {

        sf::RenderWindow window(sf::VideoMode(1280, 720), "Impossible platformer VERSION");

        EventHandler eh;
        Renderer renderer;

        while (window.isOpen()) {
                eh.LoopAllKeyEvents(window);

                renderer.Render(window);
        }

        return 0;
}

Pages: [1]
anything