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

如何使用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.

图片转代码服务由CSDN问答提供 功能建议

使用“ github.com/go-gl/gl/v4.5-core/gl”的golang绑定 设置color_attachments数组如下:

  //指定要绘制到的颜色缓冲区列表
func DrawBuffers(n int32,bufs * uint32){
 C  .glowDrawBuffers(gpDrawBuffers,(C.GLsizei)(n),(* C.GLenum)(unsafe.Pointer(bufs)))
} 
   
 
 

在 c ++,您可以这样操作:

  //将“ renderedTexture”设置为我们的颜色附件#0 
glFramebufferTexture(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0,renderedTexture,0); 
 
 /  /设置绘制缓冲区的列表。
GLenum DrawBuffers [1] = {GL_COLOR_ATTACHMENT0}; 
glDrawBuffers(1,DrawBuffers);  //“ 1”是DrawBuffers的大小
   
 
 

我一辈子都无法弄清楚如何将缓冲区数组传递给它 ,我们将不胜感激。

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

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

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题