#include "OpenGLContext.h"
#include "DeerRender/Log.h"
#include "glad/glad.h"
// GLFW second
#include "GLFW/glfw3.h"

namespace Deer {
	OpenGLContext::OpenGLContext(GLFWwindow* window)
	    : m_window(window) {
	}

	void OpenGLContext::init() {
		glfwMakeContextCurrent(m_window);
		int status = gladLoadGLLoader((GLADloadproc)glfwGetProcAddress);
		if (status == 0) {
			DEER_CORE_ERROR("Failed to load glad in OpenGL render context");
		}

		DEER_CORE_TRACE("OpenGL driver: {0}", (char*)glGetString(GL_VENDOR));
	}

	void OpenGLContext::swapBuffers() {
		glfwSwapBuffers(m_window);
	}
} // namespace Deer