Skip to content

Commit

Permalink
Fix gl.ClearAttachmentFBO() doc and expose Platform.glVersionNum to Lua
Browse files Browse the repository at this point in the history
  • Loading branch information
lhog committed Feb 17, 2025
1 parent ef1aeac commit 81490a7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions rts/Lua/LuaConstPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ bool LuaConstPlatform::PushEntries(lua_State* L)
LuaPushNamedString(L, "gpuVendor", globalRenderingInfo.gpuVendor);
LuaPushNamedNumber(L, "gpuMemorySize", globalRenderingInfo.gpuMemorySize.x);
LuaPushNamedString(L, "glVersionShort", globalRenderingInfo.glVersionShort.data());
LuaPushNamedNumber(L, "glVersionNum", globalRenderingInfo.glVersionNum);
LuaPushNamedString(L, "glslVersionShort", globalRenderingInfo.glslVersionShort.data());
LuaPushNamedNumber(L, "glslVersionNum", globalRenderingInfo.glslVersionNum);

Expand Down
2 changes: 1 addition & 1 deletion rts/Lua/LuaFBOs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ namespace Impl {
}
}

/*** needs `Platform.glslVersionNum >= 300`
/*** needs `Platform.glVersionNum >= 30`
* Clears the "attachment" of the currently bound FBO type "target" with "clearValues"
*
* @function gl.ClearAttachmentFBO
Expand Down
3 changes: 3 additions & 0 deletions rts/Rendering/GlobalRendering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,9 @@ void CGlobalRendering::SetGLSupportFlags()
break;
}
}
if (int2 glVerNum = { 0, 0 }; sscanf(globalRenderingInfo.glVersionShort.data(), "%d.%d", &glVerNum.x, &glVerNum.y) == 2) {
globalRenderingInfo.glslVersionNum = glVerNum.x * 10 + glVerNum.y;
}

for (size_t n = 0; (n < sizeof(globalRenderingInfo.glslVersionShort) && globalRenderingInfo.glslVersion[n] != 0); n++) {
if ((globalRenderingInfo.glslVersionShort[n] = globalRenderingInfo.glslVersion[n]) == ' ') {
Expand Down
1 change: 1 addition & 0 deletions rts/Rendering/GlobalRenderingInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct GlobalRenderingInfo {
std::array<char, 256> glVersionShort = { 0 };
std::array<char, 256> glslVersionShort = { 0 };

int glVersionNum = 0;
int glslVersionNum = 0;

bool glContextIsCore;
Expand Down

0 comments on commit 81490a7

Please sign in to comment.