Skip to content

Commit eca3eee

Browse files
author
Adrien GIVRY
authored
Merge pull request #131 from kmqwerty/refactor/Remove_GL_calls
Remove GL calls from anywhere else than OvRendering
2 parents 286b106 + 109e4d4 commit eca3eee

8 files changed

Lines changed: 115 additions & 3 deletions

File tree

Sources/Overload/OvEditor/src/OvEditor/Panels/AView.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void OvEditor::Panels::AView::Render()
5050

5151
EDITOR_CONTEXT(shapeDrawer)->SetViewProjection(m_camera.GetProjectionMatrix() * m_camera.GetViewMatrix());
5252

53-
glViewport(0, 0, winWidth, winHeight); // TODO: Move this OpenGL call to OvRendering
53+
EDITOR_CONTEXT(renderer)->SetViewPort(0, 0, winWidth, winHeight);
5454

5555
_Render_Impl();
5656
}
@@ -113,4 +113,3 @@ void OvEditor::Panels::AView::PrepareCamera()
113113
auto [winWidth, winHeight] = GetSafeSize();
114114
m_camera.CacheMatrices(winWidth, winHeight, m_cameraPosition, m_cameraRotation);
115115
}
116-

Sources/Overload/OvEditor/src/OvEditor/Panels/SceneView.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ void OvEditor::Panels::SceneView::HandleActorPicking()
204204

205205
m_actorPickingFramebuffer.Bind();
206206
uint8_t pixel[3];
207-
glReadPixels(static_cast<int>(mouseX), static_cast<int>(mouseY), 1, 1, GL_RGB, GL_UNSIGNED_BYTE, pixel);
207+
EDITOR_CONTEXT(renderer)->ReadPixels(static_cast<int>(mouseX), static_cast<int>(mouseY), 1, 1, OvRendering::Settings::EPixelDataFormat::RGB, OvRendering::Settings::EPixelDataType::UNSIGNED_BYTE, pixel);
208208
m_actorPickingFramebuffer.Unbind();
209209

210210
uint32_t actorID = (0 << 24) | (pixel[2] << 16) | (pixel[1] << 8) | (pixel[0] << 0);

Sources/Overload/OvRendering/OvRendering.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ xcopy "$(SolutionDir)..\..\Dependencies\assimp\bin\*.dll" "$(SolutionDir)..\..\B
160160
<ClInclude Include="include\OvRendering\Settings\ECullFace.h" />
161161
<ClInclude Include="include\OvRendering\Settings\ECullingOptions.h" />
162162
<ClInclude Include="include\OvRendering\Settings\EOperation.h" />
163+
<ClInclude Include="include\OvRendering\Settings\EPixelDataFormat.h" />
164+
<ClInclude Include="include\OvRendering\Settings\EPixelDataType.h" />
163165
<ClInclude Include="include\OvRendering\Settings\EPrimitiveMode.h" />
164166
<ClInclude Include="include\OvRendering\Settings\EProjectionMode.h" />
165167
<ClInclude Include="include\OvRendering\Settings\ERasterizationMode.h" />

Sources/Overload/OvRendering/OvRendering.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@
135135
<ClInclude Include="include\OvRendering\Settings\EProjectionMode.h">
136136
<Filter>Header Files</Filter>
137137
</ClInclude>
138+
<ClInclude Include="include\OvRendering\Settings\EPixelDataFormat.h">
139+
<Filter>Header Files</Filter>
140+
</ClInclude>
141+
<ClInclude Include="include\OvRendering\Settings\EPixelDataType.h">
142+
<Filter>Header Files</Filter>
143+
</ClInclude>
138144
</ItemGroup>
139145
<ItemGroup>
140146
<ClCompile Include="src\OvRendering\Context\Driver.cpp">

Sources/Overload/OvRendering/include/OvRendering/Core/Renderer.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include "OvRendering/Settings/EOperation.h"
2020
#include "OvRendering/Settings/ECullFace.h"
2121
#include "OvRendering/Settings/ECullingOptions.h"
22+
#include "OvRendering/Settings/EPixelDataFormat.h"
23+
#include "OvRendering/Settings/EPixelDataType.h"
2224

