Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/pl.h
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,8 @@ typedef struct _plWindowDesc
uint32_t uMaxWidth;
uint32_t uMinHeight;
uint32_t uMaxHeight;
bool bFullscreen;
uint32_t uFullscreenMonitor;
#endif

} plWindowDesc;
Expand Down
45 changes: 38 additions & 7 deletions src/pl_main_glfw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,13 +626,44 @@ pl_create_window(plWindowDesc tDesc, plWindow** pptWindowOut)
plWindow* ptWindow = (plWindow*)malloc(sizeof(plWindow));
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);

glfwWindowHint(GLFW_RESIZABLE, (tDesc.tFlags & PL_WINDOW_FLAG_NOT_RESIZABLE) ? GLFW_FALSE : GLFW_TRUE);
glfwWindowHint(GLFW_DECORATED, (tDesc.tFlags & PL_WINDOW_FLAG_UNDECORATED) ? GLFW_FALSE : GLFW_TRUE);
glfwWindowHint(GLFW_FLOATING, (tDesc.tFlags & PL_WINDOW_FLAG_TOP_MOST) ? GLFW_TRUE : GLFW_FALSE);
glfwWindowHint(GLFW_POSITION_X, tDesc.iXPos);
glfwWindowHint(GLFW_POSITION_Y, tDesc.iYPos);
int iWidth = 320;
int iHeight = 200;
if (tDesc.bFullscreen)
{
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
glfwWindowHint(GLFW_DECORATED, GLFW_FALSE);
glfwWindowHint(GLFW_FLOATING, GLFW_FALSE);
glfwWindowHint(GLFW_POSITION_X, 0);
glfwWindowHint(GLFW_POSITION_Y, 0);

// When fullscreen mode is active use screen size of the target monitor and
// ignore values present in the window description.
// If target monitor cannot be resolved then fallback to minimum viable size.
int iMonitorCount = 0;
GLFWmonitor **pptMonitors = glfwGetMonitors(&iMonitorCount);
if (iMonitorCount > 0 && tDesc.uFullscreenMonitor < iMonitorCount)
{
const GLFWvidmode *ptMode = glfwGetVideoMode(pptMonitors[tDesc.uFullscreenMonitor]);
if (ptMode)
{
iWidth = (int)ptMode->width;
iHeight = (int)ptMode->height;
}
}
}
else
{
glfwWindowHint(GLFW_RESIZABLE, (tDesc.tFlags & PL_WINDOW_FLAG_NOT_RESIZABLE) ? GLFW_FALSE : GLFW_TRUE);
glfwWindowHint(GLFW_DECORATED, (tDesc.tFlags & PL_WINDOW_FLAG_UNDECORATED) ? GLFW_FALSE : GLFW_TRUE);
glfwWindowHint(GLFW_FLOATING, (tDesc.tFlags & PL_WINDOW_FLAG_TOP_MOST) ? GLFW_TRUE : GLFW_FALSE);
glfwWindowHint(GLFW_POSITION_X, tDesc.iXPos);
glfwWindowHint(GLFW_POSITION_Y, tDesc.iYPos);

iWidth = (int)tDesc.uWidth;
iHeight = (int)tDesc.uHeight;
}

ptGlfwWindow = glfwCreateWindow((int)tDesc.uWidth, (int)tDesc.uHeight, tDesc.pcTitle, NULL, NULL);
ptGlfwWindow = glfwCreateWindow(iWidth, iHeight, tDesc.pcTitle, NULL, NULL);

int iMinWidth = tDesc.uMinWidth > 0 ? (int)tDesc.uMinWidth : GLFW_DONT_CARE;
int iMaxWidth = tDesc.uMaxWidth > 0 ? (int)tDesc.uMaxWidth : GLFW_DONT_CARE;
Expand Down Expand Up @@ -1749,4 +1780,4 @@ pl_glfw_error_callback(int error, const char* description)
//-----------------------------------------------------------------------------

#include "pl.c"
#include "imgui_impl_glfw.cpp"
#include "imgui_impl_glfw.cpp"