Browse Source

Add setViewport()

master
Rick van Vonderen 5 years ago
parent
commit
e2c217d741
  1. 10
      inferno/src/inferno/render/context.cpp
  2. 6
      inferno/src/inferno/render/context.h
  3. 4
      inferno/src/inferno/window.cpp
  4. 7
      inferno/src/inferno/window.h

10
inferno/src/inferno/render/context.cpp

@ -13,6 +13,8 @@ namespace Inferno {
{ {
} }
// -----------------------------------------
void Context::initialize() void Context::initialize()
{ {
// Initialize glad // Initialize glad
@ -34,7 +36,7 @@ namespace Inferno {
} }
// Set viewport // Set viewport
glViewport(0, 0, w.getWidth(), w.getHeight()); this->setViewport(0, 0, w.getWidth(), w.getHeight());
// Enable z-buffer / depth buffer // Enable z-buffer / depth buffer
glEnable(GL_DEPTH_TEST); 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
inferno/src/inferno/render/context.h

@ -10,11 +10,17 @@ namespace Inferno {
Context(GLFWwindow* window); Context(GLFWwindow* window);
// virtual ~Context(); // virtual ~Context();
// -----------------------------------------
void initialize(); void initialize();
void update(); void update();
// void render(); // void render();
void destroy(); void destroy();
// -----------------------------------------
void setViewport(int x, int y, int width, int height) const;
private: private:
GLFWwindow* m_window; GLFWwindow* m_window;
}; };

4
inferno/src/inferno/window.cpp

@ -33,6 +33,8 @@ namespace Inferno {
this->destroy(); this->destroy();
} }
// -----------------------------------------
void Window::initialize() void Window::initialize()
{ {
const char* title = m_windowProperties.title; const char* title = m_windowProperties.title;
@ -173,6 +175,8 @@ namespace Inferno {
} }
} }
// -----------------------------------------
void Window::setWindowMonitor() void Window::setWindowMonitor()
{ {
GLFWmonitor* monitor = glfwGetPrimaryMonitor(); GLFWmonitor* monitor = glfwGetPrimaryMonitor();

7
inferno/src/inferno/window.h

@ -12,8 +12,8 @@ namespace Inferno {
struct WindowProperties { struct WindowProperties {
const char* title = "Inferno"; const char* title = "Inferno";
unsigned int width = 1280; int width = 1280;
unsigned int height = 720; int height = 720;
const char* fullscreen = "windowed"; // windowed/fullscreen/borderless const char* fullscreen = "windowed"; // windowed/fullscreen/borderless
bool vsync = true; bool vsync = true;
}; };
@ -23,6 +23,8 @@ namespace Inferno {
Window(); Window();
virtual ~Window(); virtual ~Window();
// -----------------------------------------
void initialize(); void initialize();
void update(); void update();
// void render(); // void render();
@ -37,6 +39,7 @@ namespace Inferno {
inline bool isVSync() const { return m_windowProperties.vsync; } inline bool isVSync() const { return m_windowProperties.vsync; }
inline GLFWwindow* getWindow() const { return m_window; } 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; } inline void setEventCallback(std::function<void(Event&)> callback) { m_eventCallback = callback; }

Loading…
Cancel
Save