|
4 | 4 | #include "SceneMan.h"
|
5 | 5 | #include "ConsoleMan.h"
|
6 | 6 | #include "MOSprite.h"
|
| 7 | +#include "Shader.h" |
7 | 8 |
|
8 | 9 | #include "tracy/Tracy.hpp"
|
9 | 10 |
|
10 | 11 | #include <array>
|
| 12 | +#include "Draw.h" |
| 13 | +#include "glad/gl.h" |
11 | 14 |
|
12 | 15 | using namespace RTE;
|
13 | 16 |
|
@@ -230,29 +233,42 @@ void PrimitiveMan::DrawPrimitives(int player, BITMAP* targetBitmap, const Vector
|
230 | 233 | int lastDrawMode = DRAW_MODE_SOLID;
|
231 | 234 | DrawBlendMode lastBlendMode = DrawBlendMode::NoBlend;
|
232 | 235 | std::array<int, 4> lastBlendAmounts = {BlendAmountLimits::MinBlend, BlendAmountLimits::MinBlend, BlendAmountLimits::MinBlend, BlendAmountLimits::MinBlend};
|
233 |
| - |
| 236 | + GLint currentShader = rlGetShaderCurrent(); |
| 237 | + rlDrawRenderBatchActive(); |
| 238 | + glBlendBarrierKHR(); |
| 239 | + rlEnableAdvancedColorBlend(); |
| 240 | + rlEnableColorBlend(); |
234 | 241 | for (const std::unique_ptr<GraphicalPrimitive>& primitive: m_ScheduledPrimitives) {
|
235 | 242 | if (int playerToDrawFor = primitive->m_Player; playerToDrawFor == player || playerToDrawFor == -1) {
|
| 243 | + rlDrawRenderBatchActive(); |
236 | 244 | if (DrawBlendMode blendMode = primitive->m_BlendMode; blendMode > DrawBlendMode::NoBlend) {
|
237 | 245 | if (const std::array<int, 4>& blendAmounts = primitive->m_ColorChannelBlendAmounts; blendMode != lastBlendMode || blendAmounts != lastBlendAmounts) {
|
238 |
| - g_FrameMan.SetColorTable(blendMode, blendAmounts); |
| 246 | + rlEnableShader(rlGetShaderCurrent()); |
| 247 | + g_FrameMan.SetBlendMode(blendMode); |
| 248 | + GLint colorUniform = glGetUniformLocation(rlGetShaderCurrent(), "rteColor"); |
| 249 | + glUniform4f(colorUniform, blendAmounts[0] / static_cast<float>(MaxBlend), blendAmounts[1] / static_cast<float>(MaxBlend), blendAmounts[2] / static_cast<float>(MaxBlend), blendAmounts[3] / static_cast<float>(MaxBlend)); |
| 250 | + //g_FrameMan.SetColorTable(blendMode, blendAmounts); |
239 | 251 | lastBlendMode = blendMode;
|
240 | 252 | lastBlendAmounts = blendAmounts;
|
241 | 253 | }
|
242 |
| - if (lastDrawMode != DRAW_MODE_TRANS) { |
243 |
| - // Drawing mode is set so blending effects apply to true primitives. For bitmap based primitives it has no effect. |
244 |
| - drawing_mode(DRAW_MODE_TRANS, nullptr, 0, 0); |
245 |
| - lastDrawMode = DRAW_MODE_TRANS; |
246 |
| - } |
247 | 254 | } else {
|
248 |
| - if (lastDrawMode != DRAW_MODE_SOLID) { |
249 |
| - drawing_mode(DRAW_MODE_SOLID, nullptr, 0, 0); |
250 |
| - lastDrawMode = DRAW_MODE_SOLID; |
251 |
| - } |
| 255 | + g_FrameMan.SetBlendMode(BlendTransparency); |
| 256 | + rlEnableShader(currentShader); |
| 257 | + GLint colorUniform = glGetUniformLocation(rlGetShaderCurrent(), "rteColor"); |
| 258 | + glUniform4f(colorUniform, 1.0f, 1.0f, 1.0f, 1.0f); |
252 | 259 | lastBlendMode = DrawBlendMode::NoBlend;
|
253 | 260 | }
|
| 261 | + glBlendBarrierKHR(); |
| 262 | + rlZDepth(primitive->m_Depth); |
254 | 263 | primitive->DrawTiled(targetBitmap, targetPos);
|
255 | 264 | }
|
256 | 265 | }
|
| 266 | + rlDrawRenderBatchActive(); |
| 267 | + rlDisableAdvancedColorBlend(); |
| 268 | + rlSetBlendMode(RL_BLEND_ALPHA); |
| 269 | + rlEnableShader(currentShader); |
| 270 | + GLint colorUniform = glGetUniformLocation(rlGetShaderCurrent(), "rteColor"); |
| 271 | + glUniform4f(colorUniform, 1.0f, 1.0f, 1.0f, 1.0f); |
| 272 | + rlZDepth(c_DefaultDrawDepth); |
257 | 273 | drawing_mode(DRAW_MODE_SOLID, nullptr, 0, 0);
|
258 | 274 | }
|
0 commit comments