Add setViewport()
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user