Line data Source code
1 : // Copyright (c) 2025 Milton McDonald
2 : // This source code is licensed under the MIT License. See LICENSE file in the
3 : // project root for details.
4 :
5 : #include "graphics-engine/engine.h"
6 :
7 : #include "error.h"
8 : #include "glad/glad.h"
9 : #include "graphics-engine/gl-wrappers.h"
10 :
11 : using ::glm::vec4;
12 :
13 : using ::graphics_engine::error::CheckGLError;
14 : using ::graphics_engine::error::MakeErrorCode;
15 : using enum ::graphics_engine::types::ErrorCode;
16 : using ::graphics_engine::types::Expected;
17 :
18 : using ::std::unexpected;
19 :
20 : namespace graphics_engine::engine {
21 :
22 3 : auto InitializeEngine() -> Expected<void> {
23 3 : if (gladLoadGL() == 0) {
24 1 : return unexpected(MakeErrorCode(kGladLoadGL));
25 : }
26 :
27 2 : return {};
28 : }
29 :
30 1 : auto Render() -> Expected<void> {
31 1 : glClear(GL_COLOR_BUFFER_BIT);
32 1 : assert(glGetError() == GL_NO_ERROR);
33 :
34 1 : return {};
35 : }
36 :
37 1 : auto SetBackgroundColor(const vec4& color) -> void {
38 1 : glClearColor(color[0], color[1], color[2], color[3]);
39 1 : }
40 :
41 : } // namespace graphics_engine::engine
|