mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-23 02:38:52 -05:00
Separated window and framebuffer sizes.
This commit is contained in:
parent
89588a4508
commit
3498163da1
|
@ -280,6 +280,8 @@ GLFW.
|
||||||
compile time
|
compile time
|
||||||
* Added `glfwGetWindowMonitor` for querying the monitor, if any, of the
|
* Added `glfwGetWindowMonitor` for querying the monitor, if any, of the
|
||||||
specified window
|
specified window
|
||||||
|
* Added `glfwGetFramebufferSize` and `glfwSetFramebufferSizeCallback` for
|
||||||
|
receiving the current size, in pixels, of the framebuffer
|
||||||
* Added `glfwSetWindowPosCallback` and `GLFWwindowposfun` for receiving window
|
* Added `glfwSetWindowPosCallback` and `GLFWwindowposfun` for receiving window
|
||||||
position events
|
position events
|
||||||
* Added `glfwSetWindowFocusCallback` and `GLFWwindowfocusfun` for receiving
|
* Added `glfwSetWindowFocusCallback` and `GLFWwindowfocusfun` for receiving
|
||||||
|
@ -377,6 +379,7 @@ GLFW.
|
||||||
* Bugfix: Cursor centering upon leaving captured cursor mode was reported
|
* Bugfix: Cursor centering upon leaving captured cursor mode was reported
|
||||||
before the mode was changed to non-captured
|
before the mode was changed to non-captured
|
||||||
* [Cocoa] Added support for OpenGL 3.2 core profile in 10.7 Lion and above
|
* [Cocoa] Added support for OpenGL 3.2 core profile in 10.7 Lion and above
|
||||||
|
* [Cocoa] Added support for high-DPI (Retina) monitors
|
||||||
* [Cocoa] Added support for joysticks
|
* [Cocoa] Added support for joysticks
|
||||||
* [Cocoa] Postponed menu creation to first window creation
|
* [Cocoa] Postponed menu creation to first window creation
|
||||||
* [Cocoa] Replaced `NSDate` time source with `mach_absolute_time`
|
* [Cocoa] Replaced `NSDate` time source with `mach_absolute_time`
|
||||||
|
@ -413,6 +416,7 @@ GLFW.
|
||||||
mode was incorrectly removed
|
mode was incorrectly removed
|
||||||
* [X11] Bugfix: The window size hints were not updated when calling
|
* [X11] Bugfix: The window size hints were not updated when calling
|
||||||
`glfwSetWindowSize` on a non-resizable window
|
`glfwSetWindowSize` on a non-resizable window
|
||||||
|
* [Win32] Added support for high-DPI monitors
|
||||||
* [Win32] Changed port to use Unicode mode only
|
* [Win32] Changed port to use Unicode mode only
|
||||||
* [Win32] Removed explicit support for versions of Windows older than Windows
|
* [Win32] Removed explicit support for versions of Windows older than Windows
|
||||||
XP
|
XP
|
||||||
|
|
|
@ -589,13 +589,13 @@ int main( void )
|
||||||
exit( EXIT_FAILURE );
|
exit( EXIT_FAILURE );
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwSetWindowSizeCallback(window, reshape);
|
glfwSetFramebufferSizeCallback(window, reshape);
|
||||||
glfwSetKeyCallback(window, key_callback);
|
glfwSetKeyCallback(window, key_callback);
|
||||||
|
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
glfwSwapInterval( 1 );
|
glfwSwapInterval( 1 );
|
||||||
|
|
||||||
glfwGetWindowSize(window, &width, &height);
|
glfwGetFramebufferSize(window, &width, &height);
|
||||||
reshape(window, width, height);
|
reshape(window, width, height);
|
||||||
|
|
||||||
glfwSetTime( 0.0 );
|
glfwSetTime( 0.0 );
|
||||||
|
|
|
@ -337,13 +337,13 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set callback functions
|
// Set callback functions
|
||||||
glfwSetWindowSizeCallback(window, reshape);
|
glfwSetFramebufferSizeCallback(window, reshape);
|
||||||
glfwSetKeyCallback(window, key);
|
glfwSetKeyCallback(window, key);
|
||||||
|
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
glfwSwapInterval( 1 );
|
glfwSwapInterval( 1 );
|
||||||
|
|
||||||
glfwGetWindowSize(window, &width, &height);
|
glfwGetFramebufferSize(window, &width, &height);
|
||||||
reshape(window, width, height);
|
reshape(window, width, height);
|
||||||
|
|
||||||
// Parse command-line options
|
// Parse command-line options
|
||||||
|
|
|
@ -57,7 +57,7 @@ int main(void)
|
||||||
float ratio;
|
float ratio;
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|
||||||
glfwGetWindowSize(window, &width, &height);
|
glfwGetFramebufferSize(window, &width, &height);
|
||||||
ratio = width / (float) height;
|
ratio = width / (float) height;
|
||||||
|
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
|
|
|
@ -354,10 +354,10 @@ static void drawAllViews(void)
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Window size callback function
|
// Framebuffer size callback function
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
static void windowSizeFun(GLFWwindow* window, int w, int h)
|
static void framebufferSizeFun(GLFWwindow* window, int w, int h)
|
||||||
{
|
{
|
||||||
width = w;
|
width = w;
|
||||||
height = h > 0 ? h : 1;
|
height = h > 0 ? h : 1;
|
||||||
|
@ -467,7 +467,7 @@ int main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set callback functions
|
// Set callback functions
|
||||||
glfwSetWindowSizeCallback(window, windowSizeFun);
|
glfwSetFramebufferSizeCallback(window, framebufferSizeFun);
|
||||||
glfwSetWindowRefreshCallback(window, windowRefreshFun);
|
glfwSetWindowRefreshCallback(window, windowRefreshFun);
|
||||||
glfwSetCursorPosCallback(window, cursorPosFun);
|
glfwSetCursorPosCallback(window, cursorPosFun);
|
||||||
glfwSetMouseButtonCallback(window, mouseButtonFun);
|
glfwSetMouseButtonCallback(window, mouseButtonFun);
|
||||||
|
@ -477,8 +477,8 @@ int main(void)
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
|
|
||||||
glfwGetWindowSize(window, &width, &height);
|
glfwGetFramebufferSize(window, &width, &height);
|
||||||
windowSizeFun(window, width, height);
|
framebufferSizeFun(window, width, height);
|
||||||
|
|
||||||
// Main loop
|
// Main loop
|
||||||
for (;;)
|
for (;;)
|
||||||
|
|
|
@ -361,10 +361,10 @@ void scroll_callback(GLFWwindow* window, double x, double y)
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Callback function for window resize events
|
// Callback function for framebuffer resize events
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
void window_size_callback(GLFWwindow* window, int width, int height)
|
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||||
{
|
{
|
||||||
float ratio = 1.f;
|
float ratio = 1.f;
|
||||||
|
|
||||||
|
@ -404,7 +404,7 @@ int main(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwSetKeyCallback(window, key_callback);
|
glfwSetKeyCallback(window, key_callback);
|
||||||
glfwSetWindowSizeCallback(window, window_size_callback);
|
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
||||||
glfwSetMouseButtonCallback(window, mouse_button_callback);
|
glfwSetMouseButtonCallback(window, mouse_button_callback);
|
||||||
glfwSetCursorPosCallback(window, cursor_position_callback);
|
glfwSetCursorPosCallback(window, cursor_position_callback);
|
||||||
glfwSetScrollCallback(window, scroll_callback);
|
glfwSetScrollCallback(window, scroll_callback);
|
||||||
|
@ -412,8 +412,8 @@ int main(int argc, char* argv[])
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
|
|
||||||
glfwGetWindowSize(window, &width, &height);
|
glfwGetFramebufferSize(window, &width, &height);
|
||||||
window_size_callback(window, width, height);
|
framebuffer_size_callback(window, width, height);
|
||||||
|
|
||||||
// Initialize OpenGL
|
// Initialize OpenGL
|
||||||
init_opengl();
|
init_opengl();
|
||||||
|
|
|
@ -679,6 +679,21 @@ typedef void (* GLFWwindowfocusfun)(GLFWwindow*,int);
|
||||||
*/
|
*/
|
||||||
typedef void (* GLFWwindowiconifyfun)(GLFWwindow*,int);
|
typedef void (* GLFWwindowiconifyfun)(GLFWwindow*,int);
|
||||||
|
|
||||||
|
/*! @brief The function signature for framebuffer resize callbacks.
|
||||||
|
*
|
||||||
|
* This is the function signature for framebuffer resize callback
|
||||||
|
* functions.
|
||||||
|
*
|
||||||
|
* @param[in] window The window whose framebuffer was resized.
|
||||||
|
* @param[in] width The new width, in pixels, of the framebuffer.
|
||||||
|
* @param[in] height The new height, in pixels, of the framebuffer.
|
||||||
|
*
|
||||||
|
* @sa glfwSetFramebufferSizeCallback
|
||||||
|
*
|
||||||
|
* @ingroup window
|
||||||
|
*/
|
||||||
|
typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int);
|
||||||
|
|
||||||
/*! @brief The function signature for mouse button callbacks.
|
/*! @brief The function signature for mouse button callbacks.
|
||||||
*
|
*
|
||||||
* This is the function signature for mouse button callback functions.
|
* This is the function signature for mouse button callback functions.
|
||||||
|
@ -1369,6 +1384,21 @@ GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height);
|
||||||
*/
|
*/
|
||||||
GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height);
|
GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height);
|
||||||
|
|
||||||
|
/*! @brief Retrieves the size of the framebuffer of the specified window.
|
||||||
|
*
|
||||||
|
* This function retrieves the size, in pixels, of the framebuffer of the
|
||||||
|
* specified window.
|
||||||
|
*
|
||||||
|
* @param[in] window The window whose framebuffer to query.
|
||||||
|
* @param[out] width The width of the framebuffer.
|
||||||
|
* @param[out] height The height of the framebuffer.
|
||||||
|
*
|
||||||
|
* @sa glfwSetFramebufferSizeCallback
|
||||||
|
*
|
||||||
|
* @ingroup window
|
||||||
|
*/
|
||||||
|
GLFWAPI void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height);
|
||||||
|
|
||||||
/*! @brief Iconifies the specified window.
|
/*! @brief Iconifies the specified window.
|
||||||
*
|
*
|
||||||
* This function iconifies/minimizes the specified window, if it was previously
|
* This function iconifies/minimizes the specified window, if it was previously
|
||||||
|
@ -1604,6 +1634,21 @@ GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwi
|
||||||
*/
|
*/
|
||||||
GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun cbfun);
|
GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun cbfun);
|
||||||
|
|
||||||
|
/*! @brief Sets the framebuffer resize callback for the specified window.
|
||||||
|
*
|
||||||
|
* This function sets the framebuffer resize callback of the specified window,
|
||||||
|
* which is called when the framebuffer of the specified window is resized.
|
||||||
|
*
|
||||||
|
* @param[in] window The window whose callback to set.
|
||||||
|
* @param[in] cbfun The new callback, or `NULL` to remove the currently set
|
||||||
|
* callback.
|
||||||
|
*
|
||||||
|
* @return The previously set callback, or `NULL` if an error occurred.
|
||||||
|
*
|
||||||
|
* @ingroup window
|
||||||
|
*/
|
||||||
|
GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun cbfun);
|
||||||
|
|
||||||
/*! @brief Processes all pending events.
|
/*! @brief Processes all pending events.
|
||||||
*
|
*
|
||||||
* This function processes only those events that have already been received
|
* This function processes only those events that have already been received
|
||||||
|
|
|
@ -111,9 +111,11 @@ static void centerCursor(_GLFWwindow *window)
|
||||||
{
|
{
|
||||||
[window->nsgl.context update];
|
[window->nsgl.context update];
|
||||||
|
|
||||||
int width, height;
|
const NSRect contentRect = [window->ns.view frame];
|
||||||
_glfwPlatformGetWindowSize(window, &width, &height);
|
const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect];
|
||||||
_glfwInputWindowSize(window, width, height);
|
|
||||||
|
_glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
|
||||||
|
_glfwInputWindowSize(window, contentRect.size.width, contentRect.size.height);
|
||||||
_glfwInputWindowDamage(window);
|
_glfwInputWindowDamage(window);
|
||||||
|
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
|
@ -515,6 +517,14 @@ static int convertMacKeyCode(unsigned int macKeyCode)
|
||||||
_glfwInputCursorEnter(window, GL_TRUE);
|
_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
|
- (void)updateTrackingAreas
|
||||||
{
|
{
|
||||||
if (trackingArea != nil)
|
if (trackingArea != nil)
|
||||||
|
@ -804,6 +814,8 @@ static GLboolean createWindow(_GLFWwindow* window,
|
||||||
|
|
||||||
window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window];
|
window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window];
|
||||||
|
|
||||||
|
[window->ns.view setWantsBestResolutionOpenGLSurface:YES];
|
||||||
|
|
||||||
[window->ns.object setTitle:[NSString stringWithUTF8String:wndconfig->title]];
|
[window->ns.object setTitle:[NSString stringWithUTF8String:wndconfig->title]];
|
||||||
[window->ns.object setContentView:window->ns.view];
|
[window->ns.object setContentView:window->ns.view];
|
||||||
[window->ns.object setDelegate:window->ns.delegate];
|
[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)];
|
[window->ns.object setContentSize:NSMakeSize(width, height)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
|
||||||
|
{
|
||||||
|
_glfwPlatformGetWindowSize(window, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (window->monitor)
|
if (window->monitor)
|
||||||
|
|
|
@ -222,6 +222,7 @@ struct _GLFWwindow
|
||||||
GLFWwindowrefreshfun refresh;
|
GLFWwindowrefreshfun refresh;
|
||||||
GLFWwindowfocusfun focus;
|
GLFWwindowfocusfun focus;
|
||||||
GLFWwindowiconifyfun iconify;
|
GLFWwindowiconifyfun iconify;
|
||||||
|
GLFWframebuffersizefun fbsize;
|
||||||
GLFWmousebuttonfun mouseButton;
|
GLFWmousebuttonfun mouseButton;
|
||||||
GLFWcursorposfun cursorPos;
|
GLFWcursorposfun cursorPos;
|
||||||
GLFWcursorenterfun cursorEnter;
|
GLFWcursorenterfun cursorEnter;
|
||||||
|
@ -474,6 +475,11 @@ void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height);
|
||||||
*/
|
*/
|
||||||
void _glfwPlatformSetWindowSize(_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
|
/*! @copydoc glfwIconifyWindow
|
||||||
* @ingroup platform
|
* @ingroup platform
|
||||||
*/
|
*/
|
||||||
|
@ -562,6 +568,14 @@ void _glfwInputWindowPos(_GLFWwindow* window, int xpos, int ypos);
|
||||||
*/
|
*/
|
||||||
void _glfwInputWindowSize(_GLFWwindow* window, int width, int height);
|
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.
|
/*! @brief Notifies shared code of a window iconification event.
|
||||||
* @param[in] window The window that received the event.
|
* @param[in] window The window that received the event.
|
||||||
* @param[in] iconified `GL_TRUE` if the window was iconified, or `GL_FALSE`
|
* @param[in] iconified `GL_TRUE` if the window was iconified, or `GL_FALSE`
|
||||||
|
|
|
@ -645,6 +645,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
updateClipRect(window);
|
updateClipRect(window);
|
||||||
|
|
||||||
|
_glfwInputFramebufferSize(window, LOWORD(lParam), HIWORD(lParam));
|
||||||
_glfwInputWindowSize(window, LOWORD(lParam), HIWORD(lParam));
|
_glfwInputWindowSize(window, LOWORD(lParam), HIWORD(lParam));
|
||||||
return 0;
|
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)
|
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
ShowWindow(window->win32.handle, SW_MINIMIZE);
|
ShowWindow(window->win32.handle, SW_MINIMIZE);
|
||||||
|
|
28
src/window.c
28
src/window.c
|
@ -113,6 +113,12 @@ void _glfwInputWindowIconify(_GLFWwindow* window, int iconified)
|
||||||
window->callbacks.iconify((GLFWwindow*) window, 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)
|
void _glfwInputWindowVisibility(_GLFWwindow* window, int visible)
|
||||||
{
|
{
|
||||||
window->visible = visible;
|
window->visible = visible;
|
||||||
|
@ -478,6 +484,15 @@ GLFWAPI void glfwSetWindowSize(GLFWwindow* handle, int width, int height)
|
||||||
_glfwPlatformSetWindowSize(window, width, 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)
|
GLFWAPI void glfwIconifyWindow(GLFWwindow* handle)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
|
@ -665,6 +680,19 @@ GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* handle,
|
||||||
return previous;
|
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)
|
GLFWAPI void glfwPollEvents(void)
|
||||||
{
|
{
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
|
|
|
@ -635,6 +635,10 @@ static void processEvent(XEvent *event)
|
||||||
|
|
||||||
case ConfigureNotify:
|
case ConfigureNotify:
|
||||||
{
|
{
|
||||||
|
_glfwInputFramebufferSize(window,
|
||||||
|
event->xconfigure.width,
|
||||||
|
event->xconfigure.height);
|
||||||
|
|
||||||
_glfwInputWindowSize(window,
|
_glfwInputWindowSize(window,
|
||||||
event->xconfigure.width,
|
event->xconfigure.width,
|
||||||
event->xconfigure.height);
|
event->xconfigure.height);
|
||||||
|
@ -1021,6 +1025,11 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
||||||
XFlush(_glfw.x11.display);
|
XFlush(_glfw.x11.display);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
|
||||||
|
{
|
||||||
|
_glfwPlatformGetWindowSize(window, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (window->x11.overrideRedirect)
|
if (window->x11.overrideRedirect)
|
||||||
|
|
|
@ -56,7 +56,7 @@ static void error_callback(int error, const char* description)
|
||||||
fprintf(stderr, "Error: %s\n", description);
|
fprintf(stderr, "Error: %s\n", description);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void window_size_callback(GLFWwindow* window, int width, int height)
|
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||||
{
|
{
|
||||||
window_width = width;
|
window_width = width;
|
||||||
window_height = height;
|
window_height = height;
|
||||||
|
@ -98,13 +98,13 @@ int main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwSetCursorPosCallback(window, cursor_position_callback);
|
glfwSetCursorPosCallback(window, cursor_position_callback);
|
||||||
glfwSetWindowSizeCallback(window, window_size_callback);
|
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
||||||
glfwSetKeyCallback(window, key_callback);
|
glfwSetKeyCallback(window, key_callback);
|
||||||
|
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
|
|
||||||
glfwGetWindowSize(window, &width, &height);
|
glfwGetFramebufferSize(window, &width, &height);
|
||||||
window_size_callback(window, width, height);
|
framebuffer_size_callback(window, width, height);
|
||||||
|
|
||||||
set_swap_interval(window, swap_interval);
|
set_swap_interval(window, swap_interval);
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ static void key_callback(GLFWwindow* window, int key, int action, int mods)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void window_size_callback(GLFWwindow* window, int width, int height)
|
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||||
{
|
{
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ int main(int argc, char** argv)
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
|
|
||||||
glfwSetKeyCallback(window, key_callback);
|
glfwSetKeyCallback(window, key_callback);
|
||||||
glfwSetWindowSizeCallback(window, window_size_callback);
|
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glOrtho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f);
|
glOrtho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f);
|
||||||
|
|
|
@ -96,9 +96,9 @@ int main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
glfwGetWindowSize(window, &width, &height);
|
glfwGetFramebufferSize(window, &width, &height);
|
||||||
|
|
||||||
printf("window size: %ix%i\n", width, height);
|
printf("framebuffer size: %ix%i\n", width, height);
|
||||||
|
|
||||||
for (i = 0; glfw_attribs[i].name; i++)
|
for (i = 0; glfw_attribs[i].name; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -259,6 +259,15 @@ static void window_size_callback(GLFWwindow* window, int width, int height)
|
||||||
glfwGetTime(),
|
glfwGetTime(),
|
||||||
width,
|
width,
|
||||||
height);
|
height);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||||
|
{
|
||||||
|
printf("%08x at %0.3f: Framebuffer size: %i %i\n",
|
||||||
|
counter++,
|
||||||
|
glfwGetTime(),
|
||||||
|
width,
|
||||||
|
height);
|
||||||
|
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
}
|
}
|
||||||
|
@ -422,6 +431,7 @@ int main(void)
|
||||||
|
|
||||||
glfwSetWindowPosCallback(window, window_pos_callback);
|
glfwSetWindowPosCallback(window, window_pos_callback);
|
||||||
glfwSetWindowSizeCallback(window, window_size_callback);
|
glfwSetWindowSizeCallback(window, window_size_callback);
|
||||||
|
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
||||||
glfwSetWindowCloseCallback(window, window_close_callback);
|
glfwSetWindowCloseCallback(window, window_close_callback);
|
||||||
glfwSetWindowRefreshCallback(window, window_refresh_callback);
|
glfwSetWindowRefreshCallback(window, window_refresh_callback);
|
||||||
glfwSetWindowFocusCallback(window, window_focus_callback);
|
glfwSetWindowFocusCallback(window, window_focus_callback);
|
||||||
|
|
|
@ -43,7 +43,7 @@ static void error_callback(int error, const char* description)
|
||||||
fprintf(stderr, "Error: %s\n", description);
|
fprintf(stderr, "Error: %s\n", description);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void window_size_callback(GLFWwindow* window, int width, int height)
|
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||||
{
|
{
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwSetKeyCallback(window, key_callback);
|
glfwSetKeyCallback(window, key_callback);
|
||||||
glfwSetWindowSizeCallback(window, window_size_callback);
|
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
||||||
|
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
|
|
|
@ -91,7 +91,7 @@ static void key_callback(GLFWwindow* window, int key, int action, int mods)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void size_callback(GLFWwindow* window, int width, int height)
|
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||||
{
|
{
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ int main(int argc, char** argv)
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
|
|
||||||
glfwSetKeyCallback(window, key_callback);
|
glfwSetKeyCallback(window, key_callback);
|
||||||
glfwSetWindowSizeCallback(window, size_callback);
|
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glOrtho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f);
|
glOrtho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f);
|
||||||
|
|
|
@ -68,6 +68,11 @@ static void key_callback(GLFWwindow* window, int key, int action, int mods)
|
||||||
static void window_size_callback(GLFWwindow* window, int width, int height)
|
static void window_size_callback(GLFWwindow* window, int width, int height)
|
||||||
{
|
{
|
||||||
printf("%0.2f Window resized to %ix%i\n", glfwGetTime(), width, height);
|
printf("%0.2f Window resized to %ix%i\n", glfwGetTime(), width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||||
|
{
|
||||||
|
printf("%0.2f Framebuffer resized to %ix%i\n", glfwGetTime(), width, height);
|
||||||
|
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
}
|
}
|
||||||
|
@ -138,6 +143,7 @@ int main(int argc, char** argv)
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
|
|
||||||
glfwSetKeyCallback(window, key_callback);
|
glfwSetKeyCallback(window, key_callback);
|
||||||
|
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
||||||
glfwSetWindowSizeCallback(window, window_size_callback);
|
glfwSetWindowSizeCallback(window, window_size_callback);
|
||||||
glfwSetWindowFocusCallback(window, window_focus_callback);
|
glfwSetWindowFocusCallback(window, window_focus_callback);
|
||||||
glfwSetWindowIconifyCallback(window, window_iconify_callback);
|
glfwSetWindowIconifyCallback(window, window_iconify_callback);
|
||||||
|
@ -150,7 +156,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
while (!glfwWindowShouldClose(window))
|
while (!glfwWindowShouldClose(window))
|
||||||
{
|
{
|
||||||
glfwGetWindowSize(window, &width, &height);
|
glfwGetFramebufferSize(window, &width, &height);
|
||||||
|
|
||||||
glScissor(0, 0, width, height);
|
glScissor(0, 0, width, height);
|
||||||
glClearColor(0, 0, 0, 0);
|
glClearColor(0, 0, 0, 0);
|
||||||
|
|
|
@ -56,7 +56,7 @@ static void error_callback(int error, const char* description)
|
||||||
fprintf(stderr, "Error: %s\n", description);
|
fprintf(stderr, "Error: %s\n", description);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void window_size_callback(GLFWwindow* window, int width, int height)
|
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||||
{
|
{
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ static void draw_joysticks(GLFWwindow* window)
|
||||||
{
|
{
|
||||||
int i, width, height;
|
int i, width, height;
|
||||||
|
|
||||||
glfwGetWindowSize(window, &width, &height);
|
glfwGetFramebufferSize(window, &width, &height);
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
@ -208,7 +208,7 @@ int main(void)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwSetWindowSizeCallback(window, window_size_callback);
|
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
||||||
|
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
|
|
|
@ -67,9 +67,9 @@ static void error_callback(int error, const char* description)
|
||||||
fprintf(stderr, "Error: %s\n", description);
|
fprintf(stderr, "Error: %s\n", description);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void window_size_callback(GLFWwindow* window, int width, int height)
|
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||||
{
|
{
|
||||||
printf("Window resized to %ix%i\n", width, height);
|
printf("Framebuffer resized to %ix%i\n", width, height);
|
||||||
|
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ static void test_modes(GLFWmonitor* monitor)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwSetWindowSizeCallback(window, window_size_callback);
|
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
||||||
glfwSetKeyCallback(window, key_callback);
|
glfwSetKeyCallback(window, key_callback);
|
||||||
|
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
|
|
|
@ -87,7 +87,7 @@ static void key_callback(GLFWwindow* window, int key, int action, int mods)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void window_size_callback(GLFWwindow* window, int width, int height)
|
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||||
{
|
{
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ static GLFWwindow* open_window(void)
|
||||||
glfwGetCursorPos(window, &cursor_x, &cursor_y);
|
glfwGetCursorPos(window, &cursor_x, &cursor_y);
|
||||||
printf("Cursor position: %f %f\n", cursor_x, cursor_y);
|
printf("Cursor position: %f %f\n", cursor_x, cursor_y);
|
||||||
|
|
||||||
glfwSetWindowSizeCallback(window, window_size_callback);
|
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
||||||
glfwSetCursorPosCallback(window, cursor_position_callback);
|
glfwSetCursorPosCallback(window, cursor_position_callback);
|
||||||
glfwSetKeyCallback(window, key_callback);
|
glfwSetKeyCallback(window, key_callback);
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ static void error_callback(int error, const char* description)
|
||||||
fprintf(stderr, "Error: %s\n", description);
|
fprintf(stderr, "Error: %s\n", description);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void window_size_callback(GLFWwindow* window, int width, int height)
|
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||||
{
|
{
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ static GLFWwindow* open_window(int width, int height, GLFWmonitor* monitor)
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
|
|
||||||
glfwSetWindowSizeCallback(window, window_size_callback);
|
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
||||||
glfwSetWindowCloseCallback(window, window_close_callback);
|
glfwSetWindowCloseCallback(window, window_close_callback);
|
||||||
glfwSetKeyCallback(window, key_callback);
|
glfwSetKeyCallback(window, key_callback);
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ static GLuint create_texture(void)
|
||||||
static void draw_quad(GLuint texture)
|
static void draw_quad(GLuint texture)
|
||||||
{
|
{
|
||||||
int width, height;
|
int width, height;
|
||||||
glfwGetWindowSize(glfwGetCurrentContext(), &width, &height);
|
glfwGetFramebufferSize(glfwGetCurrentContext(), &width, &height);
|
||||||
|
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ static void error_callback(int error, const char* description)
|
||||||
fprintf(stderr, "Error: %s\n", description);
|
fprintf(stderr, "Error: %s\n", description);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void window_size_callback(GLFWwindow* window, int width, int height)
|
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||||
{
|
{
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ int main(void)
|
||||||
last_time = glfwGetTime();
|
last_time = glfwGetTime();
|
||||||
frame_rate = 0.0;
|
frame_rate = 0.0;
|
||||||
|
|
||||||
glfwSetWindowSizeCallback(window, window_size_callback);
|
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
||||||
glfwSetKeyCallback(window, key_callback);
|
glfwSetKeyCallback(window, key_callback);
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
|
|
@ -37,7 +37,7 @@ static void error_callback(int error, const char* description)
|
||||||
fprintf(stderr, "Error: %s\n", description);
|
fprintf(stderr, "Error: %s\n", description);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void window_size_callback(GLFWwindow* window, int width, int height)
|
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||||
{
|
{
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ int main(void)
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
|
|
||||||
glfwSetWindowSizeCallback(window, window_size_callback);
|
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
||||||
|
|
||||||
while (!glfwWindowShouldClose(window))
|
while (!glfwWindowShouldClose(window))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user