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
+4 -4
View File
@@ -56,7 +56,7 @@ static void error_callback(int error, const char* 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_height = height;
@@ -98,13 +98,13 @@ int main(void)
}
glfwSetCursorPosCallback(window, cursor_position_callback);
glfwSetWindowSizeCallback(window, window_size_callback);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glfwSetKeyCallback(window, key_callback);
glfwMakeContextCurrent(window);
glfwGetWindowSize(window, &width, &height);
window_size_callback(window, width, height);
glfwGetFramebufferSize(window, &width, &height);
framebuffer_size_callback(window, width, height);
set_swap_interval(window, swap_interval);
+2 -2
View File
@@ -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);
}
@@ -124,7 +124,7 @@ int main(int argc, char** argv)
glfwSwapInterval(1);
glfwSetKeyCallback(window, key_callback);
glfwSetWindowSizeCallback(window, window_size_callback);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glMatrixMode(GL_PROJECTION);
glOrtho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f);
+2 -2
View File
@@ -96,9 +96,9 @@ int main(void)
}
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++)
{
+10
View File
@@ -259,6 +259,15 @@ static void window_size_callback(GLFWwindow* window, int width, int height)
glfwGetTime(),
width,
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);
}
@@ -422,6 +431,7 @@ int main(void)
glfwSetWindowPosCallback(window, window_pos_callback);
glfwSetWindowSizeCallback(window, window_size_callback);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glfwSetWindowCloseCallback(window, window_close_callback);
glfwSetWindowRefreshCallback(window, window_refresh_callback);
glfwSetWindowFocusCallback(window, window_focus_callback);
+2 -2
View File
@@ -43,7 +43,7 @@ static void error_callback(int error, const char* 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);
}
@@ -107,7 +107,7 @@ int main(int argc, char** argv)
}
glfwSetKeyCallback(window, key_callback);
glfwSetWindowSizeCallback(window, window_size_callback);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
+2 -2
View File
@@ -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);
}
@@ -150,7 +150,7 @@ int main(int argc, char** argv)
glfwSwapInterval(1);
glfwSetKeyCallback(window, key_callback);
glfwSetWindowSizeCallback(window, size_callback);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glMatrixMode(GL_PROJECTION);
glOrtho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f);
+7 -1
View File
@@ -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)
{
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);
}
@@ -138,6 +143,7 @@ int main(int argc, char** argv)
glfwSwapInterval(1);
glfwSetKeyCallback(window, key_callback);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glfwSetWindowSizeCallback(window, window_size_callback);
glfwSetWindowFocusCallback(window, window_focus_callback);
glfwSetWindowIconifyCallback(window, window_iconify_callback);
@@ -150,7 +156,7 @@ int main(int argc, char** argv)
while (!glfwWindowShouldClose(window))
{
glfwGetWindowSize(window, &width, &height);
glfwGetFramebufferSize(window, &width, &height);
glScissor(0, 0, width, height);
glClearColor(0, 0, 0, 0);
+3 -3
View File
@@ -56,7 +56,7 @@ static void error_callback(int error, const char* 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);
}
@@ -108,7 +108,7 @@ static void draw_joysticks(GLFWwindow* window)
{
int i, width, height;
glfwGetWindowSize(window, &width, &height);
glfwGetFramebufferSize(window, &width, &height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
@@ -208,7 +208,7 @@ int main(void)
exit(EXIT_FAILURE);
}
glfwSetWindowSizeCallback(window, window_size_callback);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
+3 -3
View File
@@ -67,9 +67,9 @@ static void error_callback(int error, const char* 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);
}
@@ -143,7 +143,7 @@ static void test_modes(GLFWmonitor* monitor)
continue;
}
glfwSetWindowSizeCallback(window, window_size_callback);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glfwSetKeyCallback(window, key_callback);
glfwMakeContextCurrent(window);
+2 -2
View File
@@ -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);
}
@@ -104,7 +104,7 @@ static GLFWwindow* open_window(void)
glfwGetCursorPos(window, &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);
glfwSetKeyCallback(window, key_callback);
+2 -2
View File
@@ -44,7 +44,7 @@ static void error_callback(int error, const char* 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);
}
@@ -82,7 +82,7 @@ static GLFWwindow* open_window(int width, int height, GLFWmonitor* monitor)
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
glfwSetWindowSizeCallback(window, window_size_callback);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glfwSetWindowCloseCallback(window, window_close_callback);
glfwSetKeyCallback(window, key_callback);
+1 -1
View File
@@ -94,7 +94,7 @@ static GLuint create_texture(void)
static void draw_quad(GLuint texture)
{
int width, height;
glfwGetWindowSize(glfwGetCurrentContext(), &width, &height);
glfwGetFramebufferSize(glfwGetCurrentContext(), &width, &height);
glViewport(0, 0, width, height);
+2 -2
View File
@@ -59,7 +59,7 @@ static void error_callback(int error, const char* 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);
}
@@ -95,7 +95,7 @@ int main(void)
last_time = glfwGetTime();
frame_rate = 0.0;
glfwSetWindowSizeCallback(window, window_size_callback);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glfwSetKeyCallback(window, key_callback);
glMatrixMode(GL_PROJECTION);
+2 -2
View File
@@ -37,7 +37,7 @@ static void error_callback(int error, const char* 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);
}
@@ -61,7 +61,7 @@ int main(void)
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
glfwSetWindowSizeCallback(window, window_size_callback);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
while (!glfwWindowShouldClose(window))
{