如何在 JOGL 中使用 glDrawBuffers?
How to use glDrawBuffers with JOGL?
用C++写的OpenGL代码是这样的:
static const GLenum buffs[] = { GL_COLOR_ATTACHMENT0 };
glDrawBuffers(1, buffs);
而且我在 JOGL 中发现了相同的 API:
gl.glDrawBuffers(int n, IntBuffer bufs)
我不知道如何使用此方法将上面的 C++ 代码移植到 JOGL。有谁知道?谢谢
您可以像在 C++ 中一样使用它
IntBuffer buffer = BufferUtil.newIntBuffer(1);
buffer.put(GL.GL_COLOR_ATTACHMENT0);
gl.glDrawBuffers(1, buffer);
基于documentation, there are two overloaded entry points for glDrawBuffers()
in JOGL. There's the one you already saw with the IntBuffer
argument, but also this one:
void glDrawBuffers(int n,
int[] bufs,
int bufs_offset)
它采用绘制缓冲区值数组以及数组中的偏移量。如果值位于数组的开头,则偏移量将为 0。因此您的调用变为:
int buffs[] = {GL.GL_COLOR_ATTACHMENT0};
gl.glDrawBuffers(1, buffs, 0);
那
呢
gl.glDrawBuffers(1,new int[]{GL.GL_COLOR_ATTACHMENT0},0);
用C++写的OpenGL代码是这样的:
static const GLenum buffs[] = { GL_COLOR_ATTACHMENT0 };
glDrawBuffers(1, buffs);
而且我在 JOGL 中发现了相同的 API:
gl.glDrawBuffers(int n, IntBuffer bufs)
我不知道如何使用此方法将上面的 C++ 代码移植到 JOGL。有谁知道?谢谢
您可以像在 C++ 中一样使用它
IntBuffer buffer = BufferUtil.newIntBuffer(1);
buffer.put(GL.GL_COLOR_ATTACHMENT0);
gl.glDrawBuffers(1, buffer);
基于documentation, there are two overloaded entry points for glDrawBuffers()
in JOGL. There's the one you already saw with the IntBuffer
argument, but also this one:
void glDrawBuffers(int n,
int[] bufs,
int bufs_offset)
它采用绘制缓冲区值数组以及数组中的偏移量。如果值位于数组的开头,则偏移量将为 0。因此您的调用变为:
int buffs[] = {GL.GL_COLOR_ATTACHMENT0};
gl.glDrawBuffers(1, buffs, 0);
那
呢gl.glDrawBuffers(1,new int[]{GL.GL_COLOR_ATTACHMENT0},0);