Skip to content

Commit 6ad96af

Browse files
committed
A bodge fix to make scene editor draw almost right
1 parent 51afa5a commit 6ad96af

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed

Source/Managers/GLResourceMan.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,9 @@ GLuint GLResourceMan::UpdateDynamicBitmap(BITMAP* bitmap, bool updated, const st
150150
}
151151
}
152152
return texture;
153+
}
154+
155+
void GLResourceMan::DestroyBitmapInfo(BITMAP* bitmap) {
156+
GLBitmapInfo* info = GetBitmapInfo(bitmap);
157+
glDeleteTextures(1, &info->m_Texture);
153158
}

Source/Managers/GLResourceMan.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ namespace RTE {
4545
GLuint GetDynamicUploadBuffer(BITMAP* bitmap);
4646
GLuint UpdateDynamicBitmap(BITMAP* bitmap, bool updated, const std::vector<Box>& = {});
4747

48+
void DestroyBitmapInfo(BITMAP* bitmap);
49+
4850
GLBitmapInfo* MakeBitmapInfo();
4951

5052

Source/Menus/SceneEditorGUI.cpp

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include "Deployment.h"
2525
#include "BunkerAssemblyScheme.h"
2626

27+
#include "GLResourceMan.h"
28+
2729
#include <array>
2830
#include <string>
2931

@@ -1188,6 +1190,9 @@ void SceneEditorGUI::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) const
11881190
if (m_EditorGUIMode == DONEEDITING)
11891191
return;
11901192

1193+
BITMAP* temp = create_bitmap_ex(bitmap_color_depth(pTargetBitmap), pTargetBitmap->w, pTargetBitmap->h);
1194+
clear_to_color(temp, 0);
1195+
11911196
// The get a std::list of the currently edited set of placed objects in the Scene
11921197
const std::list<SceneObject*>* pSceneObjectList = 0;
11931198
if (m_FeatureSet == ONLOADEDIT)
@@ -1197,22 +1202,22 @@ void SceneEditorGUI::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) const
11971202
// Draw the 'original' set of placed scene objects as solid before the blueprints
11981203
const std::list<SceneObject*>* pOriginalsList = g_SceneMan.GetScene()->GetPlacedObjects(Scene::PLACEONLOAD);
11991204
for (std::list<SceneObject*>::const_iterator itr = pOriginalsList->begin(); itr != pOriginalsList->end(); ++itr) {
1200-
(*itr)->Draw(pTargetBitmap, targetPos);
1205+
(*itr)->Draw(temp, targetPos);
12011206
// Draw basic HUD if an actor
12021207
Actor* pActor = dynamic_cast<Actor*>(*itr);
12031208
// if (pActor)
1204-
// pActor->DrawHUD(pTargetBitmap, targetPos);
1209+
// pActor->DrawHUD(temp, targetPos);
12051210
}
12061211
} else if (m_FeatureSet == AIPLANEDIT) {
12071212
pSceneObjectList = g_SceneMan.GetScene()->GetPlacedObjects(Scene::AIPLAN);
12081213
// Draw the 'original' set of placed scene objects as solid before the planned base
12091214
const std::list<SceneObject*>* pOriginalsList = g_SceneMan.GetScene()->GetPlacedObjects(Scene::PLACEONLOAD);
12101215
for (std::list<SceneObject*>::const_iterator itr = pOriginalsList->begin(); itr != pOriginalsList->end(); ++itr) {
1211-
(*itr)->Draw(pTargetBitmap, targetPos);
1216+
(*itr)->Draw(temp, targetPos);
12121217
// Draw basic HUD if an actor
12131218
Actor* pActor = dynamic_cast<Actor*>(*itr);
12141219
// if (pActor)
1215-
// pActor->DrawHUD(pTargetBitmap, targetPos);
1220+
// pActor->DrawHUD(temp, targetPos);
12161221
}
12171222
}
12181223

