mirror of
https://github.com/glfw/glfw.git
synced 2025-06-07 16:24:57 +00:00
A lot of changes, fixes and implementations to keep in line with official branch
This commit is contained in:
parent
55fb33c689
commit
7547245298
3
.gitignore
vendored
3
.gitignore
vendored
@ -17,6 +17,7 @@ Release
|
||||
MinSizeRel
|
||||
RelWithDebInfo
|
||||
*.opensdf
|
||||
.vscode
|
||||
|
||||
# Xcode clutter
|
||||
GLFW.build
|
||||
@ -100,5 +101,3 @@ tests/title
|
||||
tests/triangle-vulkan
|
||||
tests/window
|
||||
tests/windows
|
||||
|
||||
.vscode
|
@ -236,10 +236,6 @@ extern "C" {
|
||||
#endif
|
||||
#include <OpenGL/gl.h>
|
||||
|
||||
#elif defined(__amigaos4__) && defined(GL4ES)
|
||||
|
||||
#include <GL4ES/gl.h>
|
||||
|
||||
#else /*__APPLE__*/
|
||||
|
||||
#include <GL/gl.h>
|
||||
@ -6434,4 +6430,3 @@ GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window
|
||||
#endif
|
||||
|
||||
#endif /* _glfw3_h_ */
|
||||
|
||||
|
@ -30,51 +30,23 @@
|
||||
#include "internal.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef GL4ES
|
||||
#include <proto/ogles2.h>
|
||||
#include <GLES2/gl2.h>
|
||||
#define GETPROCADDRESS getProcAddressGL
|
||||
#else
|
||||
extern void *aglGetProcAddress(const char *name);
|
||||
enum CreateContextTags {
|
||||
OGLES2_CCT_MIN=(1UL<<31),
|
||||
OGLES2_CCT_WINDOW,
|
||||
OGLES2_CCT_MODEID,
|
||||
OGLES2_CCT_DEPTH,
|
||||
OGLES2_CCT_STENCIL,
|
||||
OGLES2_CCT_VSYNC,
|
||||
OGLES2_CCT_SINGLE_GET_ERROR_MODE,
|
||||
OGLES2_CCT_GET_WIDTH,
|
||||
OGLES2_CCT_GET_HEIGHT,
|
||||
OGLES2_CCT_BITMAP,
|
||||
OGLES2_CCT_SHADER_COMPAT_PATCH,
|
||||
OGLES2_CCT_CONTEXT_FOR_MODEID,
|
||||
OGLES2_CCT_RESIZE_VIEWPORT,
|
||||
OGLES2_CCT_DEBUG_SHADER_LOG,
|
||||
OGLES2_CCT_SPIRV_OPLINES,
|
||||
OGLES2_CCT_SPIRV_OPLINES_OFFSET,
|
||||
OGLES2_CCT_SPIRV_OPTIMIZE,
|
||||
OGLES2_CCT_SHARE_WITH,
|
||||
};
|
||||
typedef int GLint;
|
||||
typedef int GLsizei;
|
||||
|
||||
extern void aglMakeCurrent(void* context);
|
||||
extern void aglSetParams2(struct TagItem * tags);
|
||||
extern void aglDestroyContext(void* context);
|
||||
extern void aglMakeCurrent(void* context);
|
||||
extern void aglSwapBuffers();
|
||||
extern void glFinish();
|
||||
extern void glViewport(GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
extern void *aglCreateContext2(ULONG * errcode, struct TagItem * tags);
|
||||
extern void *gl4es_aglGetProcAddress(const char *name);
|
||||
extern void gl4es_glXSwapInterval(int interval);
|
||||
#define GETPROCADDRESS gl4es_aglGetProcAddress
|
||||
|
||||
extern struct OGLES2IFace *IOGLES2;
|
||||
#ifndef OGLES2_OGLES2_DEFS_H
|
||||
// it would be better to have an include with only the CreateContextTags enum difed, to avoid conflict
|
||||
// of other typedef with full OpenGL header file...
|
||||
#include <ogles2/ogles2_defs.h>
|
||||
#endif
|
||||
|
||||
void* aglCreateContext2(ULONG * errcode, struct TagItem * tags);
|
||||
void aglDestroyContext(void* context);
|
||||
void aglMakeCurrent(void* context);
|
||||
void aglSwapBuffers();
|
||||
void aglSetBitmap(struct BitMap *bitmap);
|
||||
void aglSetParams2(struct TagItem * tags);
|
||||
void* aglGetProcAddress(const char* name);
|
||||
#define GETPROCADDRESS aglGetProcAddress
|
||||
|
||||
static void makeContextCurrentGL(_GLFWwindow* window)
|
||||
{
|
||||
if (window)
|
||||
@ -97,13 +69,18 @@ static void swapBuffersGL(_GLFWwindow* window)
|
||||
// First flush the render pipeline, so that everything gets drawn
|
||||
glFinish();
|
||||
|
||||
if (window->context.gl.vsyncEnabled) {
|
||||
IGraphics->WaitTOF();
|
||||
}
|
||||
|
||||
// Swap the buffers (if any)
|
||||
aglSwapBuffers();
|
||||
}
|
||||
|
||||
static GLFWglproc getProcAddressGL(const char* procname)
|
||||
{
|
||||
const GLFWglproc proc = (GLFWglproc) aglGetProcAddress(procname);
|
||||
dprintf("Searching for %s\n", procname);
|
||||
const GLFWglproc proc = (GLFWglproc) GETPROCADDRESS(procname);
|
||||
return proc;
|
||||
}
|
||||
|
||||
@ -115,7 +92,16 @@ static int extensionSupportedGL(const char* extension)
|
||||
|
||||
static void swapIntervalGL(int interval)
|
||||
{
|
||||
// TODO - Should we implement this?
|
||||
_GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
|
||||
|
||||
switch (interval) {
|
||||
case 0:
|
||||
case 1:
|
||||
window->context.gl.vsyncEnabled = interval ? TRUE : FALSE;
|
||||
dprintf("VSYNC %d\n", interval);
|
||||
default:
|
||||
dprintf("Unsupported interval %d\n", interval);
|
||||
}
|
||||
}
|
||||
|
||||
// Create the OpenGL or OpenGL ES context
|
||||
@ -151,7 +137,8 @@ GLFWbool _glfwCreateContextGL(_GLFWwindow* window,
|
||||
{OGLES2_CCT_STENCIL, fbconfig->stencilBits},
|
||||
{OGLES2_CCT_VSYNC, 0},
|
||||
{OGLES2_CCT_RESIZE_VIEWPORT, TRUE},
|
||||
{OGLES2_CCT_SHARE_WITH, sharedContext},
|
||||
{OGLES2_CCT_SINGLE_GET_ERROR_MODE, 1},
|
||||
{OGLES2_CCT_SHARE_WITH, (ULONG)sharedContext},
|
||||
{TAG_DONE, 0}
|
||||
};
|
||||
|
||||
@ -160,7 +147,21 @@ GLFWbool _glfwCreateContextGL(_GLFWwindow* window,
|
||||
|
||||
/* Set the context as current */
|
||||
if (window->context.gl.glContext) {
|
||||
window->context.client = GLFW_OPENGL_ES_API;
|
||||
|
||||
dprintf("GL Extensions: %s\n", glGetString(GL_EXTENSIONS));
|
||||
aglMakeCurrent(window->context.gl.glContext);
|
||||
|
||||
// Some games (like q3) doesn't clear the z-buffer prior to use. Since we're using a floating-point depth buffer in warp3dnova,
|
||||
// that means it may contain illegal floating-point values, which causes some pixels to fail the depth-test when they shouldn't,
|
||||
// so we clear the depth buffer to a constant value when it's first created.
|
||||
// Pandora may well use an integer depth-buffer, in which case this can't happen.
|
||||
// On MiniGL it didn't happens as there is workaround inside of old warp3d (and probabaly inside of MiniGL itself too).
|
||||
// in SDL1 with gl4es (so warp3dnova/ogles2, where no such workaround) it didn't happens probabaly because SDL1 doing something like that (but not glClear).
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glViewport(0, 0, window->os4.width, window->os4.height);
|
||||
}
|
||||
else {
|
||||
IIntuition->CloseWindow(window->os4.handle);
|
||||
@ -173,7 +174,7 @@ GLFWbool _glfwCreateContextGL(_GLFWwindow* window,
|
||||
window->context.swapBuffers = swapBuffersGL;
|
||||
window->context.swapInterval = swapIntervalGL;
|
||||
window->context.extensionSupported = extensionSupportedGL;
|
||||
window->context.getProcAddress = GETPROCADDRESS;
|
||||
window->context.getProcAddress = getProcAddressGL;
|
||||
window->context.destroy = destroyContextGL;
|
||||
|
||||
return GLFW_TRUE;
|
||||
|
@ -60,13 +60,6 @@ struct Library *IconBase = NULL;
|
||||
struct WorkbenchIFace *IWorkbench = NULL;
|
||||
struct Library *WorkbenchBase = NULL;
|
||||
|
||||
#ifndef GL4ES
|
||||
struct Library *OGLES2Base = NULL;
|
||||
struct OGLES2IFace *IOGLES2 = NULL;
|
||||
#else
|
||||
extern struct OGLES2IFace *IOGLES2;
|
||||
#endif
|
||||
|
||||
#define MIN_LIB_VERSION 51
|
||||
|
||||
static void OS4_FindApplicationName();
|
||||
@ -184,14 +177,6 @@ static int loadLibraries(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef GL4ES
|
||||
OGLES2Base = openLib("ogles2.library", MIN_OGLES2_VERSION, (struct Interface **)&IOGLES2);
|
||||
if (!OGLES2Base)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
// AmigaInput
|
||||
AIN_Base = openLib("AmigaInput.library", MIN_LIB_VERSION, (struct Interface **)&IAIN);
|
||||
if (!AIN_Base)
|
||||
@ -228,17 +213,6 @@ static void closeLibraries(void)
|
||||
IExec->CloseLibrary(AIN_Base);
|
||||
}
|
||||
|
||||
#ifndef GL4ES
|
||||
if (IOGLES2)
|
||||
{
|
||||
IExec->DropInterface((struct Interface *)IOGLES2);
|
||||
}
|
||||
if (OGLES2Base)
|
||||
{
|
||||
IExec->CloseLibrary(OGLES2Base);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Close workbench.library
|
||||
if (IWorkbench)
|
||||
{
|
||||
@ -571,9 +545,9 @@ OS4_FindApplicationName()
|
||||
char pathBuffer[MAXPATHLEN];
|
||||
|
||||
if (IDOS->GetCliProgramName(pathBuffer, MAXPATHLEN - 1)) {
|
||||
printf("GetCliProgramName: '%s'\n", pathBuffer);
|
||||
dprintf("GetCliProgramName: '%s'\n", pathBuffer);
|
||||
} else {
|
||||
printf("Failed to get CLI program name, checking task node\n");
|
||||
dprintf("Failed to get CLI program name, checking task node\n");
|
||||
|
||||
struct Task* me = IExec->FindTask(NULL);
|
||||
snprintf(pathBuffer, MAXPATHLEN, "%s", ((struct Node *)me)->ln_Name);
|
||||
@ -587,5 +561,5 @@ OS4_FindApplicationName()
|
||||
snprintf(_glfw.os4.appName, size, pathBuffer);
|
||||
}
|
||||
|
||||
printf("Application name: '%s'\n", _glfw.os4.appName);
|
||||
dprintf("Application name: '%s'\n", _glfw.os4.appName);
|
||||
}
|
@ -196,7 +196,7 @@ AMIGAINPUT_Open(_GLFWjoystick * joysticks, int device_index)
|
||||
if (result) {
|
||||
char guid[33];
|
||||
// Generate a joystick GUID that matches the SDL 2.0.5+ one
|
||||
sprintf(guid, "78696e707574%02x000000000000000000", handle->DeviceID & 0xff);
|
||||
sprintf(guid, "78696e707574%02lx000000000000000000", handle->DeviceID & 0xff);
|
||||
_glfwAllocJoystick(joystick->name, guid, joystick->axisCount, joystick->buttonCount, joystick->hatCount);
|
||||
|
||||
printf("Successful\n");
|
||||
@ -257,7 +257,7 @@ AMIGAINPUT_EnumerateJoysticks(AIN_Device *device, void *UserData)
|
||||
joy->id = device->DeviceID;
|
||||
joy->name = _glfw_strdup(device->DeviceName);
|
||||
|
||||
printf("Found joystick #%d (AI ID=%ld) '%s'\n", *count, joy->id, joy->name);
|
||||
printf("Found joystick #%ld (AI ID=%ld) '%s'\n", *count, joy->id, joy->name);
|
||||
|
||||
(*count)++;
|
||||
|
||||
@ -313,7 +313,7 @@ GLFWbool _glfwInitJoysticksOS4(void)
|
||||
BOOL result = GLFW_IAIN->EnumDevices(_glfw.os4js.joystickContext, AMIGAINPUT_EnumerateJoysticks, &packet);
|
||||
#endif
|
||||
printf("EnumDevices returned %d\n", result);
|
||||
printf("Found %d joysticks\n", _glfw.os4js.joystickCount);
|
||||
printf("Found %ld joysticks\n", _glfw.os4js.joystickCount);
|
||||
|
||||
if (result) {
|
||||
/*
|
||||
|
@ -116,10 +116,33 @@ void _glfwPollMonitorsOS4(void)
|
||||
{
|
||||
const float dpi = 141.f;
|
||||
const GLFWvidmode mode = getVideoMode();
|
||||
_GLFWmonitor* monitor = _glfwAllocMonitor("OS4 Monitor 0",
|
||||
(int) (mode.width * 25.4f / dpi),
|
||||
(int) (mode.height * 25.4f / dpi));
|
||||
_glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_FIRST);
|
||||
struct DimensionInfo diminfo;
|
||||
APTR handle;
|
||||
ULONG modeid;
|
||||
|
||||
IIntuition->GetScreenAttrs(_glfw.os4.publicScreen, SA_DisplayID, &modeid, TAG_DONE);
|
||||
|
||||
handle = IGraphics->FindDisplayInfo(modeid);
|
||||
if (handle) {
|
||||
if (IGraphics->GetDisplayInfoData(handle, (UBYTE *)&diminfo, sizeof(diminfo), DTAG_DIMS, 0)) {
|
||||
GLFW_DisplayModeData *data;
|
||||
data = (GLFW_DisplayModeData *) malloc(sizeof(*data));
|
||||
if (data) {
|
||||
data->modeid = modeid;
|
||||
data->x = diminfo.Nominal.MinX;
|
||||
data->y = diminfo.Nominal.MinY;
|
||||
data->depth = diminfo.MaxDepth;
|
||||
|
||||
_GLFWmonitor* monitor = _glfwAllocMonitor("OS4 Monitor 0",
|
||||
(int) (mode.width * 25.4f / dpi),
|
||||
(int) (mode.height * 25.4f / dpi));
|
||||
|
||||
monitor->userPointer = data;
|
||||
|
||||
_glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_FIRST);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -128,6 +151,9 @@ void _glfwPollMonitorsOS4(void)
|
||||
|
||||
void _glfwFreeMonitorOS4(_GLFWmonitor* monitor)
|
||||
{
|
||||
if (monitor->userPointer)
|
||||
free(monitor->userPointer);
|
||||
|
||||
_glfwFreeGammaArrays(&monitor->os4.ramp);
|
||||
}
|
||||
|
||||
|
@ -62,12 +62,6 @@
|
||||
#include <amigainput/amigainput.h>
|
||||
#include <proto/amigainput.h>
|
||||
|
||||
/* GL Stuff */
|
||||
#ifndef GL4ES
|
||||
#include <proto/ogles2.h>
|
||||
#include <proto/minigl.h>
|
||||
#endif
|
||||
|
||||
#include "os4_joystick.h"
|
||||
|
||||
#define MIN_MINIGLVERSION 2
|
||||
@ -106,39 +100,51 @@ struct MyIntuiMessage
|
||||
int16 Height;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
ULONG modeid;
|
||||
long depth;
|
||||
LONG x;
|
||||
LONG y;
|
||||
} GLFW_DisplayModeData;
|
||||
|
||||
// OS4-specific per-window data
|
||||
//
|
||||
typedef struct _GLFWwindowOS4
|
||||
{
|
||||
struct Window *handle;
|
||||
int xpos;
|
||||
int ypos;
|
||||
int lastCursorPosX;
|
||||
int lastCursorPosY;
|
||||
int width;
|
||||
int height;
|
||||
char *title;
|
||||
GLFWbool visible;
|
||||
GLFWbool iconified;
|
||||
GLFWbool maximized;
|
||||
GLFWbool resizable;
|
||||
GLFWbool decorated;
|
||||
GLFWbool floating;
|
||||
GLFWbool transparent;
|
||||
float opacity;
|
||||
int windowType; // NORMAL - GL - GLES
|
||||
struct Window *handle;
|
||||
int xpos;
|
||||
int ypos;
|
||||
int oldxpos;
|
||||
int oldypos;
|
||||
int lastCursorPosX;
|
||||
int lastCursorPosY;
|
||||
int width;
|
||||
int height;
|
||||
char *title;
|
||||
GLFWbool visible;
|
||||
GLFWbool iconified;
|
||||
GLFWbool maximized;
|
||||
GLFWbool resizable;
|
||||
GLFWbool decorated;
|
||||
GLFWbool floating;
|
||||
GLFWbool transparent;
|
||||
GLFWbool fullscreen;
|
||||
float opacity;
|
||||
int windowType; // NORMAL - GL - GLES
|
||||
|
||||
struct AppIcon *appIcon;
|
||||
struct AppIcon *appIcon;
|
||||
struct AppWindow *appWin;
|
||||
struct Screen *screen;
|
||||
|
||||
struct Gadget *gadget;
|
||||
struct Image *image;
|
||||
struct Gadget *gadget;
|
||||
struct Image *image;
|
||||
|
||||
} _GLFWwindowOS4;
|
||||
|
||||
typedef struct _GLFWcontextGL {
|
||||
struct BitMap *bm;
|
||||
void* glContext;
|
||||
BOOL vsyncEnabled;
|
||||
} _GLFWcontextGL;
|
||||
|
||||
// OS4-specific per-monitor data
|
||||
|
289
src/os4_window.c
289
src/os4_window.c
@ -32,6 +32,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <proto/intuition.h>
|
||||
#include <intuition/pointerclass.h>
|
||||
@ -45,7 +46,7 @@ static int OS4_GetButtonState(uint16_t code);
|
||||
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 uint32_t OS4_GetWindowFlags(_GLFWwindow* window, GLFWbool fullscreen);
|
||||
static void OS4_SetWindowLimits(_GLFWwindow * window);
|
||||
static void OS4_CreateIconifyGadget(_GLFWwindow * window);
|
||||
static struct DiskObject *OS4_GetDiskObject();
|
||||
@ -67,6 +68,148 @@ static struct Hook OS4_BackFillHook = {
|
||||
0, /* h_SubEntry */
|
||||
0 /* h_Data */
|
||||
};
|
||||
static void
|
||||
OS4_GetWindowSize(struct Window * window, int * width, int * height)
|
||||
{
|
||||
LONG ret = IIntuition->GetWindowAttrs(
|
||||
window,
|
||||
WA_InnerWidth, width,
|
||||
WA_InnerHeight, height,
|
||||
TAG_DONE);
|
||||
|
||||
if (ret) {
|
||||
dprintf("GetWindowAttrs() returned %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
OS4_WaitForResize(_GLFWwindow* window, int * width, int * height)
|
||||
{
|
||||
int counter = 0;
|
||||
int activeWidth, activeHeight;
|
||||
int w = 0;
|
||||
int h = 0;
|
||||
|
||||
_glfwGetWindowSizeOS4(window, &activeWidth, &activeHeight);
|
||||
|
||||
while (counter++ < 100) {
|
||||
OS4_GetWindowSize(window->os4.handle, &w, &h);
|
||||
|
||||
if (w == activeWidth && h == activeHeight) {
|
||||
break;
|
||||
}
|
||||
|
||||
dprintf("Waiting for Intuition %d\n", counter);
|
||||
dprintf("System window size (%d * %d), GLFW window size (%d * %d)\n", w, h, activeWidth, activeHeight);
|
||||
usleep(1000);
|
||||
}
|
||||
|
||||
if (width) {
|
||||
*width = w;
|
||||
}
|
||||
|
||||
if (height) {
|
||||
*height = h;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
OS4_ResizeWindow(_GLFWwindow* window, int width, int height, int posx, int posy)
|
||||
{
|
||||
if (width > 0 && height > 0) {
|
||||
LONG ret = IIntuition->SetWindowAttrs(window->os4.handle,
|
||||
WA_InnerWidth, width,
|
||||
WA_InnerHeight, height,
|
||||
WA_Left, posx,
|
||||
WA_Top, posy,
|
||||
TAG_DONE);
|
||||
|
||||
if (ret) {
|
||||
dprintf("SetWindowAttrs() returned %d\n", ret);
|
||||
}
|
||||
|
||||
OS4_WaitForResize(window, NULL, NULL);
|
||||
#if 0
|
||||
if (window->os4.glwindow->context.gl.glContext) {
|
||||
OS4_ResizeGlContext(window);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
dprintf("Invalid width %d or height %d\n", width, height);
|
||||
}
|
||||
}
|
||||
|
||||
static uint32
|
||||
OS4_GetIDCMPFlags(_GLFWwindow* window, GLFWbool fullscreen)
|
||||
{
|
||||
uint32 IDCMPFlags = IDCMP_MOUSEBUTTONS | IDCMP_MOUSEMOVE
|
||||
| IDCMP_DELTAMOVE | IDCMP_RAWKEY | IDCMP_ACTIVEWINDOW
|
||||
| IDCMP_INACTIVEWINDOW | IDCMP_INTUITICKS
|
||||
| IDCMP_EXTENDEDMOUSE;
|
||||
|
||||
dprintf("Called\n");
|
||||
|
||||
if (!fullscreen) {
|
||||
if (window->decorated) {
|
||||
IDCMPFlags |= IDCMP_CLOSEWINDOW | IDCMP_GADGETUP | IDCMP_CHANGEWINDOW;
|
||||
}
|
||||
|
||||
if (window->resizable) {
|
||||
//IDCMPFlags |= IDCMP_SIZEVERIFY; no handling so far
|
||||
IDCMPFlags |= IDCMP_NEWSIZE;
|
||||
}
|
||||
}
|
||||
|
||||
return IDCMPFlags;
|
||||
}
|
||||
|
||||
static struct Screen *
|
||||
OS4_GetScreenForWindow(_GLFWwindow* window)
|
||||
{
|
||||
if (window->os4.screen) {
|
||||
dprintf("Fullscreen\n");
|
||||
return window->os4.screen;
|
||||
} else {
|
||||
dprintf("Window mode (public screen)\n");
|
||||
return _glfw.os4.publicScreen;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
OS4_DefineWindowBox(_GLFWwindow* window, const _GLFWwndconfig *wndconfig, struct Screen * screen, GLFWbool fullscreen, struct IBox *box)
|
||||
{
|
||||
if (fullscreen && screen) {
|
||||
box->Left = 0;
|
||||
box->Top = 0;
|
||||
box->Width = screen->Width;
|
||||
box->Height = screen->Height;
|
||||
} else {
|
||||
box->Left = wndconfig->xpos;
|
||||
box->Top = wndconfig->ypos;
|
||||
box->Width = wndconfig->width;
|
||||
box->Height = wndconfig->height;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
OS4_CloseScreen(struct Screen* screen)
|
||||
{
|
||||
if (screen) {
|
||||
if (screen != _glfw.os4.publicScreen) {
|
||||
dprintf("Closing screen %p\n", screen);
|
||||
|
||||
if (IIntuition->CloseScreen(screen) == FALSE) {
|
||||
dprintf("Screen has open window(s), cannot close\n");
|
||||
} else {
|
||||
dprintf("Screen closed successfully\n");
|
||||
}
|
||||
} else {
|
||||
dprintf("Public screen, not closing\n");
|
||||
}
|
||||
} else {
|
||||
dprintf("NULL pointer\n");
|
||||
}
|
||||
}
|
||||
|
||||
static ULONG
|
||||
OS4_MapCursorIdToNative(int id)
|
||||
@ -150,34 +293,24 @@ static void enableCursor(_GLFWwindow* window)
|
||||
_glfw.os4.disabledCursorWindow = NULL;
|
||||
}
|
||||
|
||||
// Returns whether the cursor is in the content area of the specified window
|
||||
//
|
||||
static GLFWbool cursorInContentArea(_GLFWwindow* window)
|
||||
{
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
// Updates the cursor image according to its cursor mode
|
||||
//
|
||||
static void updateCursorImage(_GLFWwindow* window)
|
||||
static void updateCursorImage(_GLFWwindow* window, int shape)
|
||||
{
|
||||
if (window->cursorMode == GLFW_CURSOR_NORMAL)
|
||||
{
|
||||
if (window->cursor) {
|
||||
IIntuition->SetWindowPointer(
|
||||
window->os4.handle,
|
||||
WA_Pointer, window->cursor->os4.handle,
|
||||
TAG_DONE);
|
||||
}
|
||||
else {
|
||||
IIntuition->SetWindowPointer(
|
||||
window->os4.handle,
|
||||
//WA_PointerType, type,
|
||||
TAG_DONE);
|
||||
}
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
if (shape < 0 && window->cursor && window->cursor->os4.handle) {
|
||||
IIntuition->SetWindowPointer(
|
||||
window->os4.handle,
|
||||
WA_Pointer, window->cursor->os4.handle,
|
||||
TAG_DONE);
|
||||
}
|
||||
else {
|
||||
//SetCursor(NULL);
|
||||
else if (shape >= 0) {
|
||||
IIntuition->SetWindowPointer(
|
||||
window->os4.handle,
|
||||
WA_PointerType, shape,
|
||||
TAG_DONE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,12 +319,28 @@ static int createNativeWindow(_GLFWwindow* window,
|
||||
const _GLFWfbconfig* fbconfig,
|
||||
int windowType)
|
||||
{
|
||||
window->autoIconify = GLFW_FALSE;
|
||||
if (window->monitor) {
|
||||
GLFW_DisplayModeData *data = (GLFW_DisplayModeData *) window->monitor->userPointer;
|
||||
|
||||
IIntuition->OpenScreenTags(NULL,
|
||||
SA_Width, window->monitor->currentMode.width,
|
||||
SA_Height, window->monitor->currentMode.height,
|
||||
SA_Depth, data->depth,
|
||||
SA_DisplayID, data->modeid,
|
||||
SA_Quiet, TRUE,
|
||||
SA_Title, wndconfig->title,
|
||||
SA_ShowTitle, FALSE,
|
||||
SA_LikeWorkbench, TRUE,
|
||||
SA_Compositing, FALSE,
|
||||
TAG_DONE);
|
||||
dprintf("fitToMonitor\n");
|
||||
fitToMonitor(window);
|
||||
window->os4.fullscreen = GLFW_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
window->os4.fullscreen = GLFW_FALSE;
|
||||
window->os4.xpos = 17;
|
||||
window->os4.ypos = 17;
|
||||
window->os4.width = wndconfig->width;
|
||||
@ -209,33 +358,29 @@ static int createNativeWindow(_GLFWwindow* window,
|
||||
window->os4.opacity = 1.f;
|
||||
|
||||
window->os4.windowType = windowType;
|
||||
uint32_t windowFlags = OS4_GetWindowFlags(window, FALSE);
|
||||
uint32_t windowFlags = OS4_GetWindowFlags(window, window->os4.fullscreen);
|
||||
uint32 IDCMPFlags = OS4_GetIDCMPFlags(window, window->os4.fullscreen);
|
||||
|
||||
struct Screen *screen = OS4_GetScreenForWindow(window);
|
||||
|
||||
OS4_BackFillHook.h_Data = IGraphics; // Smuggle interface ptr for the hook
|
||||
|
||||
struct IBox box;
|
||||
OS4_DefineWindowBox(window, wndconfig, screen, window->os4.fullscreen, &box);
|
||||
|
||||
window->os4.handle = IIntuition->OpenWindowTags(NULL,
|
||||
WA_Left, window->os4.xpos,
|
||||
WA_Top, window->os4.ypos,
|
||||
WA_InnerWidth, wndconfig->width,
|
||||
WA_InnerHeight, wndconfig->height,
|
||||
WA_Title, wndconfig->title,
|
||||
WA_PubScreen, screen,
|
||||
WA_Left, box.Left,
|
||||
WA_Top, box.Top,
|
||||
WA_InnerWidth, box.Width,
|
||||
WA_InnerHeight, box.Height,
|
||||
WA_Title, window->os4.fullscreen ? NULL: wndconfig->title,
|
||||
WA_ScreenTitle, wndconfig->title,
|
||||
WA_MaxWidth, _glfw.os4.publicScreen->Width,
|
||||
WA_MaxHeight, _glfw.os4.publicScreen->Height,
|
||||
WA_Flags, windowFlags,
|
||||
WA_Activate, TRUE,
|
||||
WA_IDCMP, IDCMP_CLOSEWINDOW |
|
||||
IDCMP_MOUSEMOVE |
|
||||
IDCMP_MOUSEBUTTONS |
|
||||
IDCMP_EXTENDEDMOUSE |
|
||||
IDCMP_RAWKEY |
|
||||
IDCMP_NEWSIZE |
|
||||
IDCMP_DELTAMOVE |
|
||||
IDCMP_ACTIVEWINDOW |
|
||||
IDCMP_INACTIVEWINDOW |
|
||||
IDCMP_INTUITICKS |
|
||||
IDCMP_GADGETUP |
|
||||
IDCMP_CHANGEWINDOW,
|
||||
WA_IDCMP, IDCMPFlags,
|
||||
WA_Hidden, !wndconfig->visible,
|
||||
WA_UserPort, _glfw.os4.userPort,
|
||||
WA_BackFill, &OS4_BackFillHook,
|
||||
@ -244,20 +389,21 @@ static int createNativeWindow(_GLFWwindow* window,
|
||||
/* If we have a valid handle return GLFW_TRUE */
|
||||
if (window->os4.handle) {
|
||||
window->os4.title = (char *) wndconfig->title;
|
||||
window->maxwidth = _glfw.os4.publicScreen->Width;
|
||||
window->maxheight = _glfw.os4.publicScreen->Height;
|
||||
|
||||
_glfwGetWindowPosOS4(window, &window->os4.xpos, &window->os4.ypos);
|
||||
_glfwGetWindowSizeOS4(window, &window->os4.width, &window->os4.height);
|
||||
window->os4.lastCursorPosX = window->os4.xpos;
|
||||
window->os4.lastCursorPosY = window->os4.ypos;
|
||||
|
||||
if (wndconfig->decorated && wndconfig->width > 99 && wndconfig->height) {
|
||||
if (wndconfig->decorated && wndconfig->width > 99 && wndconfig->height ) {
|
||||
OS4_CreateIconifyGadget(window);
|
||||
}
|
||||
window->os4.appWin = IWorkbench->AddAppWindow(0, (ULONG)window, window->os4.handle, _glfw.os4.appMsgPort, TAG_DONE);
|
||||
|
||||
if (wndconfig->autoIconify) {
|
||||
OS4_IconifyWindow(window);
|
||||
}
|
||||
_glfwWindowFocusedOS4(window);
|
||||
|
||||
dprintf("Window Created\n");
|
||||
|
||||
return GLFW_TRUE;
|
||||
@ -290,6 +436,10 @@ int _glfwCreateWindowOS4(_GLFWwindow* window,
|
||||
dprintf("Error creating context\n");
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
if (!_glfwRefreshContextAttribs(window, ctxconfig))
|
||||
return GLFW_FALSE;
|
||||
|
||||
dprintf("Context created\n");
|
||||
}
|
||||
|
||||
@ -319,8 +469,12 @@ void _glfwDestroyWindowOS4(_GLFWwindow* window)
|
||||
if (window->context.destroy)
|
||||
window->context.destroy(window);
|
||||
|
||||
struct Screen *screen = window->os4.handle->WScreen;
|
||||
|
||||
IIntuition->CloseWindow(window->os4.handle);
|
||||
|
||||
OS4_CloseScreen(screen);
|
||||
|
||||
if (window->os4.gadget) {
|
||||
IIntuition->DisposeObject((Object *)window->os4.gadget);
|
||||
window->os4.gadget = NULL;
|
||||
@ -503,14 +657,19 @@ void _glfwGetWindowContentScaleOS4(_GLFWwindow* window, float* xscale, float* ys
|
||||
|
||||
void _glfwIconifyWindowOS4(_GLFWwindow* window)
|
||||
{
|
||||
printf("_glfwIconifyWindowOS4\n");
|
||||
if (_glfw.os4.focusedWindow == window)
|
||||
{
|
||||
printf("_glfwIconifyWindowOS4 1\n");
|
||||
_glfw.os4.focusedWindow = NULL;
|
||||
_glfwInputWindowFocus(window, GLFW_FALSE);
|
||||
}
|
||||
|
||||
if (!window->os4.iconified)
|
||||
{
|
||||
OS4_IconifyWindow(window);
|
||||
|
||||
printf("_glfwIconifyWindowOS4 2\n");
|
||||
window->os4.iconified = GLFW_TRUE;
|
||||
_glfwInputWindowIconify(window, GLFW_TRUE);
|
||||
|
||||
@ -523,6 +682,8 @@ void _glfwRestoreWindowOS4(_GLFWwindow* window)
|
||||
{
|
||||
if (window->os4.iconified)
|
||||
{
|
||||
OS4_UniconifyWindow(window);
|
||||
|
||||
window->os4.iconified = GLFW_FALSE;
|
||||
_glfwInputWindowIconify(window, GLFW_FALSE);
|
||||
|
||||
@ -531,6 +692,7 @@ void _glfwRestoreWindowOS4(_GLFWwindow* window)
|
||||
}
|
||||
else if (window->os4.maximized)
|
||||
{
|
||||
OS4_ResizeWindow(window, window->os4.width, window->os4.height, window->os4.oldxpos, window->os4.oldypos);
|
||||
window->os4.maximized = GLFW_FALSE;
|
||||
_glfwInputWindowMaximize(window, GLFW_FALSE);
|
||||
}
|
||||
@ -540,6 +702,11 @@ void _glfwMaximizeWindowOS4(_GLFWwindow* window)
|
||||
{
|
||||
if (!window->os4.maximized)
|
||||
{
|
||||
window->os4.oldxpos = window->os4.xpos;
|
||||
window->os4.oldypos = window->os4.ypos;
|
||||
|
||||
OS4_ResizeWindow(window, window->maxwidth, window->maxheight, 0, 0);
|
||||
|
||||
window->os4.maximized = GLFW_TRUE;
|
||||
_glfwInputWindowMaximize(window, GLFW_TRUE);
|
||||
}
|
||||
@ -646,7 +813,7 @@ void _glfwFocusWindowOS4(_GLFWwindow* window)
|
||||
if (previous)
|
||||
{
|
||||
_glfwInputWindowFocus(previous, GLFW_FALSE);
|
||||
if (previous->monitor && previous->autoIconify)
|
||||
if (!previous->monitor && previous->autoIconify)
|
||||
_glfwIconifyWindowOS4(previous);
|
||||
}
|
||||
|
||||
@ -765,7 +932,11 @@ void _glfwPollEventsOS4(void)
|
||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||
enableCursor(window);
|
||||
|
||||
if (!window->monitor && window->autoIconify) {
|
||||
OS4_IconifyWindow(window);
|
||||
}
|
||||
_glfwInputWindowFocus(window, GLFW_FALSE);
|
||||
|
||||
break;
|
||||
|
||||
case IDCMP_CLOSEWINDOW:
|
||||
@ -844,8 +1015,8 @@ void _glfwSetCursorModeOS4(_GLFWwindow* window, int mode)
|
||||
}
|
||||
else if (_glfw.os4.disabledCursorWindow == window)
|
||||
enableCursor(window);
|
||||
else if (cursorInContentArea(window))
|
||||
updateCursorImage(window);
|
||||
else
|
||||
updateCursorImage(window, POINTERTYPE_NORMAL);
|
||||
}
|
||||
|
||||
int _glfwCreateCursorOS4(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot) {
|
||||
@ -880,11 +1051,14 @@ int _glfwCreateCursorOS4(_GLFWcursor* cursor, const GLFWimage* image, int xhot,
|
||||
|
||||
int _glfwCreateStandardCursorOS4(_GLFWcursor* cursor, int shape)
|
||||
{
|
||||
int id = OS4_MapCursorIdToNative(shape);
|
||||
printf("_glfwCreateStandardCursorOS4 %02x %d\n", shape, id);
|
||||
|
||||
//updateCursorImage
|
||||
return GLFW_TRUE;
|
||||
_GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
|
||||
if (window) {
|
||||
int id = OS4_MapCursorIdToNative(shape);
|
||||
printf("_glfwCreateStandardCursorOS4 %02x %d\n", shape, id);
|
||||
updateCursorImage(window, id);
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
void _glfwDestroyCursorOS4(_GLFWcursor* cursor)
|
||||
@ -901,6 +1075,7 @@ void _glfwDestroyCursorOS4(_GLFWcursor* cursor)
|
||||
void _glfwSetCursorOS4(_GLFWwindow* window, _GLFWcursor* cursor)
|
||||
{
|
||||
printf("_glfwSetCursorOS4\n");
|
||||
updateCursorImage(window, -1);
|
||||
}
|
||||
|
||||
void _glfwSetClipboardStringOS4(const char* string)
|
||||
@ -1150,7 +1325,7 @@ static int OS4_TranslateState(int state)
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
OS4_GetWindowFlags(_GLFWwindow* window, BOOL fullscreen)
|
||||
OS4_GetWindowFlags(_GLFWwindow* window, GLFWbool fullscreen)
|
||||
{
|
||||
uint32_t windowFlags = WFLG_ACTIVATE | WFLG_REPORTMOUSE | WFLG_RMBTRAP | WFLG_SMART_REFRESH | WFLG_NOCAREREFRESH;
|
||||
|
||||
@ -1309,10 +1484,10 @@ OS4_UniconifyWindow(_GLFWwindow* window)
|
||||
}
|
||||
IIntuition->SetWindowAttrs(window->os4.handle,
|
||||
WA_Hidden, FALSE,
|
||||
WA_Activate, TRUE,
|
||||
TAG_DONE);
|
||||
|
||||
window->os4.iconified = FALSE;
|
||||
//SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user