Add setViewport()

This commit is contained in:
Rick van Vonderen
2019-12-20 01:01:10 +01:00
parent cd2f38f360
commit e2c217d741
4 changed files with 24 additions and 3 deletions
+9 -1
View File
@@ -13,6 +13,8 @@ namespace Inferno {
{
}
// -----------------------------------------
void Context::initialize()
{
// Initialize glad
@@ -34,7 +36,7 @@ namespace Inferno {
}
// Set viewport
glViewport(0, 0, w.getWidth(), w.getHeight());
this->setViewport(0, 0, w.getWidth(), w.getHeight());
// Enable z-buffer / depth buffer
glEnable(GL_DEPTH_TEST);
@@ -49,4 +51,10 @@ namespace Inferno {
{
}
// -----------------------------------------
void Context::setViewport(int x, int y, int width, int height) const
{
glViewport(x, y, width, height);
}
}
+6
View File
@@ -10,11 +10,17 @@ namespace Inferno {
Context(GLFWwindow* window);
// virtual ~Context();
// -----------------------------------------
void initialize();
void update();
// void render();
void destroy();
// -----------------------------------------
void setViewport(int x, int y, int width, int height) const;
private:
GLFWwindow* m_window;
};
+4
View File
@@ -33,6 +33,8 @@ namespace Inferno {
this->destroy();
}
// -----------------------------------------
void Window::initialize()
{
const char* title = m_windowProperties.title;
@@ -173,6 +175,8 @@ namespace Inferno {
}
}
// -----------------------------------------
void Window::setWindowMonitor()
{
GLFWmonitor* monitor = glfwGetPrimaryMonitor();
+5 -2
View File
@@ -12,8 +12,8 @@ namespace Inferno {
struct WindowProperties {
const char* title = "Inferno";
unsigned int width = 1280;
unsigned int height = 720;
int width = 1280;
int height = 720;
const char* fullscreen = "windowed"; // windowed/fullscreen/borderless
bool vsync = true;
};
@@ -23,6 +23,8 @@ namespace Inferno {
Window();
virtual ~Window();
// -----------------------------------------
void initialize();
void update();
// void render();
@@ -37,6 +39,7 @@ namespace Inferno {
inline bool isVSync() const { return m_windowProperties.vsync; }
inline GLFWwindow* getWindow() const { return m_window; }
inline Context* getContext() const { return m_context; }
inline void setEventCallback(std::function<void(Event&)> callback) { m_eventCallback = callback; }