New scene items system
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
#include "RenderHost.hpp"
|
||||
#include "assert/assertgl.hpp"
|
||||
#include "assert/assert.hpp"
|
||||
#include "game/Game.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
@ -13,15 +14,15 @@ RenderHost::RenderHost() {
|
||||
|
||||
}
|
||||
|
||||
void RenderHost::init() {
|
||||
void RenderHost::init(std::shared_ptr<Game> game) {
|
||||
// Init GLFW
|
||||
if(!glfwInit()) {
|
||||
throw std::runtime_error("Failed to initialize GLFW!");
|
||||
assertUnreachable("Failed to initialize GLFW!");
|
||||
}
|
||||
|
||||
// Set the error callback for error handling.
|
||||
glfwSetErrorCallback([](int error, const char *description) {
|
||||
throw std::runtime_error(description);
|
||||
assertUnreachable(description);
|
||||
});
|
||||
|
||||
// Setup window hints
|
||||
@ -41,9 +42,10 @@ void RenderHost::init() {
|
||||
);
|
||||
|
||||
// Validate window exists
|
||||
if(!window) {
|
||||
throw std::runtime_error("Failed to create GLFW window!");
|
||||
}
|
||||
if(!window) assertUnreachable("Failed to create GLFW window!");
|
||||
|
||||
// Setup the user pointer
|
||||
glfwSetWindowUserPointer(window, game.get());
|
||||
|
||||
// Load GLAD
|
||||
glfwMakeContextCurrent(window);
|
||||
|
@ -4,7 +4,7 @@
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "dawnlibs.hpp"
|
||||
#include "display/IRenderHost.hpp"
|
||||
#include <glad/glad.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
@ -12,7 +12,9 @@
|
||||
#define DAWN_GLFW_WINDOW_HEIGHT_DEFAULT 720
|
||||
|
||||
namespace Dawn {
|
||||
class RenderHost {
|
||||
class Game;
|
||||
|
||||
class RenderHost : public IRenderHost {
|
||||
public:
|
||||
GLFWwindow *window = nullptr;
|
||||
|
||||
@ -21,26 +23,12 @@ namespace Dawn {
|
||||
*/
|
||||
RenderHost();
|
||||
|
||||
/**
|
||||
* Initializes GLFW and creates the window.
|
||||
*/
|
||||
void init();
|
||||
void init(std::shared_ptr<Game> game) override;
|
||||
|
||||
/**
|
||||
* Performs an update and renders the frame.
|
||||
*/
|
||||
void update();
|
||||
void update() override;
|
||||
|
||||
/**
|
||||
* Returns whether or not GLFW has been requested to close.
|
||||
*
|
||||
* @return True if GLFW has been requested to close.
|
||||
*/
|
||||
bool_t isCloseRequested();
|
||||
bool_t isCloseRequested() override;
|
||||
|
||||
/**
|
||||
* Cleans up GLFW.
|
||||
*/
|
||||
virtual ~RenderHost();
|
||||
~RenderHost();
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user