Separated window and framebuffer sizes.

This commit is contained in:
Camilla Berglund
2013-06-03 12:51:57 +02:00
parent 89588a4508
commit 3498163da1
26 changed files with 197 additions and 58 deletions
+20 -3
View File
@@ -111,9 +111,11 @@ static void centerCursor(_GLFWwindow *window)
{
[window->nsgl.context update];
int width, height;
_glfwPlatformGetWindowSize(window, &width, &height);
_glfwInputWindowSize(window, width, height);
const NSRect contentRect = [window->ns.view frame];
const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect];
_glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
_glfwInputWindowSize(window, contentRect.size.width, contentRect.size.height);
_glfwInputWindowDamage(window);
if (window->cursorMode == GLFW_CURSOR_DISABLED)
@@ -515,6 +517,14 @@ static int convertMacKeyCode(unsigned int macKeyCode)
_glfwInputCursorEnter(window, GL_TRUE);
}
- (void)viewDidChangeBackingProperties
{
const NSRect contentRect = [window->ns.view frame];
const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect];
_glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
}
- (void)updateTrackingAreas
{
if (trackingArea != nil)
@@ -804,6 +814,8 @@ static GLboolean createWindow(_GLFWwindow* window,
window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window];
[window->ns.view setWantsBestResolutionOpenGLSurface:YES];
[window->ns.object setTitle:[NSString stringWithUTF8String:wndconfig->title]];
[window->ns.object setContentView:window->ns.view];
[window->ns.object setDelegate:window->ns.delegate];
@@ -927,6 +939,11 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
[window->ns.object setContentSize:NSMakeSize(width, height)];
}
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
{
_glfwPlatformGetWindowSize(window, width, height);
}
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
{
if (window->monitor)
+26 -12
View File
@@ -216,18 +216,19 @@ struct _GLFWwindow
#endif
struct {
GLFWwindowposfun pos;
GLFWwindowsizefun size;
GLFWwindowclosefun close;
GLFWwindowrefreshfun refresh;
GLFWwindowfocusfun focus;
GLFWwindowiconifyfun iconify;
GLFWmousebuttonfun mouseButton;
GLFWcursorposfun cursorPos;
GLFWcursorenterfun cursorEnter;
GLFWscrollfun scroll;
GLFWkeyfun key;
GLFWcharfun character;
GLFWwindowposfun pos;
GLFWwindowsizefun size;
GLFWwindowclosefun close;
GLFWwindowrefreshfun refresh;
GLFWwindowfocusfun focus;
GLFWwindowiconifyfun iconify;
GLFWframebuffersizefun fbsize;
GLFWmousebuttonfun mouseButton;
GLFWcursorposfun cursorPos;
GLFWcursorenterfun cursorEnter;
GLFWscrollfun scroll;
GLFWkeyfun key;
GLFWcharfun character;
} callbacks;
// This is defined in the window API's platform.h
@@ -474,6 +475,11 @@ void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height);
*/
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height);
/*! @copydoc glfwGetFramebufferSize
* @ingroup platform
*/
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height);
/*! @copydoc glfwIconifyWindow
* @ingroup platform
*/
@@ -562,6 +568,14 @@ void _glfwInputWindowPos(_GLFWwindow* window, int xpos, int ypos);
*/
void _glfwInputWindowSize(_GLFWwindow* window, int width, int height);
/*! @brief Notifies shared code of a framebuffer resize event.
* @param[in] window The window that received the event.
* @param[in] width The new width, in pixels, of the framebuffer.
* @param[in] height The new height, in pixels, of the framebuffer.
* @ingroup event
*/
void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height);
/*! @brief Notifies shared code of a window iconification event.
* @param[in] window The window that received the event.
* @param[in] iconified `GL_TRUE` if the window was iconified, or `GL_FALSE`
+6
View File
@@ -645,6 +645,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
if (window->cursorMode == GLFW_CURSOR_DISABLED)
updateClipRect(window);
_glfwInputFramebufferSize(window, LOWORD(lParam), HIWORD(lParam));
_glfwInputWindowSize(window, LOWORD(lParam), HIWORD(lParam));
return 0;
}
@@ -991,6 +992,11 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
}
}
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
{
_glfwPlatformGetWindowSize(window, width, height);
}
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
{
ShowWindow(window->win32.handle, SW_MINIMIZE);
+28
View File
@@ -113,6 +113,12 @@ void _glfwInputWindowIconify(_GLFWwindow* window, int iconified)
window->callbacks.iconify((GLFWwindow*) window, iconified);
}
void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height)
{
if (window->callbacks.fbsize)
window->callbacks.fbsize((GLFWwindow*) window, width, height);
}
void _glfwInputWindowVisibility(_GLFWwindow* window, int visible)
{
window->visible = visible;
@@ -478,6 +484,15 @@ GLFWAPI void glfwSetWindowSize(GLFWwindow* handle, int width, int height)
_glfwPlatformSetWindowSize(window, width, height);
}
GLFWAPI void glfwGetFramebufferSize(GLFWwindow* handle, int* width, int* height)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFW_REQUIRE_INIT();
_glfwPlatformGetFramebufferSize(window, width, height);
}
GLFWAPI void glfwIconifyWindow(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
@@ -665,6 +680,19 @@ GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* handle,
return previous;
}
GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* handle,
GLFWframebuffersizefun cbfun)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
GLFWframebuffersizefun previous;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
previous = window->callbacks.fbsize;
window->callbacks.fbsize = cbfun;
return previous;
}
GLFWAPI void glfwPollEvents(void)
{
_GLFW_REQUIRE_INIT();
+9
View File
@@ -635,6 +635,10 @@ static void processEvent(XEvent *event)
case ConfigureNotify:
{
_glfwInputFramebufferSize(window,
event->xconfigure.width,
event->xconfigure.height);
_glfwInputWindowSize(window,
event->xconfigure.width,
event->xconfigure.height);
@@ -1021,6 +1025,11 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
XFlush(_glfw.x11.display);
}
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
{
_glfwPlatformGetWindowSize(window, width, height);
}
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
{
if (window->x11.overrideRedirect)