Skip to content

Instantly share code, notes, and snippets.

@salinecitrine
Created April 14, 2024 10:10
Show Gist options
  • Save salinecitrine/c7633fc6053d20bcd907d4dfae8bc436 to your computer and use it in GitHub Desktop.
Save salinecitrine/c7633fc6053d20bcd907d4dfae8bc436 to your computer and use it in GitHub Desktop.
function widget:GetInfo()
return {
name = "Geo Feature Engine Crash Reproducer",
desc = "-",
license = "GNU GPL, v2 or later",
layer = 0,
enabled = false
}
end
local function getGeoFeatureID()
for _, featureID in ipairs(Spring.GetAllFeatures()) do
local featureDefID = Spring.GetFeatureDefID(featureID)
if featureDefID then
local featureDef = FeatureDefs[featureDefID]
if featureDef.name == "geovent" or featureDef.name == "geocrack" then
return featureID
end
end
end
end
local vao
local function run(featureID)
local vertexVBO = gl.GetVBO(GL.ARRAY_BUFFER, true)
local vertexVboLayout = { { id = 0, name = "x", size = 1 } }
local vboData = { 0 }
vertexVBO:Define(#vboData, vertexVboLayout)
vertexVBO:Upload(vboData)
local instanceVBOLayout = { { id = 1, name = "instData", size = 4, type = GL.UNSIGNED_INT } }
local instanceVBO = gl.GetVBO(GL.ARRAY_BUFFER, true)
instanceVBO:Define(
1,
instanceVBOLayout
)
vao = gl.GetVAO()
vao:AttachVertexBuffer(vertexVBO)
vao:AttachInstanceBuffer(instanceVBO)
instanceVBO:Upload({ 0, 0, 0, 0 }, nil, 0)
-- crash
instanceVBO:InstanceDataFromFeatureIDs(featureID, 1, 0)
end
function widget:Initialize()
local geoFeatureID = getGeoFeatureID()
if geoFeatureID then
Spring.Echo("Found geo with id " .. geoFeatureID)
run(geoFeatureID)
else
Spring.Echo("Could not find a geo")
end
end
function widget:Shutdown()
if vao then
vao:Delete()
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment