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: GL_INVALID_OPERATION at glFramebufferTexture2DEXT

  1. #1
    Intern Newbie
    Join Date
    Jun 2009
    Posts
    40

    GL_INVALID_OPERATION at glFramebufferTexture2DEXT

    I'm trying to get a basic FBO up and running, but I'm getting a GL_INVALID_OPERATION error when trying to assign a texture to the FBO. I'm on WindowsXP and am programming in Freepascal with SDL as the context wrapper. Here's a code snippet:

    Code :
       glEnable(GL_TEXTURE_2D);
       glClearColor(0.0, 0.0, 0.0, 0.0);
       glViewport(0, 0, 800, 600);
       glClear(GL_COLOR_BUFFER_BIT);
       glMatrixMode(GL_PROJECTION);
       glLoadIdentity();
       glOrtho(0.0, 800, 600, 0.0, -1.0, 1.0);
       glMatrixMode(GL_MODELVIEW);
       glLoadIdentity();
       glEnable(GL_BLEND);
       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
       glDisable(GL_LIGHTING);
       glShadeModel(GL_SMOOTH);
     
    [...]
     
       TempSurface := IMG_Load('gfx/logo.png');
       glGenTextures(1, @TexID);
       glBindTexture(GL_TEXTURE_2D, TexID);
       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
       glTexImage2D(GL_TEXTURE_2D, 0, 4, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, TempSurface^.pixels);
       SDL_FreeSurface(TempSurface);
     
    [...]
     
       IF glext_LoadExtension('GL_EXT_framebuffer_object') THEN BEGIN
          glGenFramebuffersEXT(1, @FBO);
          glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBO);
    // NO ERROR HERE
          glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, TexID, 0);
    // GL_INVALID_OPERATION RETURNED HERE!
          glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
       END;

    I can't figure out what I'm doing wrong here...

  2. #2
    Intern Newbie
    Join Date
    Jun 2009
    Posts
    40
    I've narrowed it down to being an issue with the texture being assigned to the FBO. If I assign zero instead of a texture, I don't get the error. And then there's this (http://www.opengl.org/wiki/GLAPI/glFramebufferTexture):
    GL_INVALID_OPERATION​ is generated if textarget​ and texture​ are not compatible.
    Anybody have any idea how textarget and the texture are incompatible?

  3. #3
    Junior Member Regular Contributor
    Join Date
    Aug 2009
    Location
    Poland
    Posts
    111
    Quote Originally Posted by PP2005 View Post
    glTexImage2D(GL_TEXTURE_2D, 0, 4, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, TempSurface^.pixels);
    Which version of OpenGL are You using?
    Afaik old internal texture formats (1,2,3,4) are deprecated by GL 3.0, try GL_RGBA, or GL_RGB instead (third argument),
    also see paragraph 4.4.4 (Framebuffer completness and internal formats) of
    http://www.opengl.org/registry/specs...fer_object.txt

  4. #4
    Intern Newbie
    Join Date
    Jun 2009
    Posts
    40
    Yes, that did it! Thanks a bunch!

Posting Permissions

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