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

Author Topic: Get User's Resolution  (Read 2408 times)

0 Members and 1 Guest are viewing this topic.

radicool

  • Newbie
  • *
  • Posts: 3
    • View Profile
Get User's Resolution
« on: April 08, 2016, 08:55:51 am »
So I want to save the User's resolution into a Vector2i object.

sf::Vector2i screenDimensionsTest(sf::VideoMode.getDesktopMode().width,
sf::VideoMode.getDesktopMode().width);

No errors show, but I get errors upon compiling my code. I'm new to this stuff, could somebody explain? Am I going about this the right way?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Get User's Resolution
« Reply #1 on: April 08, 2016, 09:03:12 am »
Despite you saving the width twice this should work. What's your compiler errors then?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

radicool

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Get User's Resolution
« Reply #2 on: April 08, 2016, 10:25:05 am »
Quote
Despite you saving the width twice this should work

Lol, I've rewritten the line so many times, just a copy + paste error :)

1>c:\users\kyle\documents\visual studio 2010\projects\turn based game\turn based game\turn based game.cpp(17): error C2143: syntax error : missing ')' before '.'
1>c:\users\kyle\documents\visual studio 2010\projects\turn based game\turn based game\turn based game.cpp(17): error C3484: syntax error: expected '->' before the return type
1>c:\users\kyle\documents\visual studio 2010\projects\turn based game\turn based game\turn based game.cpp(17): error C2061: syntax error : identifier 'getDesktopMode'
1>c:\users\kyle\documents\visual studio 2010\projects\turn based game\turn based game\turn based game.cpp(113): fatal error C1506: unrecoverable block scoping error

These errors resolve resolve if I include the #include <VideoMode.hpp>

but the include directive itself gives off an error. I've also tried moving the getDesktopResolution before and after the window is created. It makes no difference.

nicox11

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: Get User's Resolution
« Reply #3 on: April 08, 2016, 11:47:24 am »
Show us your code, this look like simplistics syntaxes more than the lines you shown.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
AW: Get User's Resolution
« Reply #4 on: April 08, 2016, 11:48:27 am »
Ah I didn't look close enough, but the compiler error gives it away.

getDesktopMode() is a static function, thus you need to use :: to access it.
sf::VideoMode::getDesktopMode()
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

radicool

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Get User's Resolution
« Reply #5 on: April 08, 2016, 02:07:57 pm »
Ahh, thanks for that. It's working as intended ;D