work on renderer
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#ifndef RENDERER_OPENGL
|
||||
|
||||
#define RENDERER_OPENGL
|
||||
#ifdef RENDERER_OPENGL
|
||||
#undef RENDERER_OPENGL
|
||||
|
||||
#include "pch.hpp"
|
||||
|
||||
@@ -11,6 +13,12 @@
|
||||
|
||||
namespace Archimedes {
|
||||
|
||||
class VertexArrayOpenGL : public VertexArray {};
|
||||
|
||||
class IndexArrayOpenGL : public IndexArray {};
|
||||
|
||||
class ShaderOpenGL : public Shader {};
|
||||
|
||||
class RendererOpenGL : public Renderer {
|
||||
|
||||
public:
|
||||
@@ -19,19 +27,30 @@ namespace Archimedes {
|
||||
RendererOpenGL() {};
|
||||
~RendererOpenGL() {};
|
||||
|
||||
bool init() {
|
||||
bool init() override {
|
||||
return glewInit() == GLEW_OK;
|
||||
};
|
||||
|
||||
void render(std::list<std::function<void()>> cmdList, int& w, int& h) {
|
||||
void render() override {
|
||||
|
||||
glViewport(0, 0, w, h);
|
||||
glClearColor(0.2, 0.2, 0.4, 1);
|
||||
glClearColor(clearColor.r, clearColor.g, clearColor.b, clearColor.a);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
}
|
||||
|
||||
void draw() {}
|
||||
void draw(const VertexArray& va, const IndexArray& ia, const Shader& shader) override {
|
||||
|
||||
glUseProgram(shader.id);
|
||||
|
||||
glBindVertexArray(va.id);
|
||||
|
||||
glDrawElements(GL_TRIANGLES, va.count, GL_UNSIGNED_INT, 0);
|
||||
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
RendererOpenGL* getRendererImpl() override { return this; }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user