mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-26 12:18:51 -05:00
Make remaining tests set viewport in render loop
This commit is contained in:
parent
c29e4455bb
commit
ff6a8891d4
|
@ -86,11 +86,6 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
|
||||||
{
|
|
||||||
glViewport(0, 0, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
int ch;
|
int ch;
|
||||||
|
@ -132,7 +127,6 @@ int main(int argc, char** argv)
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
|
|
||||||
glfwSetKeyCallback(window, key_callback);
|
glfwSetKeyCallback(window, key_callback);
|
||||||
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
|
||||||
|
|
||||||
glClearColor(0.5f, 0.5f, 0.5f, 0);
|
glClearColor(0.5f, 0.5f, 0.5f, 0);
|
||||||
|
|
||||||
|
|
|
@ -289,8 +289,6 @@ static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||||
Slot* slot = glfwGetWindowUserPointer(window);
|
Slot* slot = glfwGetWindowUserPointer(window);
|
||||||
printf("%08x to %i at %0.3f: Framebuffer size: %i %i\n",
|
printf("%08x to %i at %0.3f: Framebuffer size: %i %i\n",
|
||||||
counter++, slot->number, glfwGetTime(), width, height);
|
counter++, slot->number, glfwGetTime(), width, height);
|
||||||
|
|
||||||
glViewport(0, 0, width, height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void window_content_scale_callback(GLFWwindow* window, float xscale, float yscale)
|
static void window_content_scale_callback(GLFWwindow* window, float xscale, float yscale)
|
||||||
|
|
|
@ -127,8 +127,6 @@ static void window_size_callback(GLFWwindow* window, int width, int height)
|
||||||
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||||
{
|
{
|
||||||
printf("%0.2f Framebuffer resized to %ix%i\n", glfwGetTime(), width, height);
|
printf("%0.2f Framebuffer resized to %ix%i\n", glfwGetTime(), width, height);
|
||||||
|
|
||||||
glViewport(0, 0, width, height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void window_focus_callback(GLFWwindow* window, int focused)
|
static void window_focus_callback(GLFWwindow* window, int focused)
|
||||||
|
|
|
@ -92,11 +92,6 @@ static void error_callback(int error, const char* description)
|
||||||
fprintf(stderr, "Error: %s\n", description);
|
fprintf(stderr, "Error: %s\n", description);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
|
||||||
{
|
|
||||||
glViewport(0, 0, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||||
{
|
{
|
||||||
if (action != GLFW_PRESS)
|
if (action != GLFW_PRESS)
|
||||||
|
@ -188,7 +183,6 @@ int main(int argc, char** argv)
|
||||||
swap_tear = (glfwExtensionSupported("WGL_EXT_swap_control_tear") ||
|
swap_tear = (glfwExtensionSupported("WGL_EXT_swap_control_tear") ||
|
||||||
glfwExtensionSupported("GLX_EXT_swap_control_tear"));
|
glfwExtensionSupported("GLX_EXT_swap_control_tear"));
|
||||||
|
|
||||||
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
|
||||||
glfwSetKeyCallback(window, key_callback);
|
glfwSetKeyCallback(window, key_callback);
|
||||||
|
|
||||||
glGenBuffers(1, &vertex_buffer);
|
glGenBuffers(1, &vertex_buffer);
|
||||||
|
@ -217,9 +211,13 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
while (!glfwWindowShouldClose(window))
|
while (!glfwWindowShouldClose(window))
|
||||||
{
|
{
|
||||||
|
int width, height;
|
||||||
mat4x4 m, p, mvp;
|
mat4x4 m, p, mvp;
|
||||||
float position = cosf((float) glfwGetTime() * 4.f) * 0.75f;
|
float position = cosf((float) glfwGetTime() * 4.f) * 0.75f;
|
||||||
|
|
||||||
|
glfwGetFramebufferSize(window, &width, &height);
|
||||||
|
|
||||||
|
glViewport(0, 0, width, height);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
mat4x4_ortho(p, -1.f, 1.f, -1.f, 1.f, 0.f, 1.f);
|
mat4x4_ortho(p, -1.f, 1.f, -1.f, 1.f, 0.f, 1.f);
|
||||||
|
|
|
@ -38,11 +38,6 @@ static void error_callback(int error, const char* description)
|
||||||
fprintf(stderr, "Error: %s\n", description);
|
fprintf(stderr, "Error: %s\n", description);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
|
||||||
{
|
|
||||||
glViewport(0, 0, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
GLFWwindow* window;
|
GLFWwindow* window;
|
||||||
|
@ -63,8 +58,6 @@ int main(void)
|
||||||
gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
|
gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
|
|
||||||
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
|
||||||
|
|
||||||
while (!glfwWindowShouldClose(window))
|
while (!glfwWindowShouldClose(window))
|
||||||
{
|
{
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user