如何使用 openGL 的 golang 绑定定义 gl.DrawBuffers COLOR_ATTACHMENTi
How to define gl.DrawBuffers COLOR_ATTACHMENTi with golang bindings for openGL
使用"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
使用"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