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

Author Topic: General Questions  (Read 2690 times)

0 Members and 1 Guest are viewing this topic.

Zel

  • Newbie
  • *
  • Posts: 8
    • View Profile
General Questions
« on: February 08, 2020, 11:11:15 am »
Hello,

I'm currently converting a hobby project from SDL2 to SFML2.

A couple of quick questions.

1.  On multi-threading,  I use one thread to do game logic and load textures and a second thread to define sprites and draw.  On SDL these threads required mutexes to work this way.  However with SFML's thread functions, with or without mutexes, this seems to work without thread errors.  Is the omission of mutexes, in this case, a possible cause of "undefined behavior"?

2.  I've found that using viewports allows me to scale my program's internal resolution to a much larger window, is this the correct way to do this?

Thank you. ^.^


binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: General Questions
« Reply #1 on: February 09, 2020, 12:51:15 pm »
Multi-threading in SFML is no different than in any other programming library. Unless stated otherwise, simultaneous access to the same object from multiple threads requires synchronization.

Using views allows you to control a 2D virtual "camera". You choose where to place it in your 2D scene, how big the area should be that it should capture and the target region of your window where the contents should be projected. There is no right or wrong here. It depends on what you are trying to achieve artistically. Rendering to a view whose source rectangle size does not exactly correspond to its viewport size will cause the contents to be stretched or squashed along one or both axes. If you want your rendered graphics to be reproduced 1:1 you should avoid any kind of scaling and make sure your view source rectangle size matches its viewport size in pixels exactly.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

Zel

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: General Questions
« Reply #2 on: February 15, 2020, 03:57:57 am »
Thank you for confirming in detail that both keeping the mutexes and that the way I'm using the viewport are in fact consistent with my objectives.