Skip to content

Commit 6a5a3a8

Browse files
committed
fixed shader textures and argb colors
1 parent bc67d44 commit 6a5a3a8

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

LuaSTG/Core/Graphics/Renderer_Shader_OpenGL.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ namespace Core::Graphics
363363

364364
GLint amt_uniforms = 0;
365365
glGetProgramiv(opengl_prgm, GL_ACTIVE_UNIFORMS, &amt_uniforms);
366+
glUseProgram(opengl_prgm);
366367

367-
GLint amt_samplers = 0;
368368
GLuint tex_idx = 0;
369369

370370
for (GLuint uniform = 0; uniform < amt_uniforms; uniform++)
@@ -383,8 +383,10 @@ namespace Core::Graphics
383383
{
384384
LocalTexture2D local_texture2d;
385385
local_texture2d.index = tex_idx;
386-
tex_idx++;
387386

387+
glUniform1i(uniform, tex_idx);
388+
389+
tex_idx++;
388390
m_texture2d_map.emplace(name, std::move(local_texture2d));
389391
}
390392
else // Handle Uniform Buffers

LuaSTG/Core/Type.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,11 @@ namespace Core
192192
uint8_t a;
193193

194194
Color4B() : r(0), g(0), b(0), a(0) {}
195-
Color4B(uint32_t ARGB) : r(0), g(0), b(0), a(0) { color(ARGB); }
195+
Color4B(uint32_t ARGB) : r(ARGB >> 16 & 255), g(ARGB >> 8 & 255), b(ARGB & 255), a(ARGB >> 24 & 255) {}
196196
Color4B(uint8_t const r_, uint8_t const g_, uint8_t const b_) : r(r_), g(g_), b(b_), a(static_cast<uint8_t>(255u)) {}
197197
Color4B(uint8_t const r_, uint8_t const g_, uint8_t const b_, uint8_t const a_) : r(r_), g(g_), b(b_), a(a_) {}
198198

199-
inline void color(uint32_t ARGB) noexcept { *((uint32_t*)(&r)) = ARGB; }
199+
inline void color(uint32_t ABGR) noexcept { *((uint32_t*)(&r)) = ABGR; }
200200
inline uint32_t color() const noexcept { return *((uint32_t*)(&r)); }
201201

202202
bool operator==(Color4B const& right) const noexcept

LuaSTG/LuaSTG/LuaBinding/LW_Render.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void LuaSTGPlus::LuaWrapper::RenderWrapper::Register(lua_State* L) noexcept
2222
))
2323
{
2424
return luaL_error(L, "can't draw text '%s'.", luaL_checkstring(L, 1));
25-
}
25+
}
2626
return 0;
2727
}
2828
static int RenderTTF(lua_State* L) noexcept
@@ -36,7 +36,7 @@ void LuaSTGPlus::LuaWrapper::RenderWrapper::Register(lua_State* L) noexcept
3636
(float)luaL_checknumber(L, 6),
3737
LRES.GetGlobalImageScaleFactor() * (float)luaL_optnumber(L, 9, 1.0),
3838
luaL_checkinteger(L, 7),
39-
*LuaWrapper::ColorWrapper::Cast(L, 8)
39+
*ColorWrapper::Cast(L, 8)
4040
))
4141
{
4242
return luaL_error(L, "can't render font '%s'.", luaL_checkstring(L, 1));
@@ -69,7 +69,7 @@ void LuaSTGPlus::LuaWrapper::RenderWrapper::Register(lua_State* L) noexcept
6969
// group color
7070
LPOOL.DrawGroupCollider2(
7171
luaL_checkinteger(L, 1),
72-
*LuaWrapper::ColorWrapper::Cast(L, 2)
72+
*ColorWrapper::Cast(L, 2)
7373
);
7474
return 0;
7575
}

0 commit comments

Comments
 (0)