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

Author Topic: No title bar on RenderWindow  (Read 5191 times)

0 Members and 1 Guest are viewing this topic.

racumin

  • Newbie
  • *
  • Posts: 16
    • View Profile
No title bar on RenderWindow
« 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
Code: [Select]

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!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
No title bar on RenderWindow
« Reply #1 on: October 08, 2009, 09:09:49 am »
You should handle events (ie. call GetEvent) if you want anything to happen on your window, including being displayed properly.
Laurent Gomila - SFML developer

racumin

  • Newbie
  • *
  • Posts: 16
    • View Profile
No title bar on RenderWindow
« Reply #2 on: October 08, 2009, 09:12:35 am »
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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
No title bar on RenderWindow
« Reply #3 on: October 08, 2009, 09:17:20 am »
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
Laurent Gomila - SFML developer

racumin

  • Newbie
  • *
  • Posts: 16
    • View Profile
No title bar on RenderWindow
« Reply #4 on: October 08, 2009, 10:25:42 am »
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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
No title bar on RenderWindow
« Reply #5 on: October 08, 2009, 10:31:07 am »
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
Laurent Gomila - SFML developer

racumin

  • Newbie
  • *
  • Posts: 16
    • View Profile
No title bar on RenderWindow
« Reply #6 on: October 09, 2009, 09:00:42 am »
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
Code: [Select]

    while (App.GetEvent(Event))
    {
        if (Event.Type == sf::Event::window_opened??)
            //display titlebar here
    }


Thanks!

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
No title bar on RenderWindow
« Reply #7 on: October 10, 2009, 06:23:00 am »
Quote from: "racumin"
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
Code: [Select]

    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:
Code: [Select]
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 use the latest build of SFML2

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
No title bar on RenderWindow
« Reply #8 on: October 10, 2009, 11:11:51 am »
Quote
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.

Quote
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 ;)

Quote
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
Code: [Select]
Event event;
while (App.GetEvent(event))
{
}

But I think you need to handle the Close event, at least.
Laurent Gomila - SFML developer

racumin

  • Newbie
  • *
  • Posts: 16
    • View Profile
No title bar on RenderWindow
« Reply #9 on: October 12, 2009, 04:22:02 am »
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.

Code: [Select]

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;

}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
No title bar on RenderWindow
« Reply #10 on: October 12, 2009, 08:04:12 am »
What window manager are you using? Is it an OpenGL one like Compiz?
Laurent Gomila - SFML developer

racumin

  • Newbie
  • *
  • Posts: 16
    • View Profile
No title bar on RenderWindow
« Reply #11 on: October 12, 2009, 10:09:41 am »
It's Compiz.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
No title bar on RenderWindow
« Reply #12 on: October 12, 2009, 10:36:58 am »
It should work if you disable Compiz. As far as I know, it's impossible to get SFML and Compiz to work together.
Laurent Gomila - SFML developer

racumin

  • Newbie
  • *
  • Posts: 16
    • View Profile
No title bar on RenderWindow
« Reply #13 on: October 12, 2009, 10:50:33 am »
Hi thanks for the solution! I disabled the visual effects  and now the title bar is displayed. Thank you very much!!!!