Hi everyone, hopefully this is the right area for this post.
Could someone take a look at my code and see why the splash will not show in the window? I'm not getting any errors, it just won't show in the window. I've read the example from the docs, some other problems like what I'm trying to do but I'm stilling having some problems. Thanks for any help.
Code from splash.h
#ifndef SPLASH_H
#define SPLASH_H
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/OpenGL.hpp>
#include <iostream>
class Splash : public sf::Drawable
{
private :
sf::Sprite m_sprite;
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const
{
target.draw(m_sprite, states);
}
public:
Splash();
};
Splash::Splash()
{
std::cout << "Entered default constructor" << std::endl;
sf::Texture m_texture;
m_texture.loadFromFile("resources/Splash.png");
sf::RectangleShape m_rectangleShape;
m_rectangleShape.setTexture(&m_texture);
sf::Sprite m_sprite(m_texture);
m_sprite.setTextureRect(sf::IntRect(0, 0, 300, 300));
m_sprite.setPosition(0,0);
}
#endif
Code from main.cpp
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/OpenGL.hpp>
#include <iostream>
#include "splash.h"
int main()
{
Splash loadSplash;
sf::ContextSettings contextSettings;
contextSettings.depthBits = 24;
int screenX = sf::VideoMode::getDesktopMode().width;
int screenY = sf::VideoMode::getDesktopMode().height;
sf::RenderWindow mainWin(sf::VideoMode(screenX/2, screenY), "BusbySoft", sf::Style::Default, contextSettings);
mainWin.setVerticalSyncEnabled(true);
mainWin.setPosition(sf::Vector2i(0, 0));
while (mainWin.isOpen())
{
sf::Event event;
while (mainWin.pollEvent(event))
{
// Close window: exit
if (event.type == sf::Event::Closed)
mainWin.close();
// Escape key: exit
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))
mainWin.close();
if(event.type == sf::Event::MouseMoved)
{
std::cout << "x=" << event.mouseMove.x << ", y=" << event.mouseMove.y << std::endl;
}
}
// Clear the depth buffer
glClear(GL_DEPTH_BUFFER_BIT);
//mainWin.clear(sf::Color(35,44,69,255));
mainWin.draw(loadSplash);
// Finally, display the rendered frame on screen
mainWin.display();
}
return EXIT_SUCCESS;
}