SFML community forums
Help => Window => Topic started by: racumin on October 08, 2009, 09:08:12 am
-
Hi! I'm new to c++ and sfml. I'm creating a small window but the titlebar won't show. I tried
int main() {
WindowSettings settings;
settings.DepthBits = 32;
settings.StencilBits = 8;
settings.AntialiasingLevel = 2;
VideoMode mode(100, 150, 32);
RenderWindow window(mode, "SFML Window", Style::Titlebar, settings);
while (window.IsOpened()) {
window.Clear();
//handle events here
window.Display();
}
}
in Ubuntu Hardy but the titlebar won't show. How can I fix this problem? Thanks!
-
You should handle events (ie. call GetEvent) if you want anything to happen on your window, including being displayed properly.
-
I just need to see the title bar for my window. How do I make the window show the title bar? How will I do this using the GetEvent method?
-
You just have to insert a proper event handling inside your main loop, like it is explained in the tutorials
http://www.sfml-dev.org/tutorials/1.5/window-events.php
-
Hi I think the problem is cause by the Ubuntu OS. I tried the code from http://www.sfml-dev.org/forum/viewtopic.php?t=1257&highlight=title and when I ran it, no window was displayed. How do I fix that?
-
This code doesn't handle events. I think the problem is that you don't want to call GetEvent in your main loop ;)
PS: you should activate BBCode in your profile; every time you use [ link ] or [ code ] it is ignored because you have explicitely disabled BBCode for your messages, and I have to fix it
-
Hi, for now, I think the call to GetEvent is not neccessary. From the link above, you can see in its screenshot that there is a window with black background and a title bar with the "iiiiSkipBo" text. There is also a minimize, maximize and close buttons. When I ran this program in Ubuntu, it produces some black pixels with no window at all.
If I am wrong, please correct me. If I need to call the GetEvent, what will I do there? Is it something like
while (App.GetEvent(Event))
{
if (Event.Type == sf::Event::window_opened??)
//display titlebar here
}
Thanks!
-
Hi, for now, I think the call to GetEvent is not neccessary. From the link above, you can see in its screenshot that there is a window with black background and a title bar with the "iiiiSkipBo" text. There is also a minimize, maximize and close buttons. When I ran this program in Ubuntu, it produces some black pixels with no window at all.
If I am wrong, please correct me. If I need to call the GetEvent, what will I do there? Is it something like
while (App.GetEvent(Event))
{
if (Event.Type == sf::Event::window_opened??)
//display titlebar here
}
Thanks!
No, you don't have to explicitly draw the Titlebar. Otherwise Laurent wouldn't have complaints about not being able to change the Titlebar every once in a while. XD
If you don't want to handle any events, just use this:
while (App.GetEvent(&Event)) // The & is required so that you don't get Memory Leaks and can actually use the Event variable
{
}
That way, the Window Event Queue won't overflow, you don't use any of the events, and the Window works properly. However, if you want the "X" button on the Titlebar to work, you will have to add a little event handling to the window.
-
I think the call to GetEvent is not neccessary
But I tell you it is. On some OSes the window is frozen until you ask the OS to handle its events.
From the link above, you can see in its screenshot that there is a window with black background and a title bar with the "iiiiSkipBo" text. There is also a minimize, maximize and close buttons. When I ran this program in Ubuntu, it produces some black pixels with no window at all.
Different OS, different results ;)
If I need to call the GetEvent, what will I do there?
If you don't need to handle events at all, you can use an empty loop
Event event;
while (App.GetEvent(event))
{
}
But I think you need to handle the Close event, at least.
-
Hi, I tried the following code. It produces a screen with 100 x 150 pixels. But the problem is, I cannot see the title bar. But when I try to click the area where the close button should be located, it prints "closing", meaning that the handling of events function correctly but the title bar really won't show. I'm using Ubuntu Hardy.
int main() {
cout << "Starting..." << endl;
WindowSettings settings;
settings.DepthBits = 32;
settings.StencilBits = 8;
settings.AntialiasingLevel = 2;
VideoMode mode(100, 150, 32);
RenderWindow window(mode, "SFML Window", Style::Close, settings);
window.SetFramerateLimit(60);
while (window.IsOpened() && running) {
window.Clear();
//listen for events
Event event;
while (window.GetEvent(event)) {
// a key is pressed
if (event.Type == Event::KeyPressed) {
} else if (event.Type == Event::Closed) {
cout << "closing" << endl;
}
}
window.Display();
}
cout << "Exiting..." << endl;
return EXIT_SUCCESS;
}
-
What window manager are you using? Is it an OpenGL one like Compiz?
-
It's Compiz.
-
It should work if you disable Compiz. As far as I know, it's impossible to get SFML and Compiz to work together.
-
Hi thanks for the solution! I disabled the visual effects and now the title bar is displayed. Thank you very much!!!!