parent
554bbe6567
commit
b2ebd91bec
15 changed files with 116 additions and 17 deletions
@ -1,25 +1,30 @@ |
||||
#include "buffer.h" |
||||
#include "bakara/renderer/renderer.h" |
||||
#include "bakatools/container/types.h" |
||||
#include "bakatools/logging/assert.h" |
||||
#include "platforms/opengl/opengl_buffer.h" |
||||
|
||||
namespace Bk |
||||
{ |
||||
VertexBuffer* VertexBuffer::Create(float *vertices, u32 size) |
||||
Ref<VertexBuffer> VertexBuffer::Create(float *vertices, u32 size) |
||||
{ |
||||
switch (Renderer::GetAPI())
|
||||
{ |
||||
case Renderer::API::None: BK_MSG_ASSERT(false, "API not supported"); return nullptr; |
||||
case Renderer::API::Opengl: return new Platform::OpenglVertexBuffer(vertices, size); |
||||
case Renderer::API::Opengl: return CreateRef<Platform::OpenglVertexBuffer>(vertices, size); |
||||
} |
||||
BK_MSG_ASSERT(false, "API not supported");
|
||||
return nullptr; |
||||
} |
||||
|
||||
IndexBuffer* IndexBuffer::Create(u32* indices, u32 count) |
||||
Ref<IndexBuffer> IndexBuffer::Create(u32* indices, u32 count) |
||||
{ |
||||
switch (Renderer::GetAPI())
|
||||
{ |
||||
case Renderer::API::None: BK_MSG_ASSERT(false, "API not supported"); return nullptr; |
||||
case Renderer::API::Opengl: return new Platform::OpenglIndexBuffer(indices, count); |
||||
case Renderer::API::Opengl: return CreateRef<Platform::OpenglIndexBuffer>(indices, count); |
||||
} |
||||
BK_MSG_ASSERT(false, "API not supported");
|
||||
return nullptr; |
||||
} |
||||
} |
@ -0,0 +1,18 @@ |
||||
#include "bakara/renderer/renderer.h" |
||||
#include "bakatools/logging/assert.h" |
||||
#include "texture.h" |
||||
#include "platforms/opengl/opengl_texture.h" |
||||
|
||||
namespace Bk |
||||
{ |
||||
Ref<Texture2D> Texture2D::Create(const std::string& filePath) |
||||
{ |
||||
switch (Renderer::GetAPI())
|
||||
{ |
||||
case Renderer::API::None: BK_MSG_ASSERT(false, "API not supported"); return nullptr; |
||||
case Renderer::API::Opengl: return CreateRef<Platform::OpenglTexture2D>(filePath); |
||||
} |
||||
BK_MSG_ASSERT(false, "API not supported");
|
||||
return nullptr; |
||||
} |
||||
} |
@ -0,0 +1,22 @@ |
||||
#pragma once |
||||
|
||||
#include "bakatools/container/types.h" |
||||
#include <string> |
||||
|
||||
namespace Bk
|
||||
{ |
||||
class Texture
|
||||
{ |
||||
public: |
||||
virtual ~Texture() {} |
||||
virtual u32 GetWidth() = 0; |
||||
virtual u32 GetHeight() = 0; |
||||
virtual void Bind() = 0; |
||||
}; |
||||
|
||||
class Texture2D : public Texture |
||||
{ |
||||
public: |
||||
static Ref<Texture2D> Create(const std::string& filePath); |
||||
}; |
||||
} |
@ -0,0 +1,22 @@ |
||||
#include "opengl_texture.h" |
||||
|
||||
#include <stb_image.h> |
||||
#include <glad/glad.h> |
||||
|
||||
namespace Bk::Platform
|
||||
{ |
||||
OpenglTexture2D::OpenglTexture2D(const std::string& filePath) |
||||
{ |
||||
|
||||
} |
||||
|
||||
OpenglTexture2D::~OpenglTexture2D() |
||||
{ |
||||
|
||||
} |
||||
|
||||
void OpenglTexture2D::Bind()
|
||||
{ |
||||
|
||||
} |
||||
} |
@ -0,0 +1,20 @@ |
||||
#pragma once |
||||
|
||||
#include "bakara/renderer/texture.h" |
||||
|
||||
namespace Bk::Platform
|
||||
{ |
||||
class OpenglTexture2D : public Texture2D |
||||
{ |
||||
public: |
||||
OpenglTexture2D(const std::string& filePath); |
||||
virtual ~OpenglTexture2D(); |
||||
|
||||
virtual u32 GetWidth() override { return width; } |
||||
virtual u32 GetHeight() override { return height; } |
||||
virtual void Bind() override; |
||||
private: |
||||
u32 id; |
||||
u32 width, height; |
||||
};
|
||||
} |
Loading…
Reference in New Issue