sculpto
buffer.cpp
Go to the documentation of this file.
1/*!****************************************************************//*!*
2 * \file buffer.h
3 * \brief Buffer interfaces implementation module.
4 *
5 * \author Sabitov Kirill
6 * \date 26 June 2022
7 *********************************************************************/
8
9#include "sclpch.h"
10#include "../render_context.h"
11#include "buffer.h"
13
15{
16 switch (render_context::GetApi())
17 {
18 case scl::render_context_api::OpenGL: return CreateShared<scl::gl_constant_buffer>(Size);
19 case scl::render_context_api::DirectX: SCL_CORE_ASSERT(0, "This API is currently unsupported."); return nullptr;
20 }
21
22 SCL_CORE_ASSERT(0, "Unknown render API was selected.");
23 return nullptr;
24}
25
27{
28 switch (render_context::GetApi())
29 {
30 case scl::render_context_api::OpenGL: return CreateShared<scl::gl_constant_buffer>(Data, Size);
31 case scl::render_context_api::DirectX: SCL_CORE_ASSERT(0, "This API is currently unsupported."); return nullptr;
32 }
33
34 SCL_CORE_ASSERT(0, "Unknown render API was selected.");
35 return nullptr;
36}
37
39 VertexLayout(VertexLayout) {}
40
42{
43 switch (render_context::GetApi())
44 {
45 case scl::render_context_api::OpenGL: return CreateShared<scl::gl_vertex_buffer>(Count, VertexLayout);
46 case scl::render_context_api::DirectX: SCL_CORE_ASSERT(0, "This API is currently unsupported."); return nullptr;
47 }
48
49 SCL_CORE_ASSERT(0, "Unknown render API was selected.");
50 return nullptr;
51}
52
53scl::shared<scl::vertex_buffer> scl::vertex_buffer::Create(const void *Vertices, u32 Count, const vertex_layout &VertexLayout)
54{
55 switch (render_context::GetApi())
56 {
57 case scl::render_context_api::OpenGL: return CreateShared<scl::gl_vertex_buffer>(Vertices, Count, VertexLayout);
58 case scl::render_context_api::DirectX: SCL_CORE_ASSERT(0, "This API is currently unsupported."); return nullptr;
59 }
60
61 SCL_CORE_ASSERT(0, "Unknown render API was selected.");
62 return nullptr;
63}
64
66{
67 switch (render_context::GetApi())
68 {
69 case scl::render_context_api::OpenGL: return CreateShared<scl::gl_index_buffer>(Indices, Count);
70 case scl::render_context_api::DirectX: SCL_CORE_ASSERT(0, "This API is currently unsupported."); return nullptr;
71 }
72
73 SCL_CORE_ASSERT(0, "Unknown render API was selected.");
74 return nullptr;
75}
#define SCL_CORE_ASSERT(expr,...)
Definition: assert.h:69
Buffer interfaces implementation module.
static shared< constant_buffer > Create(u32 Size)
Definition: buffer.cpp:14
static shared< index_buffer > Create(u32 *Indices, u32 Count)
Definition: buffer.cpp:65
static render_context_api GetApi()
static shared< vertex_buffer > Create(u32 Count, const vertex_layout &VertexLayout)
Definition: buffer.cpp:41
vertex_buffer(const vertex_layout &VertexLayout)
Definition: buffer.cpp:38
std::shared_ptr< T > shared
Definition: smart_ptr.h:15
uint32_t u32
Definition: math_common.h:21
Sculpto library prehompiled header. Defines common definitions, includes commonly used modules.