6 changed files with 92 additions and 20 deletions
			
			
		| @ -0,0 +1,46 @@ | ||||
| #include <glad/glad.h> | ||||
| #include <GLFW/glfw3.h> | ||||
| 
 | ||||
| #include "inferno/core.h" | ||||
| #include "inferno/log.h" | ||||
| #include "inferno/render/context.h" | ||||
| #include "inferno/window.h" | ||||
| 
 | ||||
| namespace Inferno { | ||||
| 
 | ||||
| 	Context::Context(GLFWwindow* window) : | ||||
| 		m_window(window) | ||||
| 	{ | ||||
| 	} | ||||
| 
 | ||||
| 	void Context::initialize() | ||||
| 	{ | ||||
| 		// Initialize glad
 | ||||
| 		glfwMakeContextCurrent(m_window); | ||||
| 		int glad = gladLoadGLLoader((GLADloadproc)glfwGetProcAddress); | ||||
| 		NF_CORE_ASSERT(glad, "Failed to initialize glad!"); | ||||
| 
 | ||||
| 		// Log OpenGL properties
 | ||||
| 		NF_CORE_INFO("OpenGL Info:"); | ||||
| 		NF_CORE_INFO("  Vendor:   %s", glGetString(GL_VENDOR)); | ||||
| 		NF_CORE_INFO("  Renderer: %s", glGetString(GL_RENDERER)); | ||||
| 		NF_CORE_INFO("  Version:  %s", glGetString(GL_VERSION)); | ||||
| 
 | ||||
| 		// Set viewport
 | ||||
| 		Window &w = *(Window*)glfwGetWindowUserPointer(m_window); | ||||
| 		glViewport(0, 0, w.getWidth(), w.getHeight()); | ||||
| 
 | ||||
| 		// Enable z-buffer / depth buffer
 | ||||
| 		glEnable(GL_DEPTH_TEST); | ||||
| 	} | ||||
| 
 | ||||
| 	void Context::update() | ||||
| 	{ | ||||
| 		glfwSwapBuffers(m_window); | ||||
| 	} | ||||
| 
 | ||||
| 	void Context::destroy() | ||||
| 	{ | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,25 @@ | ||||
| #ifndef CONTEXT_H | ||||
| #define CONTEXT_H | ||||
| 
 | ||||
| struct GLFWwindow; | ||||
| 
 | ||||
| namespace Inferno { | ||||
| 
 | ||||
| 	class Context { | ||||
| 	public: | ||||
| 		Context(GLFWwindow* window); | ||||
| 		// virtual ~Context();
 | ||||
| 
 | ||||
| 		void initialize(); | ||||
| 		void update(); | ||||
| 		// void render();
 | ||||
| 		void destroy(); | ||||
| 
 | ||||
| 	private: | ||||
| 		GLFWwindow* m_window; | ||||
| 	}; | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| #endif // CONTEXT_H
 | ||||
					Loading…
					
					
				
		Reference in new issue