Add 'no sky' via IMaterial::ColorModulate.

* Really should move this out of FrameStageNotify. Only keeping it
  here for demonstration purposes. Might find a better place later.

Signed-off-by: aixxe <me@aixxe.net>
This commit is contained in:
aixxe 2016-12-21 16:05:36 +00:00
parent 8287f60778
commit 3c4ad3d7ae
4 changed files with 30 additions and 0 deletions

View File

@ -14,6 +14,10 @@ void GUI::DrawConfigurationWindow() {
ImGui::Checkbox("Auto-bunnyhop", &GUI::BunnyHop::Enabled);
ImGui::Spacing();
ImGui::Checkbox("No sky", &GUI::NoSky::Enabled);
ImGui::ColorEdit3("##No sky color", GUI::NoSky::Color);
ImGui::Spacing();
ImGui::PopItemWidth();
ImGui::End();
}

View File

@ -4,6 +4,9 @@ bool GUI::IsVisible = false;
bool GUI::BunnyHop::Enabled = true;
bool GUI::NoSky::Enabled = true;
float GUI::NoSky::Color[3] = {0, 0, 0.275};
void GUI::Render() {
// Draw various global components.
GUI::DrawFramerateCounter();

View File

@ -10,6 +10,11 @@ namespace GUI {
extern bool Enabled;
}
namespace NoSky {
extern bool Enabled;
extern float Color[3];
}
void DrawFramerateCounter();
void DrawConfigurationWindow();

View File

@ -6,6 +6,24 @@ void Hooks::FrameStageNotify(IBaseClientDLL* thisptr, ClientFrameStage_t stage)
// Get the original function and store it statically.
static FrameStageNotify_t oFrameStageNotify = clientdll_hook->GetOriginalFunction<FrameStageNotify_t>(35);
// Really should move this somewhere else. Doesn't need to be called this often.
if (stage == ClientFrameStage_t::FRAME_NET_UPDATE_POSTDATAUPDATE_END) {
for (MaterialHandle_t i = matsystem->FirstMaterial(); i != matsystem->InvalidMaterial(); i = matsystem->NextMaterial(i)) {
IMaterial* material = matsystem->GetMaterial(i);
// No Sky
if (!strcmp(material->GetTextureGroupName(), TEXTURE_GROUP_SKYBOX)) {
if (GUI::NoSky::Enabled) {
material->ColorModulate(GUI::NoSky::Color[0], GUI::NoSky::Color[1], GUI::NoSky::Color[2]);
} else {
material->ColorModulate(1, 1, 1);
}
continue;
}
}
}
// Call original 'IBaseClientDLL::FrameStageNotify'.
oFrameStageNotify(thisptr, stage);
}