Quellcode durchsuchen

imgui extension

small imgui extension
scene palette shader crashfix
legacy
touky vor 8 Jahren
Ursprung
Commit
f52db94b51
3 geänderte Dateien mit 44 neuen und 3 gelöschten Zeilen
  1. +22
    -0
      src/lolimgui.cpp
  2. +17
    -1
      src/lolimgui.h
  3. +5
    -2
      src/scene.cpp

+ 22
- 0
src/lolimgui.cpp Datei anzeigen

@@ -18,6 +18,28 @@

using namespace lol;

//Imgui extension ---------------------------------------------------------------------------------
namespace ImGui
{
IMGUI_API void SetNextWindowSizeAndDock(const ImVec2& size, ImGuiSetDock dock, ImGuiSetCond cond)
{
vec2 video_size = vec2(Video::GetSize());
ImVec2 pos = ImVec2();

switch (dock)
{
case ImGuiSetDock_TopLeft: pos = ImVec2(0, 0); break;
case ImGuiSetDock_TopRight: pos = ImVec2(video_size.x - size.x, 0); break;
case ImGuiSetDock_BottomLeft: pos = ImVec2(0, video_size.y - size.y); break;
case ImGuiSetDock_BottomRight: pos = ImVec2(video_size.x - size.x, video_size.y - size.y); break;
}

ImGui::SetNextWindowPos(pos, cond);
ImGui::SetNextWindowSize(size, cond);
}
}

//LolImGui ----------------------------------------------------------------------------------------
#define Line(s) ((s) + "\n")

//-----------------------------------------------------------------------------


+ 17
- 1
src/lolimgui.h Datei anzeigen

@@ -14,10 +14,26 @@

#include "imgui.h"

//Imgui extension ---------------------------------------------------------------------------------
typedef int ImGuiSetDock; // condition flags for Set*() // enum ImGuiSetCond_

enum ImGuiSetDock_
{
ImGuiSetDock_TopLeft = 0,
ImGuiSetDock_TopRight = 1,
ImGuiSetDock_BottomLeft = 2,
ImGuiSetDock_BottomRight = 3,
};

namespace ImGui
{
IMGUI_API void SetNextWindowSizeAndDock(const ImVec2& size, ImGuiSetDock dock, ImGuiSetCond cond = 0);
}

//LolImGui ----------------------------------------------------------------------------------------
namespace lol
{

//LolImGui --------------------------------------------------------------------
class LolImGui : public Entity
{
typedef Entity super;


+ 5
- 2
src/scene.cpp Datei anzeigen

@@ -723,7 +723,7 @@ void Scene::render_tiles() // XXX: rename to Blit()

if (!data->m_tile_api.m_shader)
data->m_tile_api.m_shader = Shader::Create(LOLFX_RESOURCE_NAME(gpu_tile));
if (!data->m_tile_api.m_palette_shader)
if (!data->m_tile_api.m_palette_shader && data->m_tile_api.m_palettes.count())
data->m_tile_api.m_palette_shader = Shader::Create(LOLFX_RESOURCE_NAME(gpu_palette));

for (int p = 0; p < 2; p++)
@@ -749,7 +749,7 @@ void Scene::render_tiles() // XXX: rename to Blit()
shader->SetUniform(uni_mat, mat4(1.f));

uni_tex = shader->GetUniformLocation("u_texture");
uni_pal = data->m_tile_api.m_palette_shader->GetUniformLocation("u_palette");
uni_pal = data->m_tile_api.m_palette_shader ? data->m_tile_api.m_palette_shader->GetUniformLocation("u_palette") : ShaderUniform();
uni_texsize = shader->GetUniformLocation("u_texsize");

for (int buf = 0, i = 0, n; i < tiles.count(); i = n, buf += 2)
@@ -809,6 +809,9 @@ void Scene::render_tiles() // XXX: rename to Blit()
tiles.empty();

shader->Unbind();

if (!data->m_tile_api.m_palette_shader)
break;
}

#if (defined LOL_USE_GLEW || defined HAVE_GL_2X) && !defined HAVE_GLES_2X


Laden…
Abbrechen
Speichern