Reenabling resizeCallback.
This commit is contained in:
parent
450fb12e1d
commit
3ddcb72d5a
@ -68,7 +68,7 @@ bool Graphics::createWindow()
|
|||||||
glfwWindowHint( GLFW_OPENGL_DEBUG_CONTEXT, true );
|
glfwWindowHint( GLFW_OPENGL_DEBUG_CONTEXT, true );
|
||||||
|
|
||||||
// define whether the window can get resized:
|
// define whether the window can get resized:
|
||||||
glfwWindowHint(GLFW_RESIZABLE, false);
|
glfwWindowHint(GLFW_RESIZABLE, true);
|
||||||
|
|
||||||
// non-decorated windows can be used as splash screens:
|
// non-decorated windows can be used as splash screens:
|
||||||
//glfwWindowHint( GLFW_DECORATED, false );
|
//glfwWindowHint( GLFW_DECORATED, false );
|
||||||
@ -142,13 +142,6 @@ void Graphics::setWindowSize(glm::uvec2 windowSize) {
|
|||||||
this->windowSize = windowSize;
|
this->windowSize = windowSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void resizeCallback(Graphics* graphics, int newWidth, int newHeight)
|
|
||||||
{
|
|
||||||
// store the new window size and adjust the viewport:
|
|
||||||
graphics->setWindowSize(glm::uvec2( newWidth, newHeight));
|
|
||||||
glViewport( 0, 0, newWidth, newHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::mat4 Graphics::buildFrustum( float phiInDegree, float _near, float _far, float aspectRatio) {
|
glm::mat4 Graphics::buildFrustum( float phiInDegree, float _near, float _far, float aspectRatio) {
|
||||||
|
|
||||||
float phiHalfInRadians = 0.5*phiInDegree * (M_PI/180.0);
|
float phiHalfInRadians = 0.5*phiInDegree * (M_PI/180.0);
|
||||||
|
@ -11,8 +11,6 @@ class Graphics {
|
|||||||
Graphics(glm::uvec2 windowSize, float nearPlane, float farPlane);
|
Graphics(glm::uvec2 windowSize, float nearPlane, float farPlane);
|
||||||
Graphics();
|
Graphics();
|
||||||
void render(Level* level, ACGL::OpenGL::SharedShaderProgram shader);
|
void render(Level* level, ACGL::OpenGL::SharedShaderProgram shader);
|
||||||
// gets called at window resize:
|
|
||||||
void resizeCallback( GLFWwindow *, int newWidth, int newHeight );
|
|
||||||
// to build the projection matrix:
|
// to build the projection matrix:
|
||||||
glm::mat4 buildFrustum( float phiInDegree, float near, float far, float aspectRatio);
|
glm::mat4 buildFrustum( float phiInDegree, float near, float far, float aspectRatio);
|
||||||
glm::mat4 buildViewMatrix(Level* level);
|
glm::mat4 buildViewMatrix(Level* level);
|
||||||
@ -28,6 +26,4 @@ class Graphics {
|
|||||||
GLFWwindow* window;
|
GLFWwindow* window;
|
||||||
};
|
};
|
||||||
|
|
||||||
void resizeCallback(Graphics* graphics, int newWidth, int newHeight);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
11
main.cc
11
main.cc
@ -16,8 +16,6 @@
|
|||||||
#include <ACGL/OpenGL/glloaders/extensions.hh>
|
#include <ACGL/OpenGL/glloaders/extensions.hh>
|
||||||
#include <ACGL/Base/Settings.hh>
|
#include <ACGL/Base/Settings.hh>
|
||||||
|
|
||||||
Application app;
|
|
||||||
|
|
||||||
Application::Application() {
|
Application::Application() {
|
||||||
graphics = Graphics(glm::uvec2(1024, 786), 0.1f, 100.0f);
|
graphics = Graphics(glm::uvec2(1024, 786), 0.1f, 100.0f);
|
||||||
}
|
}
|
||||||
@ -62,6 +60,13 @@ void Application::init()
|
|||||||
openGLCriticalError();
|
openGLCriticalError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void resizeCallback(GLFWwindow* window, int newWidth, int newHeight)
|
||||||
|
{
|
||||||
|
// store the new window size and adjust the viewport:
|
||||||
|
app.getGraphics()->setWindowSize(glm::uvec2( newWidth, newHeight));
|
||||||
|
glViewport( 0, 0, newWidth, newHeight);
|
||||||
|
}
|
||||||
|
|
||||||
static void keyCallback(GLFWwindow* _window, int _key, int, int _action, int)
|
static void keyCallback(GLFWwindow* _window, int _key, int, int _action, int)
|
||||||
{
|
{
|
||||||
if (_key == GLFW_KEY_ESCAPE && _action == GLFW_PRESS) {
|
if (_key == GLFW_KEY_ESCAPE && _action == GLFW_PRESS) {
|
||||||
@ -95,7 +100,7 @@ int main( int argc, char *argv[] )
|
|||||||
glfwSetInputMode(app.getGraphics()->getWindow(), GLFW_STICKY_KEYS, 1);
|
glfwSetInputMode(app.getGraphics()->getWindow(), GLFW_STICKY_KEYS, 1);
|
||||||
// Hide mouse cursor
|
// Hide mouse cursor
|
||||||
glfwSetInputMode(app.getGraphics()->getWindow(), GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
|
glfwSetInputMode(app.getGraphics()->getWindow(), GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
|
||||||
//glfwSetWindowSizeCallback(app.getGraphics(), resizeCallback);
|
glfwSetWindowSizeCallback(app.getGraphics()->getWindow(), resizeCallback);
|
||||||
glfwSetKeyCallback(app.getGraphics()->getWindow(), keyCallback );
|
glfwSetKeyCallback(app.getGraphics()->getWindow(), keyCallback );
|
||||||
glfwSetScrollCallback(app.getGraphics()->getWindow(), scrollCallback );
|
glfwSetScrollCallback(app.getGraphics()->getWindow(), scrollCallback );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user