【问题标题】:Alternative to glFramebufferTexture for OpenGL version 3.1 and Oculus RiftOpenGL 3.1 版和 Oculus Rift 的 glFramebufferTexture 的替代品
【发布时间】:2014-05-12 23:15:29
【问题描述】:

因此 Oculus Rift SDK 接受使用 glFramebufferTexture 函数创建的帧缓冲区纹理 ID。

例子:

    [...]

GLuint l_FBOId;
glGenFramebuffers(1, &l_FBOId);
glBindFramebuffer(GL_FRAMEBUFFER, l_FBOId);

// The texture we're going to render to...
GLuint l_TextureId;
glGenTextures(1, &l_TextureId);
// "Bind" the newly created texture : all future texture functions will modify this texture...
glBindTexture(GL_TEXTURE_2D, l_TextureId);
// Give an empty image to OpenGL (the last "0")
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, l_TextureSize.w, l_TextureSize.h, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
// Linear filtering...
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

// Create Depth Buffer...
GLuint l_DepthBufferId;
glGenRenderbuffers(1, &l_DepthBufferId);
glBindRenderbuffer(GL_RENDERBUFFER, l_DepthBufferId);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, l_TextureSize.w, l_TextureSize.h);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, l_DepthBufferId);

[...]

/*

Oculus Rift API

*/

ovrGLTexture l_EyeTexture[2];
l_EyeTexture[0].OGL.Header.API = ovrRenderAPI_OpenGL;
l_EyeTexture[0].OGL.Header.TextureSize.w = l_TextureSize.w;
l_EyeTexture[0].OGL.Header.TextureSize.h = l_TextureSize.h;
l_EyeTexture[0].OGL.Header.RenderViewport = l_Eyes[0].RenderViewport;
l_EyeTexture[0].OGL.TexId = l_TextureId;

[...]

但是,glFramebufferTexture 函数仅在 OpenGL 3.2+ 中可用。

是否可以创建一个在功能上与 Oculus Rift SDK 相同且可接受的解决方法?

【问题讨论】:

    标签: opengl oculus


    【解决方案1】:

    使用glFramebufferTexture2D()。该功能从 OpenGL 3.0 开始可用,当时引入了原始帧缓冲区对象 (FBO) 功能。

    glFramebufferTexture() 后来被添加用于涉及立方体贴图和纹理数组的更高级的 FBO 用例。对于简单的 2D 纹理,它几乎等同于 glFramebufferTexture2D()

    【讨论】:

    • 谢谢。这就是 SDK 中的替代品!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-10
    • 2017-06-10
    相关资源
    最近更新 更多