Skip to content

Commit

Permalink
Fix api_blueprint for headless.
Browse files Browse the repository at this point in the history
  • Loading branch information
saurtron committed Dec 21, 2024
1 parent 1ad515e commit 055ca0a
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions luaui/Widgets/api_blueprint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ local function makeInstanceVBO(layout, vertexVBO, numVertices)
end

local function initGL4()
if not gl.CreateShader then
return
end
local outlineVBO, outlineVertices = makeOutlineVBO()
outlineInstanceVBO = makeInstanceVBO(outlineInstanceVBOLayout, outlineVBO, outlineVertices)

Expand Down Expand Up @@ -527,6 +530,9 @@ local BUILD_MODES_HANDLERS = {
local instanceIDs = {}

local function clearInstances()
if not gl.CreateShader then
return
end
clearInstanceTable(outlineInstanceVBO)

if WG.StopDrawUnitShapeGL4 then
Expand Down Expand Up @@ -611,6 +617,9 @@ end
---@param buildPositions StartPoints
---@param teamID number
local function updateInstances(blueprint, buildPositions, teamID)
if not gl.CreateShader then
return
end
if not blueprint or not buildPositions then
clearInstances()
return
Expand Down Expand Up @@ -668,6 +677,9 @@ local function drawOutlines()
end

function widget:DrawWorldPreUnit()
if not gl.CreateShader then
return
end
if not activeBlueprint then
return
end
Expand Down Expand Up @@ -725,17 +737,7 @@ local function setActiveBuilders(unitIDs)
end

function widget:Initialize()
if not gl.CreateShader then
-- no shader support, so just remove the widget itself, especially for headless
widgetHandler:RemoveWidget()
return
end

if not initGL4() then
-- shader compile failed
widgetHandler:RemoveWidget()
return
end
initGL4()

WG["api_blueprint"] = {
setActiveBlueprint = setActiveBlueprint,
Expand All @@ -757,6 +759,9 @@ end
function widget:Shutdown()
WG["api_blueprint"] = nil

if not gl.CreateShader then
return
end
clearInstances()

if outlineInstanceVBO and outlineInstanceVBO.VAO then
Expand Down

0 comments on commit 055ca0a

Please sign in to comment.