60 lines
1.7 KiB
C++
60 lines
1.7 KiB
C++
/**
|
|
This file is a part of our_dick
|
|
Copyright (C) 2020 ATLAS_Moon, rexy712
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Affero General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Affero General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "graphics/gl_include.hpp"
|
|
#include "render.hpp"
|
|
#include "config.hpp"
|
|
#include "graphics/window.hpp"
|
|
#include <cstdio>
|
|
|
|
namespace{
|
|
void handle_resize_event(GLFWwindow*, int width, int height){
|
|
debug_print("Window resized\n");
|
|
glViewportIndexedf(0, 0, 0, width, height);
|
|
}
|
|
}
|
|
|
|
|
|
render_manager::render_manager(int width, int height, const char* title):
|
|
m_window_close_callback(nullptr),
|
|
m_input_handler(nullptr),
|
|
m_main_window(width, height, title)
|
|
{
|
|
m_main_window.make_current();
|
|
glViewportIndexedf(0, 0, 0, width, height);
|
|
glClearColor(0, 0, 0, 1);
|
|
glfwSetFramebufferSizeCallback(m_main_window, handle_resize_event);
|
|
m_main_window.set_visible(true);
|
|
}
|
|
|
|
bool render_manager::should_close()const{
|
|
return m_main_window.should_close();
|
|
}
|
|
|
|
void render_manager::update(){
|
|
m_main_window.swap_buffers();
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
glfwPollEvents();
|
|
}
|
|
|
|
void render_manager::request_exit(){
|
|
if(m_window_close_callback)
|
|
m_window_close_callback();
|
|
m_main_window.set_should_close(true);
|
|
}
|