Metal: Fixed screenshot.

This commit is contained in:
Бранимир Караџић
2020-11-10 17:14:54 -08:00
parent e541312851
commit 2b4bf6d913
5 changed files with 17 additions and 29 deletions

View File

@@ -199,13 +199,13 @@ namespace entry
{
NSRect originalFrame = [_window frame];
NSRect adjustFrame = [_window contentRectForFrameRect: originalFrame];
adjustFrame.origin.y = NSMaxY(NSScreen.screens[0].frame) - NSMaxY(adjustFrame);
CGWarpMouseCursorPosition(CGPointMake(_x + adjustFrame.origin.x, _y + adjustFrame.origin.y));
CGAssociateMouseAndMouseCursorPosition(YES);
}
void setMouseLock(NSWindow* _window, bool _lock)
{
NSWindow* newMouseLock = _lock ? _window : NULL;
@@ -216,10 +216,10 @@ namespace entry
{
NSRect originalFrame = [_window frame];
NSRect adjustFrame = [_window contentRectForFrameRect: originalFrame];
m_cmx = (int)adjustFrame.size.width / 2;
m_cmy = (int)adjustFrame.size.height / 2;
setMousePos(_window, m_cmx, m_cmy);
[NSCursor hide];
}
@@ -324,12 +324,12 @@ namespace entry
case NSEventTypeRightMouseDragged:
case NSEventTypeOtherMouseDragged:
getMousePos(window, &m_mx, &m_my);
if (window == m_mouseLock)
{
m_mx -= m_cmx;
m_my -= m_cmy;
setMousePos(window, m_cmx, m_cmy);
}
@@ -572,7 +572,7 @@ namespace entry
int32_t m_scroll;
int32_t m_style;
bool m_exit;
NSWindow* m_mouseLock;
int32_t m_cmx;
int32_t m_cmy;

View File

@@ -2060,6 +2060,7 @@ namespace bgfx
m_cmdPre.start();
m_cmdPost.start();
m_capture = false;
m_saveScreenshot = false;
}
void finish()
@@ -2197,6 +2198,7 @@ namespace bgfx
Resolution m_resolution;
uint32_t m_debug;
bool m_saveScreenshot;
CommandBuffer m_cmdPre;
CommandBuffer m_cmdPost;
@@ -4802,6 +4804,8 @@ namespace bgfx
}
}
m_submit->m_saveScreenshot = true;
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::RequestScreenShot);
uint16_t len = (uint16_t)bx::strLen(_filePath)+1;
cmdbuf.write(_handle);

View File

@@ -150,10 +150,10 @@ namespace bgfx { namespace gl
m_view = glView;
m_context = glContext;
}
else
{
[g_platformData.context makeCurrentContext];
}
else
{
[(NSOpenGLContext*)g_platformData.context makeCurrentContext];
}
import();

View File

@@ -364,7 +364,6 @@ namespace bgfx { namespace mtl
, m_rtMsaa(false)
, m_capture(NULL)
, m_captureSize(0)
, m_saveScreenshot(false)
{
bx::memSet(&m_windows, 0xff, sizeof(m_windows) );
}
@@ -982,12 +981,6 @@ namespace bgfx { namespace mtl
m_uniformReg.remove(_handle);
}
void requestScreenShotPre(const char* _filePath)
{
BX_UNUSED(_filePath);
m_saveScreenshot = true;
}
void requestScreenShot(FrameBufferHandle _handle, const char* _filePath) override
{
BX_UNUSED(_handle);
@@ -2390,7 +2383,6 @@ namespace bgfx { namespace mtl
SamplerDescriptor m_samplerDescriptor;
// currently active objects data
bool m_saveScreenshot;
Texture m_screenshotTarget;
ShaderMtl m_screenshotBlitProgramVsh;
ShaderMtl m_screenshotBlitProgramFsh;
@@ -3700,7 +3692,7 @@ namespace bgfx { namespace mtl
updateResolution(_render->m_resolution);
if (m_saveScreenshot
if (_render->m_saveScreenshot
|| NULL != m_capture)
{
if (m_screenshotTarget)
@@ -3740,8 +3732,6 @@ namespace bgfx { namespace mtl
m_screenshotTarget = m_device.newTextureWithDescriptor(m_textureDescriptor);
}
m_saveScreenshot = false;
}
else
{

View File

@@ -994,12 +994,6 @@ namespace bgfx { namespace webgpu
m_uniformReg.remove(_handle);
}
void requestScreenShotPre(const char* _filePath)
{
BX_UNUSED(_filePath);
//m_saveScreenshot = true;
}
void requestScreenShot(FrameBufferHandle _handle, const char* _filePath) override
{
BX_UNUSED(_handle); BX_UNUSED(_filePath);