mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-25 21:41:03 +00:00
- fixed compilation of macOS target
Base and OpenGL framebuffer classes still require proper splitting
This commit is contained in:
parent
c994692015
commit
7efa231e4e
3 changed files with 54 additions and 27 deletions
|
@ -44,12 +44,12 @@ typedef struct objc_object NSCursor;
|
||||||
typedef struct objc_object CocoaWindow;
|
typedef struct objc_object CocoaWindow;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class SystemGLFrameBuffer : public DFrameBuffer
|
class SystemBaseFrameBuffer : public DFrameBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// This must have the same parameters as the Windows version, even if they are not used!
|
// This must have the same parameters as the Windows version, even if they are not used!
|
||||||
SystemGLFrameBuffer(void *hMonitor, bool fullscreen);
|
SystemBaseFrameBuffer(void *hMonitor, bool fullscreen);
|
||||||
~SystemGLFrameBuffer();
|
~SystemBaseFrameBuffer();
|
||||||
|
|
||||||
virtual bool IsFullscreen();
|
virtual bool IsFullscreen();
|
||||||
virtual void SetVSync(bool vsync);
|
virtual void SetVSync(bool vsync);
|
||||||
|
@ -67,7 +67,7 @@ public:
|
||||||
static void SetWindowTitle(const char* title);
|
static void SetWindowTitle(const char* title);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SystemGLFrameBuffer() {}
|
SystemBaseFrameBuffer() {}
|
||||||
|
|
||||||
void SwapBuffers();
|
void SwapBuffers();
|
||||||
|
|
||||||
|
@ -95,4 +95,17 @@ private:
|
||||||
static const int MINIMUM_HEIGHT = 200;
|
static const int MINIMUM_HEIGHT = 200;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class SystemGLFrameBuffer : public SystemBaseFrameBuffer
|
||||||
|
{
|
||||||
|
typedef SystemBaseFrameBuffer Super;
|
||||||
|
|
||||||
|
public:
|
||||||
|
SystemGLFrameBuffer(void *hMonitor, bool fullscreen)
|
||||||
|
: SystemBaseFrameBuffer(hMonitor, fullscreen)
|
||||||
|
{}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
SystemGLFrameBuffer() {}
|
||||||
|
};
|
||||||
|
|
||||||
#endif // COCOA_GL_SYSFB_H_INCLUDED
|
#endif // COCOA_GL_SYSFB_H_INCLUDED
|
||||||
|
|
|
@ -285,10 +285,10 @@ NSOpenGLPixelFormat* CreatePixelFormat()
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
static SystemGLFrameBuffer* frameBuffer;
|
static SystemBaseFrameBuffer* frameBuffer;
|
||||||
|
|
||||||
|
|
||||||
SystemGLFrameBuffer::SystemGLFrameBuffer(void*, const bool fullscreen)
|
SystemBaseFrameBuffer::SystemBaseFrameBuffer(void*, const bool fullscreen)
|
||||||
: DFrameBuffer(vid_defwidth, vid_defheight)
|
: DFrameBuffer(vid_defwidth, vid_defheight)
|
||||||
, m_fullscreen(false)
|
, m_fullscreen(false)
|
||||||
, m_hiDPI(false)
|
, m_hiDPI(false)
|
||||||
|
@ -321,7 +321,7 @@ SystemGLFrameBuffer::SystemGLFrameBuffer(void*, const bool fullscreen)
|
||||||
FConsoleWindow::GetInstance().Show(false);
|
FConsoleWindow::GetInstance().Show(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemGLFrameBuffer::~SystemGLFrameBuffer()
|
SystemBaseFrameBuffer::~SystemBaseFrameBuffer()
|
||||||
{
|
{
|
||||||
assert(frameBuffer == this);
|
assert(frameBuffer == this);
|
||||||
frameBuffer = nullptr;
|
frameBuffer = nullptr;
|
||||||
|
@ -335,17 +335,17 @@ SystemGLFrameBuffer::~SystemGLFrameBuffer()
|
||||||
object:nil];
|
object:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SystemGLFrameBuffer::IsFullscreen()
|
bool SystemBaseFrameBuffer::IsFullscreen()
|
||||||
{
|
{
|
||||||
return m_fullscreen;
|
return m_fullscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemGLFrameBuffer::ToggleFullscreen(bool yes)
|
void SystemBaseFrameBuffer::ToggleFullscreen(bool yes)
|
||||||
{
|
{
|
||||||
SetMode(yes, m_hiDPI);
|
SetMode(yes, m_hiDPI);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemGLFrameBuffer::SetWindowSize(int width, int height)
|
void SystemBaseFrameBuffer::SetWindowSize(int width, int height)
|
||||||
{
|
{
|
||||||
if (width < MINIMUM_WIDTH || height < MINIMUM_HEIGHT)
|
if (width < MINIMUM_WIDTH || height < MINIMUM_HEIGHT)
|
||||||
{
|
{
|
||||||
|
@ -367,7 +367,7 @@ void SystemGLFrameBuffer::SetWindowSize(int width, int height)
|
||||||
[m_window center];
|
[m_window center];
|
||||||
}
|
}
|
||||||
|
|
||||||
int SystemGLFrameBuffer::GetTitleBarHeight() const
|
int SystemBaseFrameBuffer::GetTitleBarHeight() const
|
||||||
{
|
{
|
||||||
const NSRect windowFrame = [m_window frame];
|
const NSRect windowFrame = [m_window frame];
|
||||||
const NSRect contentFrame = [m_window contentRectForFrameRect:windowFrame];
|
const NSRect contentFrame = [m_window contentRectForFrameRect:windowFrame];
|
||||||
|
@ -377,7 +377,7 @@ int SystemGLFrameBuffer::GetTitleBarHeight() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SystemGLFrameBuffer::SetVSync(bool vsync)
|
void SystemBaseFrameBuffer::SetVSync(bool vsync)
|
||||||
{
|
{
|
||||||
const GLint value = vsync ? 1 : 0;
|
const GLint value = vsync ? 1 : 0;
|
||||||
|
|
||||||
|
@ -386,25 +386,25 @@ void SystemGLFrameBuffer::SetVSync(bool vsync)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SystemGLFrameBuffer::SwapBuffers()
|
void SystemBaseFrameBuffer::SwapBuffers()
|
||||||
{
|
{
|
||||||
[[NSOpenGLContext currentContext] flushBuffer];
|
[[NSOpenGLContext currentContext] flushBuffer];
|
||||||
}
|
}
|
||||||
|
|
||||||
int SystemGLFrameBuffer::GetClientWidth()
|
int SystemBaseFrameBuffer::GetClientWidth()
|
||||||
{
|
{
|
||||||
const int clientWidth = I_GetContentViewSize(m_window).width;
|
const int clientWidth = I_GetContentViewSize(m_window).width;
|
||||||
return clientWidth > 0 ? clientWidth : GetWidth();
|
return clientWidth > 0 ? clientWidth : GetWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SystemGLFrameBuffer::GetClientHeight()
|
int SystemBaseFrameBuffer::GetClientHeight()
|
||||||
{
|
{
|
||||||
const int clientHeight = I_GetContentViewSize(m_window).height;
|
const int clientHeight = I_GetContentViewSize(m_window).height;
|
||||||
return clientHeight > 0 ? clientHeight : GetHeight();
|
return clientHeight > 0 ? clientHeight : GetHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SystemGLFrameBuffer::SetFullscreenMode()
|
void SystemBaseFrameBuffer::SetFullscreenMode()
|
||||||
{
|
{
|
||||||
if (!m_fullscreen)
|
if (!m_fullscreen)
|
||||||
{
|
{
|
||||||
|
@ -418,7 +418,7 @@ void SystemGLFrameBuffer::SetFullscreenMode()
|
||||||
[m_window setFrame:screenFrame display:YES];
|
[m_window setFrame:screenFrame display:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemGLFrameBuffer::SetWindowedMode()
|
void SystemBaseFrameBuffer::SetWindowedMode()
|
||||||
{
|
{
|
||||||
if (m_fullscreen)
|
if (m_fullscreen)
|
||||||
{
|
{
|
||||||
|
@ -451,7 +451,7 @@ void SystemGLFrameBuffer::SetWindowedMode()
|
||||||
[m_window exitAppOnClose];
|
[m_window exitAppOnClose];
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemGLFrameBuffer::SetMode(const bool fullscreen, const bool hiDPI)
|
void SystemBaseFrameBuffer::SetMode(const bool fullscreen, const bool hiDPI)
|
||||||
{
|
{
|
||||||
NSOpenGLView* const glView = [m_window contentView];
|
NSOpenGLView* const glView = [m_window contentView];
|
||||||
[glView setWantsBestResolutionOpenGLSurface:hiDPI];
|
[glView setWantsBestResolutionOpenGLSurface:hiDPI];
|
||||||
|
@ -485,7 +485,7 @@ void SystemGLFrameBuffer::SetMode(const bool fullscreen, const bool hiDPI)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SystemGLFrameBuffer::UseHiDPI(const bool hiDPI)
|
void SystemBaseFrameBuffer::UseHiDPI(const bool hiDPI)
|
||||||
{
|
{
|
||||||
if (frameBuffer != nullptr)
|
if (frameBuffer != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -493,7 +493,7 @@ void SystemGLFrameBuffer::UseHiDPI(const bool hiDPI)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemGLFrameBuffer::SetCursor(NSCursor* cursor)
|
void SystemBaseFrameBuffer::SetCursor(NSCursor* cursor)
|
||||||
{
|
{
|
||||||
if (frameBuffer != nullptr)
|
if (frameBuffer != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -505,7 +505,7 @@ void SystemGLFrameBuffer::SetCursor(NSCursor* cursor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemGLFrameBuffer::SetWindowVisible(bool visible)
|
void SystemBaseFrameBuffer::SetWindowVisible(bool visible)
|
||||||
{
|
{
|
||||||
if (frameBuffer != nullptr)
|
if (frameBuffer != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -522,7 +522,7 @@ void SystemGLFrameBuffer::SetWindowVisible(bool visible)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemGLFrameBuffer::SetWindowTitle(const char* title)
|
void SystemBaseFrameBuffer::SetWindowTitle(const char* title)
|
||||||
{
|
{
|
||||||
if (frameBuffer != nullptr)
|
if (frameBuffer != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -575,7 +575,7 @@ void I_SetFPSLimit(int limit)
|
||||||
|
|
||||||
CUSTOM_CVAR(Bool, vid_hidpi, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
|
CUSTOM_CVAR(Bool, vid_hidpi, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
|
||||||
{
|
{
|
||||||
SystemGLFrameBuffer::UseHiDPI(self);
|
SystemBaseFrameBuffer::UseHiDPI(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -632,7 +632,7 @@ bool I_SetCursor(FTexture *cursorpic)
|
||||||
hotSpot:NSMakePoint(0.0f, 0.0f)];
|
hotSpot:NSMakePoint(0.0f, 0.0f)];
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemGLFrameBuffer::SetCursor(cursor);
|
SystemBaseFrameBuffer::SetCursor(cursor);
|
||||||
|
|
||||||
[pool release];
|
[pool release];
|
||||||
|
|
||||||
|
@ -652,11 +652,11 @@ NSSize I_GetContentViewSize(const NSWindow* const window)
|
||||||
|
|
||||||
void I_SetMainWindowVisible(bool visible)
|
void I_SetMainWindowVisible(bool visible)
|
||||||
{
|
{
|
||||||
SystemGLFrameBuffer::SetWindowVisible(visible);
|
SystemBaseFrameBuffer::SetWindowVisible(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
// each platform has its own specific version of this function.
|
// each platform has its own specific version of this function.
|
||||||
void I_SetWindowTitle(const char* title)
|
void I_SetWindowTitle(const char* title)
|
||||||
{
|
{
|
||||||
SystemGLFrameBuffer::SetWindowTitle(title);
|
SystemBaseFrameBuffer::SetWindowTitle(title);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ extern HWND Window;
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "vk_device.h"
|
#include "vk_device.h"
|
||||||
#include "vk_swapchain.h"
|
#include "vk_swapchain.h"
|
||||||
|
@ -74,9 +75,13 @@ VulkanDevice::VulkanDevice()
|
||||||
createDevice();
|
createDevice();
|
||||||
createAllocator();
|
createAllocator();
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
RECT clientRect = { 0 };
|
RECT clientRect = { 0 };
|
||||||
GetClientRect(Window, &clientRect);
|
GetClientRect(Window, &clientRect);
|
||||||
swapChain = std::make_unique<VulkanSwapChain>(this, clientRect.right, clientRect.bottom, vid_vsync);
|
swapChain = std::make_unique<VulkanSwapChain>(this, clientRect.right, clientRect.bottom, vid_vsync);
|
||||||
|
#else
|
||||||
|
assert(!"Implement platform-specific swapchain size getter");
|
||||||
|
#endif
|
||||||
|
|
||||||
createSemaphores();
|
createSemaphores();
|
||||||
}
|
}
|
||||||
|
@ -94,11 +99,15 @@ VulkanDevice::~VulkanDevice()
|
||||||
|
|
||||||
void VulkanDevice::windowResized()
|
void VulkanDevice::windowResized()
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
RECT clientRect = { 0 };
|
RECT clientRect = { 0 };
|
||||||
GetClientRect(Window, &clientRect);
|
GetClientRect(Window, &clientRect);
|
||||||
|
|
||||||
swapChain.reset();
|
swapChain.reset();
|
||||||
swapChain = std::make_unique<VulkanSwapChain>(this, clientRect.right, clientRect.bottom, vid_vsync);
|
swapChain = std::make_unique<VulkanSwapChain>(this, clientRect.right, clientRect.bottom, vid_vsync);
|
||||||
|
#else
|
||||||
|
assert(!"Implement platform-specific swapchain resize");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanDevice::waitPresent()
|
void VulkanDevice::waitPresent()
|
||||||
|
@ -202,7 +211,12 @@ void VulkanDevice::createInstance()
|
||||||
appInfo.engineVersion = VK_MAKE_VERSION(ENG_MAJOR, ENG_MINOR, ENG_REVISION);
|
appInfo.engineVersion = VK_MAKE_VERSION(ENG_MAJOR, ENG_MINOR, ENG_REVISION);
|
||||||
appInfo.apiVersion = VK_API_VERSION_1_0;
|
appInfo.apiVersion = VK_API_VERSION_1_0;
|
||||||
|
|
||||||
std::vector<const char *> enabledExtensions = { VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_WIN32_SURFACE_EXTENSION_NAME };
|
std::vector<const char *> enabledExtensions = { VK_KHR_SURFACE_EXTENSION_NAME };
|
||||||
|
#ifdef _WIN32
|
||||||
|
enabledExtensions.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
|
||||||
|
#else
|
||||||
|
assert(!"Add platform-specific surface extension");
|
||||||
|
#endif
|
||||||
|
|
||||||
std::vector<const char*> validationLayers;
|
std::vector<const char*> validationLayers;
|
||||||
std::string debugLayer = "VK_LAYER_LUNARG_standard_validation";
|
std::string debugLayer = "VK_LAYER_LUNARG_standard_validation";
|
||||||
|
|
Loading…
Reference in a new issue