@@ -1226,7 +1231,7 @@ void SceneEditorGUI::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) const
12261231
// Draw the currently held object into the order of the std::list if it is to be placed inside
12271232
if (m_pCurrentObject && m_DrawCurrentObject && i == m_ObjectListOrder) {
12281233
g_FrameMan.SetTransTableFromPreset(m_BlinkTimer.AlternateReal(333) || m_EditorGUIMode == PLACINGOBJECT ? TransparencyPreset::LessTrans : TransparencyPreset::HalfTrans);
1229-
m_pCurrentObject->Draw(pTargetBitmap, targetPos, g_DrawTrans);
1234+
m_pCurrentObject->Draw(temp, targetPos, g_DrawTrans);
12301235
pActor = dynamic_cast<Actor*>(m_pCurrentObject);
12311236
if (pActor)
12321237
pActor->DrawHUD(pTargetBitmap, targetPos);
@@ -1239,7 +1244,7 @@ void SceneEditorGUI::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) const
12391244
// Blink trans if we are supposed to blink this one
12401245
if ((*itr) == m_pObjectToBlink) {
12411246
g_FrameMan.SetTransTableFromPreset(m_BlinkTimer.AlternateReal(333) ? TransparencyPreset::LessTrans : TransparencyPreset::HalfTrans);
1242-
(*itr)->Draw(pTargetBitmap, targetPos, g_DrawTrans);
1247+
(*itr)->Draw(temp, targetPos, g_DrawTrans);
12431248
}
12441249
// Drawing of already placed objects that aren't highlighted or anything
12451250
else {
@@ -1250,15 +1255,15 @@ void SceneEditorGUI::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) const
12501255
// Animate the ghosted into appearing solid in the build order to make the order clear
12511256
if (i >= m_RevealIndex) {
12521257
g_FrameMan.SetTransTableFromPreset(pActor ? TransparencyPreset::MoreTrans : TransparencyPreset::HalfTrans);
1253-
(*itr)->Draw(pTargetBitmap, targetPos, g_DrawTrans);
1258+
(*itr)->Draw(temp, targetPos, g_DrawTrans);
12541259
}
12551260
// Show as non-transparent half the time to still give benefits of WYSIWYG
12561261
else
1257-
(*itr)->Draw(pTargetBitmap, targetPos);
1262+
(*itr)->Draw(temp, targetPos);
12581263
}
12591264
// In full scene edit mode, we want to give a WYSIWYG view
12601265
else {
1261-
(*itr)->Draw(pTargetBitmap, targetPos);
1266+
(*itr)->Draw(temp, targetPos);
12621267

12631268
// Draw team marks for doors, deployments and assemblies
12641269
Deployment* pDeployment = dynamic_cast<Deployment*>(*itr);
@@ -1299,7 +1304,7 @@ void SceneEditorGUI::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) const
12991304
if ((m_pCurrentObject && !m_pCurrentObject->IsInGroup("Brains")) && m_EditorGUIMode != INSTALLINGBRAIN && !(m_EditorGUIMode == PLACINGOBJECT && m_PreviousMode == INSTALLINGBRAIN)) {
13001305
SceneObject* pBrain = g_SceneMan.GetScene()->GetResidentBrain(m_pController->GetPlayer());
13011306
if (pBrain) {
1302-
pBrain->Draw(pTargetBitmap, targetPos);
1307+
pBrain->Draw(temp, targetPos);
13031308
// Draw basic HUD if an actor
13041309
Actor* pActor = dynamic_cast<Actor*>(pBrain);
13051310
if (pActor)
@@ -1319,7 +1324,7 @@ void SceneEditorGUI::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) const
13191324
// If the held object will be placed at the end of the std::list, draw it last to the scene, transperent blinking
13201325
else if (m_pCurrentObject && (m_ObjectListOrder < 0 || (pSceneObjectList && m_ObjectListOrder == pSceneObjectList->size()))) {
13211326
g_FrameMan.SetTransTableFromPreset(m_BlinkTimer.AlternateReal(333) || m_EditorGUIMode == PLACINGOBJECT ? TransparencyPreset::LessTrans : TransparencyPreset::HalfTrans);
1322-
m_pCurrentObject->Draw(pTargetBitmap, targetPos, g_DrawTrans);
1327+
m_pCurrentObject->Draw(temp, targetPos, g_DrawTrans);
13231328
Actor* pActor = dynamic_cast<Actor*>(m_pCurrentObject);
13241329
if (pActor && m_FeatureSet != BLUEPRINTEDIT && m_FeatureSet != AIPLANEDIT)
13251330
pActor->DrawHUD(pTargetBitmap, targetPos);
@@ -1329,6 +1334,16 @@ void SceneEditorGUI::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) const
13291334

13301335
// Draw the pie menu
13311336
m_PieMenu->Draw(pTargetBitmap, targetPos);
1337+
1338+
Texture2D tempTexture = g_GLResourceMan.GetStaticTextureFromBitmap(temp);
1339+
1340+
rlZDepth(3);
1341+
DrawTexture(tempTexture, 0, 0, {255, 255, 255, 255});
1342+
rlZDepth(0.0f);
1343+
rlDrawRenderBatchActive();
1344+
1345+
g_GLResourceMan.DestroyBitmapInfo(temp);
1346+
destroy_bitmap(temp);
13321347
}
13331348

13341349
void SceneEditorGUI::UpdateBrainSkyPathAndCost(Vector brainPos) {

0 commit comments

Comments
 (0)