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

// 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)))
}

在c ++中,您可以这样做:
// 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

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

最佳答案

将指针传递到第一个元素:gl.DrawBuffers(int32(len(attachments)), &attachments[0])。我希望这回答了你的问题。

完整示例:https://github.com/Kugelschieber/go-game/blob/e88c16372587ddb958753bf70fde9de4babf65df/fbo.go

关于opengl - 如何使用openGL的golang绑定(bind)定义gl.DrawBuffers COLOR_ATTACHMENTi,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48938955/

10-10 14:05