Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Alternative to glFramebufferTexture for OpenGL version 3.1

  1. #1
    Junior Member Regular Contributor
    Join Date
    Apr 2014
    Posts
    109

    Alternative to glFramebufferTexture for OpenGL version 3.1

    Hello,

    I am trying to create an OpenGL 3.1 application for the Oculus Rift and one item it seems to require is a frame buffer texture but the function glFramebufferTexture is available for versions 3.2 and higher.

    Is there a function that mimics this via a hack or something for OpenGL 3.1?

    Thank you for your time.

  2. #2
    Member Regular Contributor Agent D's Avatar
    Join Date
    Sep 2011
    Location
    Innsbruck, Austria
    Posts
    281
    glFramebufferTexture2D for your case??

    Framebuffer objects are part of core OpenGL(R) since version 3.0 (or previous via an extension).

    It is true that the glFramebufferTexture function is only available in 3.2, but the specialized glFramebufferTextureND are available in 3.1.

    I don't see where your problem is. The simplest way would be to set up an FBO with a 2D texture color buffer attachment. One for the left eye and one for the right
    eye. The resulting textures are rendered on two quads with a distortion applied for the Rift and that should be it.

  3. #3
    Junior Member Regular Contributor
    Join Date
    Apr 2014
    Posts
    109
    Quote Originally Posted by Agent D View Post
    glFramebufferTexture2D for your case??

    Framebuffer objects are part of core OpenGL(R) since version 3.0 (or previous via an extension).

    It is true that the glFramebufferTexture function is only available in 3.2, but the specialized glFramebufferTextureND are available in 3.1.

    I don't see where your problem is. The simplest way would be to set up an FBO with a 2D texture color buffer attachment. One for the left eye and one for the right
    eye. The resulting textures are rendered on two quads with a distortion applied for the Rift and that should be it.

    Thank you. I was just trying to use the built in Oculus Rift SDK which takes the ID of the function.

    Example below:

    Code :
    	[...]
     
    	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;
     
    	[...]

  4. #4
    Junior Member Regular Contributor
    Join Date
    Apr 2014
    Posts
    109
    Quote Originally Posted by Agent D View Post
    glFramebufferTexture2D for your case??

    Framebuffer objects are part of core OpenGL(R) since version 3.0 (or previous via an extension).

    It is true that the glFramebufferTexture function is only available in 3.2, but the specialized glFramebufferTextureND are available in 3.1.

    I don't see where your problem is. The simplest way would be to set up an FBO with a 2D texture color buffer attachment. One for the left eye and one for the right
    eye. The resulting textures are rendered on two quads with a distortion applied for the Rift and that should be it.
    glFramebufferTexture2D works. Thank you.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •