Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Opengl 如何使用多采样FBO_Opengl_Textures_Lwjgl_Fbo_Multisampling - Fatal编程技术网

Opengl 如何使用多采样FBO

Opengl 如何使用多采样FBO,opengl,textures,lwjgl,fbo,multisampling,Opengl,Textures,Lwjgl,Fbo,Multisampling,注意:我使用的是LWJGL 以下是我创建新FBO的代码: /** * Creates a new FBO. * @param width The width of the FBO to create. * @param height The height of the FBO to create. * @return an int[] array containing the buffer IDs in the * following order: {frameBufferID, c

注意:我使用的是LWJGL

以下是我创建新FBO的代码:

/**
 * Creates a new FBO.
 * @param width The width of the FBO to create.
 * @param height The height of the FBO to create.
 * @return an int[] array containing the buffer IDs in the 
 * following order: {frameBufferID, colorBufferID (texture), depthBufferID}.
 */
public static int[] newFBO(int width, int height) {
    int[] out = new int[3];
    out[0] = glGenFramebuffersEXT();
    out[1] = glGenTextures();
    out[2] = glGenRenderbuffersEXT();

    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, out[0]);

    glBindTexture(GL_TEXTURE_2D, out[1]);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, org.lwjgl.opengl.GL12.GL_TEXTURE_MAX_LEVEL,20);
    glTexParameteri(GL_TEXTURE_2D, GL14.GL_GENERATE_MIPMAP,GL_TRUE);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0,GL_RGBA, GL_INT, (java.nio.ByteBuffer) null);
    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_TEXTURE_2D, out[1], 0);

    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, out[2]);
    glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL14.GL_DEPTH_COMPONENT24, width, height);
    glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,GL_DEPTH_ATTACHMENT_EXT,GL_RENDERBUFFER_EXT, out[2]);

    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

    return out;
}
以下是我如何将FBO绘制到屏幕上:

public static void rectOnScreen(int tex) {
    glBindTexture(GL_TEXTURE_2D, tex);
    glDisable(GL_DEPTH_TEST);
    glEnable(GL_TEXTURE_2D);
    glLoadIdentity();
    glBegin(GL_QUADS);
    glTexCoord2f(0, 0);
    glVertex2f(-1, -1);
    glTexCoord2f(0, 1);
    glVertex2f(-1, 1);
    glTexCoord2f(1, 1);
    glVertex2f(1, 1);
    glTexCoord2f(1, 0);
    glVertex2f(1, -1);
    glEnd();
    glDisable(GL_TEXTURE_2D);
    glEnable(GL_DEPTH_TEST);
}
基本上,我使用out[2]作为该函数的参数

现在,我如何在这里应用多重采样?我真的不喜欢我所得到的结果的锯齿状外观。我想在绘制FBO时采集多个样本。我很乐意把代码写出来,但我想一个教程或其他东西的链接也可以