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

Author Topic: Beginner mistake? No video modes listed  (Read 489 times)

0 Members and 1 Guest are viewing this topic.

meta_leap

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Beginner mistake? No video modes listed
« on: December 04, 2023, 08:31:32 pm »
Still a bit new to C++ but years of coding in plenty other langs.

I'm really stumped on this mysterious phenomenon — the brief & simple portion of code:

    auto modes = sf::VideoMode::getFullscreenModes();
    if (modes.empty())
        modes.push_back(sf::VideoMode::getDesktopMode());
    std::printf(">>>>>>>>%d>>>\n", (int)(modes.size()));
    for (auto it = modes.begin(); it != modes.end(); it++)
        std::printf("- %dx%d @ %dbits/px\n", it->width, it->height, it->bitsPerPixel);
    std::printf("<<<<<<<<<\n");
    std::fflush(stdout);


And the baffling output:

>>>>>>>>210>>>
<<<<<<<<<


Not a single iteration with allegedly 210 vector items. Surely this must be some newbie mistake on my part?  =)

Thanks for pointers!

This is Linux with X11 (and tiled window manager i3). Compiling with gcc's g++ and SFML 2.5.1 libs. (My distro lags a bit with that kinda stuff.)
« Last Edit: December 04, 2023, 08:36:34 pm by meta_leap »

Hapax

  • Hero Member
  • *****
  • Posts: 3339
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Beginner mistake? No video modes listed
« Reply #1 on: December 05, 2023, 06:44:32 am »
I copied, pasted and ran your exact code and I got a sane result (approx. 30 items and they all listed) so I must presume there is some deeper issue.

Have you run just this exact code with nothing else and was that still an issue?

Do you normally have other lines of code too that might affect it?

Does it do this with a vector of other structures? Ints? Some custom structure of your own?
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

meta_leap

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Beginner mistake? No video modes listed
« Reply #2 on: December 05, 2023, 07:36:48 am »
Merci, knowing now that it worked fine for you, I just got the idea to run the executable directly from my terminal, rather than as-usual via gdb (usually only F5-run my code from the editor) and voila, it works fine!  ;D  wonder what's missing under gdb runs but well, it's not mission-critical  =)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10784
    • View Profile
    • development blog
    • Email
Re: Beginner mistake? No video modes listed
« Reply #3 on: December 05, 2023, 11:13:11 am »
If you run it manually via gdb then the application will by default just be loaded and if you want to run it, you have to type r.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

meta_leap

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Beginner mistake? No video modes listed
« Reply #4 on: December 05, 2023, 11:31:18 am »
Well I run-via-gdb it through a VSCode extension, so I guess it must be doing that part, because the window shows, the main loop enters and works, etc =)

 

anything