mirror of
https://github.com/glfw/glfw.git
synced 2025-06-08 08:45:02 +00:00
Fixed resize problem. Added callback to position on IDCMP_CHANGEWINDOW. Set RGB bits on fbconfig
This commit is contained in:
parent
f7a6cf9a2f
commit
ea8833c8a1
@ -122,15 +122,26 @@ GLFWbool _glfwCreateContextGL(_GLFWwindow* window,
|
||||
{
|
||||
ULONG errCode;
|
||||
|
||||
dprintf("redBits=%d\n", fbconfig->redBits);
|
||||
dprintf("greenBits=%d\n", fbconfig->greenBits);
|
||||
dprintf("blueBits=%d\n", fbconfig->blueBits);
|
||||
dprintf("alphaBits=%d\n", fbconfig->alphaBits);
|
||||
dprintf("depthBits=%d\n", fbconfig->depthBits);
|
||||
dprintf("stencilBits=%d\n", fbconfig->stencilBits);
|
||||
dprintf("accumRedBits=%d\n", fbconfig->accumRedBits);
|
||||
dprintf("accumGreenBits=%d\n", fbconfig->accumGreenBits);
|
||||
dprintf("accumBlueBits=%d\n", fbconfig->accumBlueBits);
|
||||
dprintf("accumAlphaBits=%d\n", fbconfig->accumAlphaBits);
|
||||
dprintf("auxBuffers=%d\n", fbconfig->auxBuffers);
|
||||
|
||||
struct TagItem contextparams[] =
|
||||
{
|
||||
{OGLES2_CCT_WINDOW,(ULONG)window->os4.handle},
|
||||
/*
|
||||
{OGLES2_CCT_DEPTH,_this->gl_config.depth_size},
|
||||
{OGLES2_CCT_STENCIL,_this->gl_config.stencil_size},
|
||||
*/
|
||||
{OGLES2_CCT_VSYNC,0},
|
||||
{TAG_DONE,0}
|
||||
{OGLES2_CCT_WINDOW, (ULONG)window->os4.handle},
|
||||
{OGLES2_CCT_DEPTH, fbconfig->depthBits},
|
||||
{OGLES2_CCT_STENCIL, fbconfig->stencilBits},
|
||||
{OGLES2_CCT_VSYNC, 0},
|
||||
{OGLES2_CCT_RESIZE_VIEWPORT, TRUE},
|
||||
{TAG_DONE, 0}
|
||||
};
|
||||
|
||||
window->context.gl.glContext = (void *)aglCreateContext2(&errCode, contextparams);
|
||||
|
@ -534,7 +534,6 @@ int _glfwInitOS4(void)
|
||||
{
|
||||
loadLibraries();
|
||||
createKeyTables();
|
||||
_glfwPollMonitorsOS4();
|
||||
|
||||
if (!(_glfw.os4.userPort = IExec->AllocSysObjectTags(ASOT_PORT, TAG_DONE))) {
|
||||
return GLFW_FALSE;
|
||||
@ -545,6 +544,7 @@ int _glfwInitOS4(void)
|
||||
}
|
||||
|
||||
OS4_LockPubScreen();
|
||||
_glfwPollMonitorsOS4();
|
||||
|
||||
OS4_FindApplicationName();
|
||||
|
||||
|
@ -37,18 +37,74 @@
|
||||
//
|
||||
static GLFWvidmode getVideoMode(void)
|
||||
{
|
||||
struct Screen* currentScreen = IIntuition->LockPubScreen(NULL);
|
||||
|
||||
APTR handle;
|
||||
struct DimensionInfo diminfo;
|
||||
struct DisplayInfo dispinfo;
|
||||
GLFWvidmode mode;
|
||||
mode.width = currentScreen->Width;
|
||||
mode.height = currentScreen->Height;
|
||||
// TODO - Change this
|
||||
ULONG modeid;
|
||||
|
||||
IIntuition->GetScreenAttrs(_glfw.os4.publicScreen, SA_DisplayID, &modeid, TAG_DONE);
|
||||
|
||||
handle = IGraphics->FindDisplayInfo(modeid);
|
||||
if (!handle) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!IGraphics->GetDisplayInfoData(handle, (UBYTE *)&diminfo, sizeof(diminfo), DTAG_DIMS, 0)) {
|
||||
dprintf("Failed to get dim info\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!IGraphics->GetDisplayInfoData(handle, (UBYTE *)&dispinfo, sizeof(dispinfo), DTAG_DISP, 0)) {
|
||||
dprintf("Failed to get disp info\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
mode.width = diminfo.Nominal.MaxX - diminfo.Nominal.MinX + 1;
|
||||
mode.height = diminfo.Nominal.MaxY - diminfo.Nominal.MinY + 1;
|
||||
mode.refreshRate = 60; // grab DTAG_MNTR?
|
||||
if (dispinfo.PropertyFlags & DIPF_IS_RTG) {
|
||||
dprintf("RTG mode %d: w=%d, h=%d, bits=%d\n", modeid, mode.width, mode.height, diminfo.MaxDepth);
|
||||
|
||||
switch (diminfo.MaxDepth) {
|
||||
case 32:
|
||||
mode.redBits = 8;
|
||||
mode.greenBits = 8;
|
||||
mode.blueBits = 8;
|
||||
break;
|
||||
case 24:
|
||||
mode.redBits = 8;
|
||||
mode.greenBits = 8;
|
||||
mode.blueBits = 8;
|
||||
break;
|
||||
case 16:
|
||||
mode.redBits = 5;
|
||||
mode.greenBits = 6;
|
||||
mode.blueBits = 5;
|
||||
break;
|
||||
case 15:
|
||||
mode.redBits = 5;
|
||||
mode.greenBits = 5;
|
||||
mode.blueBits = 5;
|
||||
break;
|
||||
default:
|
||||
// TODO - What we have to use for 8?
|
||||
mode.redBits = 8;
|
||||
mode.greenBits = 8;
|
||||
mode.blueBits = 8;
|
||||
break;
|
||||
}
|
||||
|
||||
return mode;
|
||||
}
|
||||
|
||||
out:
|
||||
// TODO - Change this fallback
|
||||
mode.refreshRate = 60;
|
||||
mode.redBits = 8;
|
||||
mode.greenBits = 8;
|
||||
mode.blueBits = 8;
|
||||
mode.refreshRate = 60;
|
||||
|
||||
IIntuition->UnlockPubScreen(NULL, currentScreen);
|
||||
return mode;
|
||||
}
|
||||
|
||||
@ -176,7 +232,7 @@ OS4_LockPubScreen()
|
||||
if (_glfw.os4.publicScreen) {
|
||||
return TRUE;
|
||||
} else {
|
||||
printf("Failed to lock Workbench screen\n");
|
||||
dprintf("Failed to lock Workbench screen\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -46,13 +46,15 @@ static int OS4_GetButton(uint16_t code);
|
||||
static char OS4_TranslateUnicode(uint16_t code, uint32_t qualifier);
|
||||
static int OS4_TranslateState(int state);
|
||||
static uint32_t OS4_GetWindowFlags(_GLFWwindow* window, BOOL fullscreen);
|
||||
static void OS4_SetWindowLimits(_GLFWwindow * window, struct Window * syswin);
|
||||
static void OS4_SetWindowLimits(_GLFWwindow * window);
|
||||
static void OS4_CreateIconifyGadget(_GLFWwindow * window);
|
||||
static struct DiskObject *OS4_GetDiskObject();
|
||||
static void OS4_HandleAppIcon(struct AppMessage * msg);
|
||||
static ULONG OS4_BackFill(const struct Hook *hook, struct RastPort *rastport, struct BackFillMessage *message);
|
||||
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
static UWORD fallbackPointerData[2 * 16] = { 0 };
|
||||
|
||||
@ -83,6 +85,8 @@ static void applySizeLimits(_GLFWwindow* window, int* width, int* height)
|
||||
*height = window->minheight;
|
||||
else if (window->maxheight != GLFW_DONT_CARE && *height > window->maxheight)
|
||||
*height = window->maxheight;
|
||||
|
||||
OS4_SetWindowLimits(window);
|
||||
}
|
||||
|
||||
static void fitToMonitor(_GLFWwindow* window)
|
||||
@ -148,6 +152,8 @@ static int createNativeWindow(_GLFWwindow* window,
|
||||
WA_InnerHeight, wndconfig->height,
|
||||
WA_Title, wndconfig->title,
|
||||
WA_ScreenTitle, wndconfig->title,
|
||||
WA_MaxWidth, _glfw.os4.publicScreen->Width,
|
||||
WA_MaxHeight, _glfw.os4.publicScreen->Height,
|
||||
WA_Flags, windowFlags,
|
||||
WA_IDCMP, IDCMP_CLOSEWINDOW |
|
||||
IDCMP_MOUSEMOVE |
|
||||
@ -650,8 +656,7 @@ void _glfwPollEventsOS4(void)
|
||||
break;
|
||||
|
||||
case IDCMP_NEWSIZE:
|
||||
printf("w: %d - h: %d\n", msg.Width, msg.Height);
|
||||
//_glfwInputWindowSize(window, msg.Width, msg.Height);
|
||||
_glfwInputWindowSize(window, msg.Width, msg.Height);
|
||||
//OS4_HandleResize(_this, &msg);
|
||||
break;
|
||||
|
||||
@ -660,6 +665,8 @@ void _glfwPollEventsOS4(void)
|
||||
window->os4.xpos = imsg->IDCMPWindow->LeftEdge;
|
||||
window->os4.ypos = imsg->IDCMPWindow->TopEdge;
|
||||
}
|
||||
//dprintf("w: %d - h: %d - x =%d - y = %d\n", msg.Width, msg.Height, window->os4.xpos, window->os4.ypos);
|
||||
_glfwInputWindowPos(window, window->os4.xpos, window->os4.ypos);
|
||||
|
||||
//OS4_HandleMove(_this, &msg);
|
||||
//OS4_HandleResize(_this, &msg);
|
||||
@ -1034,12 +1041,13 @@ OS4_GetWindowFlags(_GLFWwindow* window, BOOL fullscreen)
|
||||
}
|
||||
|
||||
static void
|
||||
OS4_SetWindowLimits(_GLFWwindow * window, struct Window * syswin)
|
||||
OS4_SetWindowLimits(_GLFWwindow * window)
|
||||
{
|
||||
const int minW = window->minwidth ? max(MIN_WINDOW_SIZE, window->minwidth) : MIN_WINDOW_SIZE;
|
||||
const int minH = window->minheight ? max(MIN_WINDOW_SIZE, window->minheight) : MIN_WINDOW_SIZE;
|
||||
const int maxW = window->maxwidth;
|
||||
const int maxH = window->maxheight;
|
||||
struct Window * syswin = window->os4.handle;
|
||||
const int minW = window->minwidth ? MAX(MIN_WINDOW_SIZE, window->minwidth) : MIN_WINDOW_SIZE;
|
||||
const int minH = window->minheight ? MAX(MIN_WINDOW_SIZE, window->minheight) : MIN_WINDOW_SIZE;
|
||||
const int maxW = window->maxwidth != GLFW_DONT_CARE ? window->maxwidth : GLFW_DONT_CARE;
|
||||
const int maxH = window->maxheight != GLFW_DONT_CARE ? window->maxheight : GLFW_DONT_CARE;
|
||||
|
||||
dprintf("Window min size %d*%d, max size %d*%d\n", minW, minH, maxW, maxH);
|
||||
|
||||
@ -1049,8 +1057,8 @@ OS4_SetWindowLimits(_GLFWwindow * window, struct Window * syswin)
|
||||
BOOL ret = IIntuition->WindowLimits(syswin,
|
||||
minW + borderWidth,
|
||||
minH + borderHeight,
|
||||
maxW ? (maxW + borderWidth) : -1,
|
||||
maxH ? (maxH + borderHeight) : -1);
|
||||
maxW != GLFW_DONT_CARE ? (maxW + borderWidth) : GLFW_DONT_CARE,
|
||||
maxH != GLFW_DONT_CARE ? (maxH + borderHeight) : GLFW_DONT_CARE);
|
||||
|
||||
if (!ret) {
|
||||
dprintf("Setting window limits failed\n");
|
||||
|
Loading…
Reference in New Issue
Block a user