OpenGL 3.1和Oculus Rift的glFramebufferTexture的替代品 [英] Alternative to glFramebufferTexture for OpenGL version 3.1 and Oculus Rift
问题描述
因此,Oculus Rift SDK接受使用 glFramebufferTexture 函数创建的帧缓冲纹理ID.
So the Oculus Rift SDK accepts a framebuffer texture ID which is created with the glFramebufferTexture function.
示例:
[...]
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+中可用.
However, the glFramebufferTexture function is only available in OpenGL 3.2+.
是否可以创建一种在功能上与Oculus Rift SDK等效并可以接受的解决方法?
Is it possible to create a workaround that will be functionally equivalent and acceptable to the Oculus Rift SDK?
推荐答案
使用glFramebufferTexture2D()
.自OpenGL 3.0引入原始帧缓冲对象(FBO)功能以来,该功能便已可用.
Use glFramebufferTexture2D()
. That function has been available since OpenGL 3.0, when the original framebuffer object (FBO) functionality was introduced.
glFramebufferTexture()
,用于涉及立方体贴图和纹理阵列的更高级的FBO用例.对于简单的2D纹理,它基本上等效于glFramebufferTexture2D()
.
glFramebufferTexture()
was added later for more advanced FBO use cases involving cube maps and texture arrays. For simple 2D textures, it's mostly equivalent to glFramebufferTexture2D()
.
这篇关于OpenGL 3.1和Oculus Rift的glFramebufferTexture的替代品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!