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

Author Topic: [SOLVED][Ubuntu]Invisible Window  (Read 2288 times)

0 Members and 1 Guest are viewing this topic.

lotios611

  • Newbie
  • *
  • Posts: 32
    • View Profile
[SOLVED][Ubuntu]Invisible Window
« on: February 05, 2011, 07:25:16 pm »
I am trying to create a game engine, and have hit a little snag. Whenever I try to create an sf::Window, the window is invisible. I can interact with it and the name of it appears on the taskbar, but I can't see any part of the window. Here's my code:
main.cpp
Code: [Select]
#include <SE_Engine.hpp>

int main()
{
SE::Engine engine;
engine.createWindow("Pickin' Gems", 640, 480, 32);
return engine.run();
}

SE_Engine.hpp
Code: [Select]
#ifndef SE_ENGINE_HPP
#define SE_ENGINE_HPP

#include <string>
#include <SFML/Window.hpp>

namespace SE
{
class Engine
{
public:
void createWindow(std::string name = "Solstice Engine", int width = 640, int height = 480, int bitsPerPixel = 32);
int run();
private:
sf::Window _window;
bool _running;
};
}

#endif //SE_ENGINE_HPP

SE_Engine.cpp
Code: [Select]
#include "SE_Engine.hpp"

void SE::Engine::createWindow(std::string name, int width, int height, int bitsPerPixel)
{
_window.Create(sf::VideoMode(width, height, bitsPerPixel), name);
}

int SE::Engine::run()
{
_running = true;
while (_running)
{
_window.Display();
sf::Event event;
while (_window.GetEvent(event))
{
if (event.Type == sf::Event::Closed)
{
_window.Close();
_running = false;
}
}
}
return 0;
}

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
[SOLVED][Ubuntu]Invisible Window
« Reply #1 on: February 05, 2011, 07:31:55 pm »
Hmm.. if you do a "clear and display" after creating the window, does it show then? Just a guess.

Also does it happen if you create a fresh new project where you do this directly in main?
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

lotios611

  • Newbie
  • *
  • Posts: 32
    • View Profile
[SOLVED][Ubuntu]Invisible Window
« Reply #2 on: February 05, 2011, 09:17:58 pm »
Weird, changing sf::Window to sf::RenderWindow made the window appear. I tried adding _window.Display() where I create the window, but it doesn't show until I change it to a render window.
Edit: Changing it back to sf::Window seems to of fixed it. I have no idea why it didn't work before...

 

anything