facebookarchive / UETorch

A Torch plugin for Unreal Engine 4.
Other
369 stars 70 forks source link

alternative implementation of uetorch.SetResolution #40

Closed mmmaat closed 6 years ago

mmmaat commented 7 years ago

Hi Adam,

First of all, thanks for the UETorch plugin that works very well! I'm working on the NaivePhysics project after @marioyc, using the 4.8 version for now.

I found a problem with the current implementation of the SetResolution function. Taking a screenshot just after a resolution change give a black image (but depth and masks are OK). Below is an alternative implementation that fixes the problem...

// implemented from https://wiki.unrealengine.com/Game_User_Settings
extern "C" bool SetResolution(int x, int y) {
  if(! GEngine)
    return false;

  UGameUserSettings* Settings = GEngine->GameUserSettings;
  if(! Settings)
    return false;

  Settings->RequestResolutionChange(x, y, EWindowMode::Type::Windowed, false);
  Settings->ConfirmVideoMode();
  return true;
}
adamlerer commented 7 years ago

Thanks @mmmaat , would you like to submit this as a PR?

mmmaat commented 7 years ago

Ok that's done ;)