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 6 of 6

Thread: Framebuffer problems

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2016
    Posts
    19

    Framebuffer problems

    Im trying to render to a texture (shadowmap) but if I try to generate the framebuffer I always get GL_UNSUPORTED_FRAMEBUFFER_EXT.
    I have a Nvidia GPU (GTX950 oc).

    Texture generation :
    Code :
    void GenEmtyTexture(int sizeX, int sizeY, GLuint * ID, GLubyte * imagePtr, int unbind, int colorMode0, int colorMode1, GLuint dataType, GLint activeTexture, char mipmap)
    {
      //imagePtr should have enougth/be NULL memory...
      printf("Generating texture...\n");
      glGenTextures(1, ID);
      glActiveTexture(activeTexture);
      glBindTexture(GL_TEXTURE_2D, *ID);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
     
      if(mipmap)
      {
        glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
      }
     
      glTexImage2D(GL_TEXTURE_2D, 0, colorMode0, sizeX, sizeY, 1, colorMode1, dataType, imagePtr);
     
      printf("ERROR : %s\n", gluErrorString( glGetError() ) );
      if(unbind)
      {
        glBindTexture(GL_TEXTURE_2D, 0);
      }
    }
    I use it like this :
    Code :
    GenEmtyTexture(2048, 2048, &textureIDs[0], NULL, 0, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, GL_TEXTURE0, 1);

    This is how I generate the FBO :
    Code :
    glGenFramebuffers(1, &frameBufferIDs[0]);
    glBindFramebuffer(GL_FRAMEBUFFER, frameBufferIDs[0]);
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureIDs[0], 0);
     
    printf("FRAMEBUFFERSTATUS : %x\n", glCheckFramebufferStatus(GL_FRAMEBUFFER));

    printf always prints : FRAMEBUFFERSTATUS : 8cdd -->
    Code :
    #define GL_FRAMEBUFFER_UNSUPPORTED_EXT    0x8CDD


    I read that this is Nvidia specific :
    Warning: NVIDIA's OpenGL driver has a known issue with using incomplete textures. If the texture is not texture complete, the FBO itself will be considered GL_FRAMEBUFFER_UNSUPPORTED​, or will have GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT​. This is a driver bug, as the OpenGL specification does not allow implementations to return either of these values simply because a texture is not yet complete. Until this is resolved in NVIDIA's drivers, it is advised to make sure that all textures have mipmap levels, and that all glTexParameteri​ values are properly set up for the format of the texture. For example, integral textures are not complete if the mag and min filters have any LINEAR fields.

    I dont know how to fix that.

  2. #2
    Intern Contributor
    Join Date
    Feb 2016
    Posts
    64
    Code :
    glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);

    This is deprecated : Use glGenerateMipmap() instead, after glTexImage2d().

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2016
    Posts
    19
    Still x8cdd --> GL_FRAMEBUFFER_UNSUPPORTED_EXT.

  4. #4
    Junior Member Regular Contributor
    Join Date
    May 2013
    Posts
    130
    You defined a min filter that uses mipmaps, but you did not create any mipmaps.

    With the "old style" glTexImage2D function you need to call it for every mipmap level.

    Untested example code:
    Code :
    int mipmapLevelX = sizeX;
    int mipmapLevelY = sizeY;
    int mipmapLevel  = 0;
    while (mipmapLevelX > 1 || mipmapLevelY > 1) {
        glTexImage2D(GL_TEXTURE_2D, mipmapLevel, colorMode0, mipmapLevelX, mipmapLevelY, 1, colorMode1, dataType, imagePtr);
        mipmapLevel++;
        mipmapLevelX = max(1, mipmapLevelX / 2);
        mipmapLevelY = max(1, mipmapLevelY / 2);
    }

    Also you have set border to 1. If I remember correctly that was already deprecated since OpenGL 3.2 core. But I don't know what version you use. And in compatibility mode that should work fine even in OpenGL 4.5.

  5. #5
    Member Regular Contributor
    Join Date
    Jul 2012
    Posts
    420
    Yes, there is a detailed example about it in the FBO specs (Read example 5).

  6. #6
    Junior Member Regular Contributor
    Join Date
    May 2013
    Posts
    130
    One more thing. If you use glGenerateMipmap or glGenerateMipmapEXT after creating the mipmap level 0 (your glTexImage2D), they create all other other mipmap levels from that. So in that case you don't need to manually crate every single mipmap level.

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
  •