87 lines
1.9 KiB
C++
87 lines
1.9 KiB
C++
#if GRAPHICS_OPENGL
|
|
#include <GL/gl.h>
|
|
|
|
#pragma comment(lib, "opengl32")
|
|
#pragma comment(lib, "gdi32")
|
|
#endif
|
|
|
|
// #if GRAPHICS_DIRECTX11
|
|
|
|
// enum class Graphics_API: s32 {
|
|
// DirectX_11 = 0,
|
|
// OpenGL_3 = 1,
|
|
// };
|
|
|
|
struct Shader {};
|
|
struct Texture {};
|
|
struct Vertex {
|
|
Vec2 position;
|
|
Vec4 color_scale;
|
|
Vec2 uv0;
|
|
// The following values are for rendering rounded rectangles
|
|
// It's OK to put these here because for basic rendering the performance is "good enough"
|
|
Vec2 rect_center;
|
|
Vec2 rect_size;
|
|
f32 rect_corner_radius;
|
|
f32 rect_edge_softness = 1.0;
|
|
};
|
|
|
|
constexpr s64 starting_vertex_count = 2048;
|
|
|
|
struct Graphics {
|
|
// Graphics_API api = Graphics_API::OpenGL_3;
|
|
|
|
Window_Info current_window;
|
|
Shader* current_shader;
|
|
Texture* texture_render_target;
|
|
|
|
Array<Vertex> vertices; // just init to max count.
|
|
};
|
|
|
|
void graphics_thread_destroy () {
|
|
Thread_Context* context = thread_context(); // maybe turn this into a :macro?
|
|
|
|
array_free(context->graphics->vertices);
|
|
internal_free(context->graphics);
|
|
}
|
|
|
|
void graphics_reset () {
|
|
Thread_Context* context = thread_context(); // maybe turn this into a :macro?
|
|
|
|
context->graphics->current_shader = nullptr;
|
|
}
|
|
|
|
Graphics* graphics_thread_init () {
|
|
Thread_Context* context = thread_context();
|
|
|
|
Assert(context != nullptr);
|
|
|
|
push_allocator(GPAllocator());
|
|
|
|
if (context->graphics == nullptr) {
|
|
context->graphics = New<Graphics>(true);
|
|
array_reserve(context->graphics->vertices, starting_vertex_count);
|
|
}
|
|
|
|
return context->graphics;
|
|
}
|
|
|
|
void graphics_flush_buffer () {
|
|
//
|
|
}
|
|
|
|
void graphics_update_current_window (Graphics* graphics) {
|
|
// graphics->current_window
|
|
|
|
}
|
|
|
|
void graphics_set_render_target (Window_Info window_info) {
|
|
Graphics* graphics = graphics_thread_init();
|
|
|
|
graphics->current_shader = nullptr;
|
|
graphics->texture_render_target = nullptr;
|
|
|
|
graphics->current_window = window_info;
|
|
// #TODO: #Graphics graphics_update_window ::
|
|
|
|
} |