Browse Source

imgui extension

small imgui extension
scene palette shader crashfix
legacy
touky 8 years ago
parent
commit
f52db94b51
3 changed files with 44 additions and 3 deletions
  1. +22
    -0
      src/lolimgui.cpp
  2. +17
    -1
      src/lolimgui.h
  3. +5
    -2
      src/scene.cpp

+ 22
- 0
src/lolimgui.cpp View File

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


using namespace lol; 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") #define Line(s) ((s) + "\n")


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


+ 17
- 1
src/lolimgui.h View File

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


#include "imgui.h" #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 namespace lol
{ {


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


+ 5
- 2
src/scene.cpp View File

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


if (!data->m_tile_api.m_shader) if (!data->m_tile_api.m_shader)
data->m_tile_api.m_shader = Shader::Create(LOLFX_RESOURCE_NAME(gpu_tile)); 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)); data->m_tile_api.m_palette_shader = Shader::Create(LOLFX_RESOURCE_NAME(gpu_palette));


for (int p = 0; p < 2; p++) 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)); shader->SetUniform(uni_mat, mat4(1.f));


uni_tex = shader->GetUniformLocation("u_texture"); 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"); uni_texsize = shader->GetUniformLocation("u_texsize");


for (int buf = 0, i = 0, n; i < tiles.count(); i = n, buf += 2) 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(); tiles.empty();


shader->Unbind(); shader->Unbind();

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


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


Loading…
Cancel
Save