dt2002 2018-02-22 23:33
浏览 186
已采纳

如何使用openGL的golang绑定定义gl.DrawBuffers COLOR_ATTACHMENTi

Using "github.com/go-gl/gl/v4.5-core/gl" the golang bindings for setting the array of color_attachments is as follows:

// Specifies a list of color buffers to be drawn into
func DrawBuffers(n int32, bufs *uint32) {
    C.glowDrawBuffers(gpDrawBuffers, (C.GLsizei)(n), (*C.GLenum)(unsafe.Pointer(bufs)))
}

In c++ you would do this like:

// Set "renderedTexture" as our colour attachement #0
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, renderedTexture, 0);

// Set the list of draw buffers.
GLenum DrawBuffers[1] = {GL_COLOR_ATTACHMENT0};
glDrawBuffers(1, DrawBuffers); // "1" is the size of DrawBuffers

I can't for the life of me figure out how you are expected to pass an array of buffers to this and any help would be appreciated.

  • 写回答

1条回答 默认 最新

  • douweng3383 2018-02-23 13:28
    关注

    Pass a pointer to the first element: gl.DrawBuffers(int32(len(attachments)), &attachments[0]). I hope this answers your question.

    Full example: https://github.com/Kugelschieber/go-game/blob/e88c16372587ddb958753bf70fde9de4babf65df/fbo.go

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

报告相同问题?

悬赏问题

  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python