Jump to content
  • Advertisement
Sign in to follow this  
justthisguy

OpenGL fbo creation problem

This topic is 3741 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm trying to use framebuffer objects in my program but I'm running into a bit of a wall here: The problem seems to be that glew says that framebuffer objects are supported, but if I try to create one, I get the GL_FRAMEBUFFER_UNSUPPORTED_EXT error. Here's some code I've been trying:
#include "GL/glew.h"
#include "GL/gl.h"

#include "SDL/SDL.h"

#include <iostream>
using namespace std;

int main() {

  int width = 512;
  int height = 512;

  if( SDL_Init( SDL_INIT_EVERYTHING ) < 0 )  return 1;
  if( SDL_SetVideoMode( width, height, 32, SDL_OPENGL ) == NULL )  return 1;
  
  glewInit();
  
  cout << "framebuffer objects" << (GLEW_EXT_framebuffer_object ? " " : " not " ) << "supported.\n";
  
  GLuint fbo, tex;

  glGenFramebuffersEXT(1, &fbo);
  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);

  glGenTextures(1, &tex);
  glBindTexture(GL_TEXTURE_2D, tex);
  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);

  glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex, 0);

  GLenum status;
  if ((status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)) != GL_FRAMEBUFFER_COMPLETE_EXT) {
    switch (status) {
    case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
      cout << "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT" << endl; break;
    case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
      cout << "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT" << endl; break;
    case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
      cout << "GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT" << endl; break;
    case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
      cout << "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT" << endl; break;
    case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
      cout << "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT" << endl; break;
    case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
      cout << "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT" << endl; break;
    case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
      cout << "GL_FRAMEBUFFER_UNSUPPORTED_EXT" << endl; break;
    default:
      cout << "ouch" << endl; break;
    } 
    
  }

  return 0;
  
}

Any help would be much appreciated. I guess I must have left something out but I can't see what. Many thanks! :)

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!