NoJobEngine 2.0.7
Loading...
Searching...
No Matches
OpenGLRendererAPI.cpp
Go to the documentation of this file.
4#include <glad/gl.h>
5
6namespace NoJob
7{
9 {
10 glEnable(GL_DEPTH_TEST);
11 }
12
14 std::uint32_t x,
15 std::uint32_t y,
16 std::uint32_t width,
17 std::uint32_t height)
18 {
19 glViewport(
20 static_cast<GLint>(x),
21 static_cast<GLint>(y),
22 static_cast<GLsizei>(width),
23 static_cast<GLsizei>(height));
24 }
25
27 float r, float g, float b, float a)
28 {
29 glClearColor(r, g, b, a);
30 }
31
33 {
34 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
35 }
36
38 const VertexArray& vertexArray)
39 {
40 const auto& indexBuffer = vertexArray.GetIndexBuffer();
41 if (!indexBuffer)
42 return;
43
44 vertexArray.Bind();
45
46 glDrawElements(
47 GL_TRIANGLES,
48 static_cast<GLsizei>(indexBuffer->GetCount()),
49 GL_UNSIGNED_INT,
50 nullptr);
51 }
53 const VertexArray& vertexArray,
54 std::uint32_t indexCount,
55 std::uint32_t indexOffset)
56 {
57 if(indexCount==0) return;
58 vertexArray.Bind();
59 glDrawElements(GL_TRIANGLES,
60 static_cast<GLsizei>(indexCount),GL_UNSIGNED_INT,
61 reinterpret_cast<const void*>(
62 static_cast<std::uintptr_t>(indexOffset*sizeof(std::uint32_t))));
63 }
64
66 const VertexArray& vertexArray,
67 std::uint32_t vertexCount)
68 {
69 if (vertexCount < 2)
70 {
71 return;
72 }
73
74 vertexArray.Bind();
75
76 glDrawArrays(
77 GL_LINES,
78 0,
79 static_cast<GLsizei>(vertexCount));
80 }
81
82}
Buffer declarations for the Rendering subsystem.
OpenGLRendererAPI declarations for the OpenGL Backend subsystem.
VertexArray declarations for the Rendering subsystem.
void DrawIndexedRange(const VertexArray &vertexArray, std::uint32_t indexCount, std::uint32_t indexOffset) override
void SetClearColor(float r, float g, float b, float a) override
void DrawIndexed(const VertexArray &vertexArray) override
void DrawLines(const VertexArray &vertexArray, std::uint32_t vertexCount) override
void SetViewport(std::uint32_t x, std::uint32_t y, std::uint32_t width, std::uint32_t height) override
virtual void Bind() const =0
virtual const std::shared_ptr< IndexBuffer > & GetIndexBuffer() const =0