如何使用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.
使用“ github.com/go-gl/gl/v4.5-core/gl”的golang绑定 设置color_attachments数组如下: p>
//指定要绘制到的颜色缓冲区列表
func DrawBuffers(n int32,bufs * uint32){
C .glowDrawBuffers(gpDrawBuffers,(C.GLsizei)(n),(* C.GLenum)(unsafe.Pointer(bufs)))
}
code> pre>
在 c ++,您可以这样操作: p>
//将“ renderedTexture”设置为我们的颜色附件#0
glFramebufferTexture(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0,renderedTexture,0);
/ /设置绘制缓冲区的列表。
GLenum DrawBuffers [1] = {GL_COLOR_ATTACHMENT0};
glDrawBuffers(1,DrawBuffers); //“ 1”是DrawBuffers的大小
code> pre>
我一辈子都无法弄清楚如何将缓冲区数组传递给它 ,我们将不胜感激。 p>
div>
答
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