mirror of
https://github.com/glfw/glfw.git
synced 2026-09-17 14:22:50 +00:00
Separated window and framebuffer sizes.
This commit is contained in:
+2
-2
@@ -589,13 +589,13 @@ int main( void )
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
glfwSetWindowSizeCallback(window, reshape);
|
||||
glfwSetFramebufferSizeCallback(window, reshape);
|
||||
glfwSetKeyCallback(window, key_callback);
|
||||
|
||||
glfwMakeContextCurrent(window);
|
||||
glfwSwapInterval( 1 );
|
||||
|
||||
glfwGetWindowSize(window, &width, &height);
|
||||
glfwGetFramebufferSize(window, &width, &height);
|
||||
reshape(window, width, height);
|
||||
|
||||
glfwSetTime( 0.0 );
|
||||
|
||||
+2
-2
@@ -337,13 +337,13 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// Set callback functions
|
||||
glfwSetWindowSizeCallback(window, reshape);
|
||||
glfwSetFramebufferSizeCallback(window, reshape);
|
||||
glfwSetKeyCallback(window, key);
|
||||
|
||||
glfwMakeContextCurrent(window);
|
||||
glfwSwapInterval( 1 );
|
||||
|
||||
glfwGetWindowSize(window, &width, &height);
|
||||
glfwGetFramebufferSize(window, &width, &height);
|
||||
reshape(window, width, height);
|
||||
|
||||
// Parse command-line options
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ int main(void)
|
||||
float ratio;
|
||||
int width, height;
|
||||
|
||||
glfwGetWindowSize(window, &width, &height);
|
||||
glfwGetFramebufferSize(window, &width, &height);
|
||||
ratio = width / (float) 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;
|
||||
height = h > 0 ? h : 1;
|
||||
@@ -467,7 +467,7 @@ int main(void)
|
||||
}
|
||||
|
||||
// Set callback functions
|
||||
glfwSetWindowSizeCallback(window, windowSizeFun);
|
||||
glfwSetFramebufferSizeCallback(window, framebufferSizeFun);
|
||||
glfwSetWindowRefreshCallback(window, windowRefreshFun);
|
||||
glfwSetCursorPosCallback(window, cursorPosFun);
|
||||
glfwSetMouseButtonCallback(window, mouseButtonFun);
|
||||
@@ -477,8 +477,8 @@ int main(void)
|
||||
glfwMakeContextCurrent(window);
|
||||
glfwSwapInterval(1);
|
||||
|
||||
glfwGetWindowSize(window, &width, &height);
|
||||
windowSizeFun(window, width, height);
|
||||
glfwGetFramebufferSize(window, &width, &height);
|
||||
framebufferSizeFun(window, width, height);
|
||||
|
||||
// Main loop
|
||||
for (;;)
|
||||
|
||||
+5
-5
@@ -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;
|
||||
|
||||
@@ -404,7 +404,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
glfwSetKeyCallback(window, key_callback);
|
||||
glfwSetWindowSizeCallback(window, window_size_callback);
|
||||
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
||||
glfwSetMouseButtonCallback(window, mouse_button_callback);
|
||||
glfwSetCursorPosCallback(window, cursor_position_callback);
|
||||
glfwSetScrollCallback(window, scroll_callback);
|
||||
@@ -412,8 +412,8 @@ int main(int argc, char* argv[])
|
||||
glfwMakeContextCurrent(window);
|
||||
glfwSwapInterval(1);
|
||||
|
||||
glfwGetWindowSize(window, &width, &height);
|
||||
window_size_callback(window, width, height);
|
||||
glfwGetFramebufferSize(window, &width, &height);
|
||||
framebuffer_size_callback(window, width, height);
|
||||
|
||||
// Initialize OpenGL
|
||||
init_opengl();
|
||||
|
||||
Reference in New Issue
Block a user