Альтернатива glFramebufferTexture для OpenGL версии 3.1 и Oculus Rift.

Таким образом, Oculus Rift SDK принимает идентификатор текстуры буфера кадра, созданный с помощью функции glFramebufferTexture.

Пример:

    [...]

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?


person user3434662    schedule 11.05.2014    source источник


Ответы (1)


Используйте 1_. Эта функция была доступна начиная с OpenGL 3.0, когда была введена функциональность оригинального объекта кадрового буфера (FBO).

glFramebufferTexture() был добавлен позже для более продвинутых вариантов использования FBO, включающих кубические карты и массивы текстур. Для простых 2D-текстур это в основном эквивалентно glFramebufferTexture2D().

person Reto Koradi    schedule 11.05.2014
comment
Спасибо. Вот что работает в SDK как замена! - person user3434662; 12.05.2014