Reenabling resizeCallback.

This commit is contained in:
Faerbit 2014-11-15 15:19:48 +01:00
parent 450fb12e1d
commit 3ddcb72d5a
4 changed files with 10 additions and 15 deletions

View File

@ -68,7 +68,7 @@ bool Graphics::createWindow()
glfwWindowHint( GLFW_OPENGL_DEBUG_CONTEXT, true );
// define whether the window can get resized:
glfwWindowHint(GLFW_RESIZABLE, false);
glfwWindowHint(GLFW_RESIZABLE, true);
// non-decorated windows can be used as splash screens:
//glfwWindowHint( GLFW_DECORATED, false );
@ -142,13 +142,6 @@ void Graphics::setWindowSize(glm::uvec2 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) {
float phiHalfInRadians = 0.5*phiInDegree * (M_PI/180.0);

View File

@ -11,8 +11,6 @@ class Graphics {
Graphics(glm::uvec2 windowSize, float nearPlane, float farPlane);
Graphics();
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:
glm::mat4 buildFrustum( float phiInDegree, float near, float far, float aspectRatio);
glm::mat4 buildViewMatrix(Level* level);
@ -28,6 +26,4 @@ class Graphics {
GLFWwindow* window;
};
void resizeCallback(Graphics* graphics, int newWidth, int newHeight);
#endif

11
main.cc
View File

@ -16,8 +16,6 @@
#include <ACGL/OpenGL/glloaders/extensions.hh>
#include <ACGL/Base/Settings.hh>
Application app;
Application::Application() {
graphics = Graphics(glm::uvec2(1024, 786), 0.1f, 100.0f);
}
@ -62,6 +60,13 @@ void Application::init()
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)
{
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);
// Hide mouse cursor
glfwSetInputMode(app.getGraphics()->getWindow(), GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
//glfwSetWindowSizeCallback(app.getGraphics(), resizeCallback);
glfwSetWindowSizeCallback(app.getGraphics()->getWindow(), resizeCallback);
glfwSetKeyCallback(app.getGraphics()->getWindow(), keyCallback );
glfwSetScrollCallback(app.getGraphics()->getWindow(), scrollCallback );

View File

@ -25,4 +25,5 @@ class Application {
ACGL::OpenGL::SharedShaderProgram shader;
};
Application app;
#endif