dousi1961 2016-05-03 12:13
浏览 210
已采纳

glEnableVertexArrayAttrib生成的段错误

I'm writing a simple OpenGL program using go-gl. While the program runs fine on most machines, it fails with a segfault when running under Windows on my laptop (it works on Linux though - this is what's odd about it). The culprit is my call to glEnableVertexArrayAttrib. I've attached the stack trace and relevant code below.

Partial stack trace:

Exception 0xc0000005 0x8 0x0 0x0
PC=0x0
signal arrived during external code execution

github.com/go-gl/gl/v3.3-core/gl._Cfunc_glowEnableVertexArrayAttrib(0x0, 0x1)
    github.com/go-gl/gl/v3.3-core/gl/_obj/_cgo_gotypes.go:4141 +0x41
github.com/go-gl/gl/v3.3-core/gl.EnableVertexArrayAttrib(0x1)
    C:/Users/mpron/go/src/github.com/go-gl/gl/v3.3-core/gl/package.go:5874 +0x3a
github.com/caseif/cubic-go/graphics.prepareVbo(0x1, 0xc0820086e0, 0xc0820a7e70)
    C:/Users/mpron/go/src/github.com/caseif/cubic-go/graphics/block_renderer.go:145 +0x108

Relevant code:

gl.GenVertexArrays(1, &vaoHandle)
gl.BindVertexArray(vaoHandle)
gl.BindBuffer(gl.ARRAY_BUFFER, handle)
gl.BufferData(gl.ARRAY_BUFFER, len(*vbo) * 4, gl.Ptr(*vbo), gl.STATIC_DRAW)
gl.EnableVertexArrayAttrib(vaoHandle, positionAttrIndex) // line 145
gl.VertexAttribPointer(positionAttrIndex, 3, gl.FLOAT, false, 12, nil)
  • 写回答

1条回答 默认 最新

  • dqsong2010 2016-05-03 13:16
    关注

    I made a subtle mistake in calling glEnableVertexArrayAttrib, only available since OpenGL 4.5, instead of glEnableVertexAttribArray, which is available since OpenGL 2.1. The former function allows attribute arrays to be toggled on a per-VAO basis, which isn't at all necessary in this context.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