2325
namespace OvRendering::Core
2426
{
@@ -157,6 +159,28 @@ namespace OvRendering::Core
157159
*/
158160
void SetColorWriting(bool p_enable);
159161

162+
163+
/**
164+
* Set the viewport parameters.
165+
* @param x
166+
* @param y
167+
* @param width
168+
* @param height
169+
*/
170+
void SetViewPort(uint32_t x, uint32_t y, uint32_t width, uint32_t height);
171+
172+
/**
173+
* Read a block of pixels from the frame buffer.
174+
* @param x
175+
* @param y
176+
* @param width
177+
* @param height
178+
* @param format
179+
* @param type
180+
* @param data
181+
*/
182+
void ReadPixels(uint32_t x, uint32_t y, uint32_t width, uint32_t height, Settings::EPixelDataFormat format,Settings::EPixelDataType type, void* data);
183+
160184
/**
161185
* Return the value associated to the given GLenum
162186
* @param p_parameter
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* @project: Overload
3+
* @author: Overload Tech.
4+
* @licence: MIT
5+
*/
6+
7+
#pragma once
8+
9+
#include "OvRendering/API/Export.h"
10+
11+
namespace OvRendering::Settings
12+
{
13+
/**
14+
* OpenGL pixel data format enum wrapper
15+
*/
16+
enum class EPixelDataFormat
17+
{
18+
COLOR_INDEX = 0x1900,
19+
STENCIL_INDEX = 0x1901,
20+
DEPTH_COMPONENT = 0x1902,
21+
RED = 0x1903,
22+
GREEN = 0x1904,
23+
BLUE = 0x1905,
24+
ALPHA = 0x1906,
25+
RGB = 0x1907,
26+
BGR = 0x80E0,
27+
RGBA = 0x1908,
28+
BGRA = 0x80E1,
29+
LUMINANCE = 0x1909,
30+
LUMINANCE_ALPHA = 0x190A,
31+
};
32+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* @project: Overload
3+
* @author: Overload Tech.
4+
* @licence: MIT
5+
*/
6+
7+
#pragma once
8+
9+
#include "OvRendering/API/Export.h"
10+
11+
namespace OvRendering::Settings
12+
{
13+
/**
14+
* OpenGL pixel data type enum wrapper
15+
*/
16+
enum class EPixelDataType
17+
{
18+
BYTE = 0x1400,
19+
UNSIGNED_BYTE = 0x1401,
20+
BITMAP = 0x1A00,
21+
SHORT = 0x1402,
22+
UNSIGNED_SHORT = 0x1403,
23+
INT = 0x1404,
24+
UNSIGNED_INT = 0x1405,
25+
FLOAT = 0x1406,
26+
UNSIGNED_BYTE_3_3_2 = 0x8032,
27+
UNSIGNED_BYTE_2_3_3_REV = 0x8362,
28+
UNSIGNED_SHORT_5_6_5 = 0x8363,
29+
UNSIGNED_SHORT_5_6_5_REV = 0x8364,
30+
UNSIGNED_SHORT_4_4_4_4 = 0x8033,
31+
UNSIGNED_SHORT_4_4_4_4_REV = 0x8365,
32+
UNSIGNED_SHORT_5_5_5_1 = 0x8034,
33+
UNSIGNED_SHORT_1_5_5_5_REV = 0x8366,
34+
UNSIGNED_INT_8_8_8_8 = 0x8035,
35+
UNSIGNED_INT_8_8_8_8_REV = 0x8367,
36+
UNSIGNED_INT_10_10_10_2 = 0x8036,
37+
UNSIGNED_INT_2_10_10_10_REV = 0x8368
38+
};
39+
}

Sources/Overload/OvRendering/src/OvRendering/Core/Renderer.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ void OvRendering::Core::Renderer::SetColorWriting(bool p_enable)
102102
glColorMask(p_enable, p_enable, p_enable, p_enable);
103103
}
104104

105+
void OvRendering::Core::Renderer::SetViewPort(uint32_t x, uint32_t y, uint32_t width, uint32_t height)
106+
{
107+
glViewport(x, y, width, height);
108+
}
109+
110+
void OvRendering::Core::Renderer::ReadPixels(uint32_t x, uint32_t y, uint32_t width, uint32_t height, Settings::EPixelDataFormat format, Settings::EPixelDataType type, void* data)
111+
{
112+
glReadPixels(x, y, width, height, static_cast<GLenum>(format), static_cast<GLenum>(type), data);
113+
}
114+
105115
bool OvRendering::Core::Renderer::GetBool(GLenum p_parameter)
106116
{
107117
GLboolean result;

0 commit comments

Comments
 (0)