-
-
Save salinecitrine/c7633fc6053d20bcd907d4dfae8bc436 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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