4 changed files with 161 additions and 9 deletions
			
			
		@ -0,0 +1,41 @@
					 | 
				
			||||
#include <glad/glad.h> | 
				
			||||
 | 
				
			||||
#include "inferno/render/buffer.h" | 
				
			||||
#include "inferno/render/renderer.h" | 
				
			||||
 | 
				
			||||
namespace Inferno { | 
				
			||||
 | 
				
			||||
	void Command::clear() | 
				
			||||
	{ | 
				
			||||
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | 
				
			||||
	} | 
				
			||||
 | 
				
			||||
	void Command::clearColor(const glm::vec4 &color) | 
				
			||||
	{ | 
				
			||||
		glClearColor(color.r, color.g, color.b, color.a); | 
				
			||||
	} | 
				
			||||
 | 
				
			||||
	void Command::drawIndexed(const std::shared_ptr<VertexArray> &vertexArray) | 
				
			||||
	{ | 
				
			||||
		glDrawElements(GL_TRIANGLES, vertexArray->getIndexBuffer()->getCount(), GL_UNSIGNED_INT, nullptr); | 
				
			||||
	} | 
				
			||||
 | 
				
			||||
// -----------------------------------------
 | 
				
			||||
 | 
				
			||||
	void Renderer::beginScene() | 
				
			||||
	{ | 
				
			||||
 | 
				
			||||
	} | 
				
			||||
 | 
				
			||||
	void Renderer::endScene() | 
				
			||||
	{ | 
				
			||||
 | 
				
			||||
	} | 
				
			||||
 | 
				
			||||
	void Renderer::submit(const std::shared_ptr<VertexArray> &vertexArray) | 
				
			||||
	{ | 
				
			||||
		vertexArray->bind(); | 
				
			||||
		Command::drawIndexed(vertexArray); | 
				
			||||
	} | 
				
			||||
 | 
				
			||||
} | 
				
			||||
@ -0,0 +1,32 @@
					 | 
				
			||||
#ifndef RENDERER_H | 
				
			||||
#define RENDERER_H | 
				
			||||
 | 
				
			||||
#include <memory>  // std::shared_ptr | 
				
			||||
 | 
				
			||||
#include <glm/vec4.hpp> | 
				
			||||
 | 
				
			||||
namespace Inferno { | 
				
			||||
 | 
				
			||||
	class VertexArray; | 
				
			||||
 | 
				
			||||
	class Command { | 
				
			||||
	public: | 
				
			||||
		static void clear(); | 
				
			||||
		static void clearColor(const glm::vec4 &color); | 
				
			||||
 | 
				
			||||
		static void drawIndexed(const std::shared_ptr<VertexArray> &vertexArray); | 
				
			||||
	}; | 
				
			||||
 | 
				
			||||
// -----------------------------------------
 | 
				
			||||
 | 
				
			||||
	class Renderer { | 
				
			||||
	public: | 
				
			||||
		static void beginScene(); | 
				
			||||
		static void endScene(); | 
				
			||||
 | 
				
			||||
		static void submit(const std::shared_ptr<VertexArray> &vertexArray); | 
				
			||||
	}; | 
				
			||||
 | 
				
			||||
} | 
				
			||||
 | 
				
			||||
#endif // RENDERER_H
 | 
				
			||||
					Loading…
					
					
				
		Reference in new issue