void Game::update(float deltaT)
{
+
+ if (Graphix::getWindowHeight() != current_world->getViewport().getHeight() || Graphix::getWindowWidth() != current_world->getViewport().getWidth())
+ current_world->getViewport().setView(0, 0, Graphix::getWindowWidth(), Graphix::getWindowHeight());
if (playing){
current_world->update(deltaT);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
- //SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE, 16);
- //SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE, 16);
- //SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE, 16);
- //SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE, 16);
+ SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE, 16);
+ SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE, 16);
+ SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE, 16);
+ SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE, 16);
sdl_window = SDL_CreateWindow(windowTitle.c_str(), xpos, ypos, width, height, windowFlags);
#define VIEW_BOT_LIM -0.3f
-ViewPort::ViewPort(unsigned int _x, unsigned int _y, unsigned int _width, unsigned int _height, float fovy, float zNear, float zFar) :
+ViewPort::ViewPort(unsigned int _x, unsigned int _y, unsigned int _width, unsigned int _height, float _fovy, float _zNear, float _zFar) :
xpos(_x),
ypos(_y),
width(_width),
height(_height),
+ fovy(_fovy),
+ zNear(_zNear),
+ zFar(_zFar),
projection(perspective(fovy, (float)width / height, zNear, zFar)),
view_angle_x(0),
view_angle_y(0),
{
return height;
}
+
+void ViewPort::setView(uint _x, uint _y, uint _width, uint _height, bool _updateProjection)
+{
+ xpos = _x;
+ ypos = _y;
+ width = _width;
+ height = _height;
+ if (_updateProjection)
+ projection = perspective(fovy, (float)width / height, zNear, zFar);
+}
void useViewPort() const;
- void setView(unsigned int width, unsigned int height);
+ void setView(unsigned int x, unsigned int y, unsigned int width, unsigned int height, bool updateProjection = true);
void bindView(Shader* shader) const;
void bindView(Shader* shader, vec3 lookat) const;
unsigned int xpos;
unsigned int ypos;
+ float fovy, zNear, zFar;
+
mat4 projection;
mat4 view;