2

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

2 Answers2

5

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).

Christian Rau
  • 45,360
  • 10
  • 108
  • 185
  • OK so when I PUT GL/glew.h in I get an error with it and also another saying "84:2 C:\Dev-Cpp\include\GL\glew.h #error gl.h included before glew.h". I tried including glew before glu.h but then I get "Aborted (program collect2)" – Adam Kenworthy Apr 26 '13 at 11:14
  • @AdamKenworthy Try to also include it before `` (since I think that might bring in `gl.h`, too). – Christian Rau Apr 26 '13 at 11:21
  • Moving glew above glut gives me the same error about ordering. I have #include "WindowingSystem.h" at the top, which has #include inside itself. Does this mean that including windowingsystem also includes glut in my main file? – Adam Kenworthy Apr 26 '13 at 11:28
  • @AdamKenworthy Well, if it itself includes `glut.h`, then of course. Always keep in mind that including does nothing else but simple and stupid text replacement. – Christian Rau Apr 26 '13 at 12:20
  • I put glew.h in windowingSystem and get "Aborted (program collect2)". no other errors. So i really dont know where things are going wrong – Adam Kenworthy Apr 26 '13 at 13:07
  • @AdamKenworthy [This post](http://stackoverflow.com/questions/12811762/dev-c-in-windows-8-gcc-internal-error) seems to suggest the 'Aborted (program collect2)' problem is caused by an outdated version of mingw. Try to [update your installation](http://sourceforge.net/projects/orwelldevcpp/?source=directory). This version has the latest mingw included, and lots of bugfixes. The original dev-cpp hasn't been updated since 2005, but this version is up to date. – Kevin Apr 26 '13 at 13:12
  • @Kevin Downloaded and installed the new version, but I now it says "[Error] gl\glut.h: No such file or directory". Also should my compiler be the 64 bit tdm or minigw32? – Adam Kenworthy Apr 26 '13 at 14:01
  • @AdamKenworthy You can copy your old include/gl/ directory to your new installation. It should contain glut.h. If it doesn't or you already removed your old directory, reinstall glut. I'm not sure what you mean by '64 bit tdm', You are using the gcc/g++ compiler and mingw is a toolchain that includes a windows gcc/g++ version. – Kevin Apr 26 '13 at 14:26
  • @Kevin Things have gone horribly wrong, so I have reinstalled devcpp in an xp virtualbox. I have installed the glut package and the linkers are the same. I have installed to the program files/devcpp directory rather than c/devcpp. I have commented out the glew stuff. I get the error " [Error] gl\glut.h: No such file or directory". Any ideas? – Adam Kenworthy Apr 27 '13 at 09:56
  • @Kevin c:\dev-cpp\mingw64\x86_64-w64-mingw32\bin\ld.exe cannot find -lglut32 - This is my only current error. Glew seems to work, but glut does not. – Adam Kenworthy Apr 27 '13 at 18:35
0

I reinstalled DevCpp on my windows xp virtualbox. I then installed glut as normal, and the same with the glew devpack. It then worked straight away. I now use version 4.9.9.2