I'm trying to set up a frame buffer object but I am getting errors. glGenFramebuffers is always undeclared, as are other similar things like glBindFramebuffer.
I believe that the problem is import related, but am unsure how to go about fixing this. There is a chance that glew might not be set up properly but I haven't found a simple explanation of how to set this up fully.
Here is the code that fails.
myBuffer = 0;
glGenFramebuffers(1, &myBuffer);
glBindFramebuffer(GL_FRAMEBUFFER, myBuffer);
glGenTextures(1, &renderedTexture);
// Bind to new texture
glBindTexture(GL_TEXTURE_2D, renderedTexture);
// Blank image
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGB, 1024, 768, 0,GL_RGB, GL_UNSIGNED_BYTE, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glGenRenderbuffers(1, &dBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, dBuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, 1024, 768);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, dBuffer);
// Set "renderedTexture" as colour attachement #0
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, renderedTexture, 0);
DrawBuffers[2] = {GL_COLOR_ATTACHMENT0};
glDrawBuffers(1, DrawBuffers); // "1" is the size of DrawBuffers
// Check framebuffer is ok
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
return false;
These are my imports
#include "WindowingSystem.h"
#include <math.h>
#include <vector>
#include <windows.h>
#include <GL/glut.h>
#include <iostream>
#include <string>
#include <sstream>
#include <windows.h>
#include <mmsystem.h>
#include <GL/glu.h>
#include <GL/gl.h>
Here are my linkers -lglut32 -lglu32 -lglew32 -lopengl32 -lwinmm
And here is a link to an image of my compiler options https://dl.dropboxusercontent.com/u/13330596/info.png
I am using 32 bit version of Dev C++ on a windows machine
Here is a link to the entire code file https://dl.dropboxusercontent.com/u/13330596/Exercise1.cpp
Please ask for any more information
You seem to already properly link against glew32.lib
, but I don't see you actually including <GL/glew.h>
instead of <GL/gl.h>
. The latter only declares functions up to OpenGL 1.1, while the former provides declarations for all extensions and core functionality >1.1 (like FBOs).