Sign in to follow this  
4mad3u5

OpenGL Compiling opengl code using gcc through the command line

Recommended Posts

4mad3u5    116

Hi, I do not want to use visual studio express because microsoft just wants your cc and they are trying to kill opengl so there is no point to use their compiler. So I want to use Dev C++ gcc from the command line to compile code instead of vs. I have three books that I am using to learn opengl: opengl programming guide, opengl supper bible 5, and interactive computer graphics. I have been able to get code to compile with vs but we are not able to compile using Dev C++ gcc. I have been working with two professors everyday for the last three months and we can't figure this out. 

The first program that I am working with is from SB5. If you want the source code and include folders that I am using you can get them from the supper bible site: www.openglsuperbible.com/previous-editions/ 5th edition I am in chapter 2 triangle. I expect the command line to be something like this: 

g++ -IF:\school\csci\opengl\SB5\Src\GLTools\include -IF:\school\csci\opengl\SB5\freeglut-2.6.0\include Triangle.cpp libglew32.a libfreeglut.a

I have put libglew32.a and libfreeglut.a in my working directory, and I still get a bunch of errors referencing lib files and if I take out the libglew32.a and libfreeglut.a from my command line I get the same error messages so it is for sure not linking to the correct libraries, so I have no idea what to do. Here is the code I am working with: 


// Triangle.cpp
// Our first OpenGL program that will just draw a triangle on the screen.

#include <GLTools.h> // OpenGL toolkit
#include <GLShaderManager.h> // Shader Manager Class

#ifdef __APPLE__
#include <glut/glut.h> // OS X version of GLUT
#else
#define FREEGLUT_STATIC 
#include <GL/glut.h> // Windows FreeGlut equivalent
#endif

GLBatch triangleBatch;
GLShaderManager shaderManager;

///////////////////////////////////////////////////////////////////////////////
// Window has changed size, or has just been created. In either case, we need
// to use the window dimensions to set the viewport and the projection matrix.
void ChangeSize(int w, int h)
{
glViewport(0, 0, w, h);
}


///////////////////////////////////////////////////////////////////////////////
// This function does any needed initialization on the rendering context. 
// This is the first opportunity to do any OpenGL related tasks.
void SetupRC()
{
// Blue background
glClearColor(0.0f, 0.0f, 1.0f, 1.0f );

shaderManager.InitializeStockShaders();

// Load up a triangle
GLfloat vVerts[] = { -0.5f, 0.0f, 0.0f, 
0.5f, 0.0f, 0.0f,
0.0f, 0.5f, 0.0f };

triangleBatch.Begin(GL_TRIANGLES, 3);
triangleBatch.CopyVertexData3f(vVerts);
triangleBatch.End();
}



///////////////////////////////////////////////////////////////////////////////
// Called to draw scene
void RenderScene(void)
{
// Clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

GLfloat vRed[] = { 1.0f, 0.0f, 0.0f, 1.0f };
shaderManager.UseStockShader(GLT_SHADER_IDENTITY, vRed);
triangleBatch.Draw();

// Perform the buffer swap to display back buffer
glutSwapBuffers();
}


///////////////////////////////////////////////////////////////////////////////
// Main entry point for GLUT based programs
int main(int argc, char* argv[])
{
gltSetWorkingDirectory(argv[0]);

glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL);
glutInitWindowSize(800, 600);
glutCreateWindow("Triangle");
glutReshapeFunc(ChangeSize);
glutDisplayFunc(RenderScene);

GLenum err = glewInit();
if (GLEW_OK != err) {
fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err));
return 1;
}

SetupRC();

glutMainLoop();
return 0;
}



Here is what happens right after I hit enter on the command line:

In file included from F:/school/csci/opengl/SB5/freeglut-2.6.0/include/GL/freeglut_std.h:121,
from F:/school/csci/opengl/SB5/freeglut-2.6.0/include/GL/glut.h:17,
from Triangle.cpp:11:
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:225: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:225: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:226: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:226: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:227: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:227: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:228: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:228: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:229: error: `GLAPI' does not name a type
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:230: error: `GLAPI' does not name a type
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:231: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:231: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:232: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:232: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:233: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:233: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:234: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:234: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:235: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:235: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:236: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:236: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:237: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:237: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:238: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:238: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:239: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:239: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:240: error: expected constructor, destructor, or type conversion b
efore "const"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:240: error: expected `,' or `;' before "const"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:241: error: expected constructor, destructor, or type conversion b
efore "const"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:241: error: expected `,' or `;' before "const"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:242: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:242: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:243: error: expected constructor, destructor, or type conversion b
efore "const"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:243: error: expected `,' or `;' before "const"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:244: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:244: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:245: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:245: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:246: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:246: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:247: error: `GLAPI' does not name a type
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:248: error: `GLAPI' does not name a type
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:249: error: `GLAPI' does not name a type
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:250: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:250: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:251: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:251: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:252: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:252: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:253: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:253: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:254: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:254: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:255: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:255: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:256: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:256: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:257: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:257: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:258: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:258: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:259: error: `GLAPI' does not name a type
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:260: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:260: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:261: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:261: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:262: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:262: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:263: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:263: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:264: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:264: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:265: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:265: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:266: error: `GLAPI' does not name a type
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:267: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:267: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:268: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:268: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:269: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:269: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:270: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:270: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:271: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:271: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:272: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:272: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:273: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:273: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:274: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:274: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:275: error: expected constructor, destructor, or type conversion b
efore "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:275: error: expected `,' or `;' before "void"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:276: error: `GLAPI' does not name a type
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/GL/glu.h:277: error: `GLAPI' does not name a type

Edited by 4mad3u5

Share this post


Link to post
Share on other sites
BitMaster    8651

There are plenty of good, valid reasons not to use MSVC. What you wrote up there is not among them.

 

That said, Dev-C++ is the most useless replacement you could pick. It's ancient, unmaintained and full of bugs. There are some forks of Dev-C++ which are still actively developed but other tools have several years of headstart on them.

Before using Dev-C++ I would rather use a current gcc without any extra help, just a text editor and the command line. gcc 3.4.2 (which is what you are using) is ten years old. For all intends and purposes it is completely useless to get something done nowadays. Whatever problems you have probably originate in obsolete tools.

 

Investigate Code::Blocks or QtCreator if you want a modern, free IDE. Several other options exist.

Share this post


Link to post
Share on other sites
Kaptein    2224

Its my instructors that are telling me to use Dev C++ 

 

Just because they are in a position to tell students what the world looks like, doesn't mean it's true. :)

 

For pure C++: Check out TDM-GCC project. It has an up to date GCC. Also mingw64, mingw-builds and so on.

For linux you only need to install g++.

http://tdm-gcc.tdragon.net/

 

You can also check out Qt: http://qt-project.org/

I don't particularly like Qts version of C++, but everything about Qt is easy, well documented, and "it just works." Which is more than you can say for absolutely everything else on particularly Linux.

 

If you are not fond of C++, consider using Python or Java.

You also have some (future) options in game development with HTML5 and all the almost-there stuff that changes every now and then.

 

 

There is also nothing wrong with developing for Microsoft only, considering most people game on windows. Just be aware that programming multiplatform from the beginning really isn't that hard. The longer you go programming with microsofts C++ ABI the longer it will take you to make the correct changes to have your projects work on other systems.

I would consider it an investment in your own future to just stay multiplatform, and also "stay current." (By using the latest versions of absolutely everything)

Share this post


Link to post
Share on other sites
Erik Rufelt    5901

Maybe try http://codelite.org/ , I've used it to build OpenGL apps on Linux.

You get errors in included headers, so I would start by building a simpler app in whatever compiler you attempt to use, as in printf("Hello World"); return 0;

Then when that works add one line or function at a time until it doesn't work, and you at least know where it goes wrong.

Edited by Erik Rufelt

Share this post


Link to post
Share on other sites

Who insulted you? Could you quote their insult? mellow.png

 

They are helping you. They are telling you:

A) Dev C++ is outdated, buggy, unsupported, and no longer used by the vast majority of programmers.

B) The claims against Microsoft are mostly overstated. And this is a community that is highly geeky and heavily uses Linux as well as Microsoft software.

C) There ARE valid reasons for not wanting to use Microsoft's compiler. OpenGL support isn't one of them. Visual C++ can compile OpenGL just fine.

D) Microsoft's compiler and IDE is generally considered the best that is currently available, though the opensource alternatives are rapidly gaining ground.

E) I personally use GCC myself, and even I avoid the Dev C++ IDE as junk. I now prefer the opensource Qt Creator IDE, which @Kaptein already linked to.

 

When people tell me something I don't want to hear, they are trying to help me. It's sometimes too easy for me to mistake "corrections" for "insults". wink.png

Edited by Servant of the Lord

Share this post


Link to post
Share on other sites
Kaptein    2224

I installed TDM-GCC and I am getting the same error messages

 

Looking at your code, it seems you are using:

* freeglut

* glew

* the files are 32bit

 

Did you install the 32-bit version of TDM-GCC? If so you should make sure you have an up-to-date version of glew32 and freeglut32:

 

Windows binaries for freeglut:

http://files.transmissionzero.co.uk/software/development/GLUT/freeglut-MinGW.zip

Windows binaries for glew:

https://sourceforge.net/projects/glew/files/glew/1.10.0/glew-1.10.0-win32.zip/download

 

Make a 'lib' folder and 'include' folder. Copy the headers into /include and the libs into /lib

 

Copy all the header files from this hard-coded path also into ./include

F:\school\csci\opengl\SB5\Src\GLTools\include

 

Compile with:

g++ -Iinclude -Llib -lglew32 -lfreeglut Triangle.cpp

 

It's just a guess for what the compile line would look like. You are basically telling the compiler that all the .h files are in ./include and all the .a files are in ./lib.

You are also "utilizing" the glew32 and freeglut libraries, which are the libglew32.a and libfreeglut.a files respectively.

 

As a sidenote: I'm not sure why your teachers have not just set up a proper makefile with a working directory structure.

It's possible to create a project setup that compiles on both windows and (at least) Ubuntu-derived Linux as well as OS X without having to do anything but "make."

All you need is to create win32 linux osx folders inside "lib" folder and create a slightly more complicated makefile manually.

It's not the best solution, but it will work for the students.

For example you might not want to add the linux libs, since you typically install these libs with package managers, or manually with "make install." It would cover 32 and 64bit.

 

Better than hard-coding in network paths at least.

 

Oh and, is GLTools a library? If it is, then you need to compile it into a library, as well as include its headers.

Edited by Kaptein

Share this post


Link to post
Share on other sites
Kaptein    2224

k, thanks. I was currently checking to see if I was using the 32 bit versions of libfreeglut.a and libglew.a

 

Btw. did you add C:\TDM-GCC\bin to the PATH enviroment variable?

Because you need to execute g++ from the directory that contains Triangle.cpp

 

Come to think of it:

It looks like you are still using Dev-C++, which uses an old gcc. Probably. Uninstall it, and make sure it's removed from PATH.

Because you would not get the same error messages on windows, if you installed TDM-GCC. I think the installer adds C:\TDM-GCC\bin to PATH during the installation.

 

Also, make sure TDM-GCC is the same system type as the libraries you are trying to use with it. If g++ --version is 64-bit, you'll want the 64-bit libraries and vice versa.

Edited by Kaptein

Share this post


Link to post
Share on other sites
4mad3u5    116

I need to see if I did everything you said but when I put into the command line:

 

this is the command line you told me to do

g++ -IF:\school\csci\opengl\SB5\Src\GLTools\include -IF:\school\csci\opengl\SB5\freegl

ut-2.6.0\include  -Llib -lglew32 -lfreeglut Triangle.cpp
 
and just for the heck of it I did mine
g++ -IF:\school\csci\opengl\SB5\Src\GLTools\include -IF:\school\csci\opengl\SB5\freegl
ut-2.6.0\include Triangle.cpp libglew32.a libfreeglut.a
 
I got a new error message saying this both times: 
 
In file included from F:\school\csci\opengl\SB5\freeglut-2.6.0\include/GL/freeglut_std.h:121:0,
                 from F:\school\csci\opengl\SB5\freeglut-2.6.0\include/GL/glut.h:17,
                 from Triangle.cpp:11:
c:\tdm-gcc-32\include\gl\glu.h:225:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluBeginCurve (GLUnurbs* nurb);
 ^
c:\tdm-gcc-32\include\gl\glu.h:226:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluBeginPolygon (GLUtesselator* tess);
 ^
c:\tdm-gcc-32\include\gl\glu.h:227:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluBeginSurface (GLUnurbs* nurb);
 ^
c:\tdm-gcc-32\include\gl\glu.h:228:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluBeginTrim (GLUnurbs* nurb);
 ^
c:\tdm-gcc-32\include\gl\glu.h:229:1: error: 'GLAPI' does not name a type
 GLAPI GLint APIENTRY gluBuild1DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const vo
ta);
 ^
In file included from F:\school\csci\opengl\SB5\freeglut-2.6.0\include/GL/freeglut_std.h:121:0,
                 from F:\school\csci\opengl\SB5\freeglut-2.6.0\include/GL/glut.h:17,
                 from Triangle.cpp:11:
c:\tdm-gcc-32\include\gl\glu.h:230:1: error: 'GLAPI' does not name a type
 GLAPI GLint APIENTRY gluBuild2DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenu
, const void *data);
 ^
c:\tdm-gcc-32\include\gl\glu.h:231:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluCylinder (GLUquadric* quad, GLdouble base, GLdouble top, GLdouble height, GLint slices, GLint stacks);
 ^
c:\tdm-gcc-32\include\gl\glu.h:232:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluDeleteNurbsRenderer (GLUnurbs* nurb);
 ^
c:\tdm-gcc-32\include\gl\glu.h:233:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluDeleteQuadric (GLUquadric* quad);
 ^
c:\tdm-gcc-32\include\gl\glu.h:234:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluDeleteTess (GLUtesselator* tess);
 ^
c:\tdm-gcc-32\include\gl\glu.h:235:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluDisk (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops);
 ^
c:\tdm-gcc-32\include\gl\glu.h:236:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluEndCurve (GLUnurbs* nurb);
 ^
c:\tdm-gcc-32\include\gl\glu.h:237:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluEndPolygon (GLUtesselator* tess);
 ^
c:\tdm-gcc-32\include\gl\glu.h:238:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluEndSurface (GLUnurbs* nurb);
 ^
c:\tdm-gcc-32\include\gl\glu.h:239:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluEndTrim (GLUnurbs* nurb);
 ^
c:\tdm-gcc-32\include\gl\glu.h:240:1: error: 'GLAPI' does not name a type
 GLAPI const GLubyte * APIENTRY gluErrorString (GLenum error);
 ^
c:\tdm-gcc-32\include\gl\glu.h:241:1: error: 'GLAPI' does not name a type
 GLAPI const wchar_t * APIENTRY gluErrorUnicodeStringEXT (GLenum error);
 ^
c:\tdm-gcc-32\include\gl\glu.h:242:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluGetNurbsProperty (GLUnurbs* nurb, GLenum property, GLfloat* data);
 ^
c:\tdm-gcc-32\include\gl\glu.h:243:1: error: 'GLAPI' does not name a type
 GLAPI const GLubyte * APIENTRY gluGetString (GLenum name);
 ^
c:\tdm-gcc-32\include\gl\glu.h:244:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluGetTessProperty (GLUtesselator* tess, GLenum which, GLdouble* data);
 ^
c:\tdm-gcc-32\include\gl\glu.h:245:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluLoadSamplingMatrices (GLUnurbs* nurb, const GLfloat *model, const GLfloat *perspective, const GLint *view
 ^
c:\tdm-gcc-32\include\gl\glu.h:246:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluLookAt (GLdouble eyeX, GLdouble eyeY, GLdouble eyeZ, GLdouble centerX, GLdouble centerY, GLdouble centerZ
uble upX, GLdouble upY, GLdouble upZ);
 ^
c:\tdm-gcc-32\include\gl\glu.h:247:1: error: 'GLAPI' does not name a type
 GLAPI GLUnurbs* APIENTRY gluNewNurbsRenderer (void);
 ^
c:\tdm-gcc-32\include\gl\glu.h:248:1: error: 'GLAPI' does not name a type
 GLAPI GLUquadric* APIENTRY gluNewQuadric (void);
 ^
c:\tdm-gcc-32\include\gl\glu.h:249:1: error: 'GLAPI' does not name a type
 GLAPI GLUtesselator* APIENTRY gluNewTess (void);
 ^
c:\tdm-gcc-32\include\gl\glu.h:250:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluNextContour (GLUtesselator* tess, GLenum type);
 ^
c:\tdm-gcc-32\include\gl\glu.h:251:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluNurbsCallback (GLUnurbs* nurb, GLenum which, _GLUfuncptr CallBackFunc);
 ^
c:\tdm-gcc-32\include\gl\glu.h:252:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluNurbsCurve (GLUnurbs* nurb, GLint knotCount, GLfloat *knots, GLint stride, GLfloat *control, GLint order,
m type);
 ^
c:\tdm-gcc-32\include\gl\glu.h:253:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluNurbsProperty (GLUnurbs* nurb, GLenum property, GLfloat value);
 ^
c:\tdm-gcc-32\include\gl\glu.h:254:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluNurbsSurface (GLUnurbs* nurb, GLint sKnotCount, GLfloat* sKnots, GLint tKnotCount, GLfloat* tKnots, GLint
de, GLint tStride, GLfloat* control, GLint sOrder, GLint tOrder, GLenum type);
 ^
c:\tdm-gcc-32\include\gl\glu.h:255:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluOrtho2D (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top);
 ^
c:\tdm-gcc-32\include\gl\glu.h:256:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluPartialDisk (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops, GLdouble start,
ble sweep);
 ^
c:\tdm-gcc-32\include\gl\glu.h:257:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluPerspective (GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar);
 ^
c:\tdm-gcc-32\include\gl\glu.h:258:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluPickMatrix (GLdouble x, GLdouble y, GLdouble delX, GLdouble delY, GLint *viewport);
 ^
c:\tdm-gcc-32\include\gl\glu.h:259:1: error: 'GLAPI' does not name a type
 GLAPI GLint APIENTRY gluProject (GLdouble objX, GLdouble objY, GLdouble objZ, const GLdouble *model, const GLdouble *proj, const
 *view, GLdouble* winX, GLdouble* winY, GLdouble* winZ);
 ^
c:\tdm-gcc-32\include\gl\glu.h:260:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluPwlCurve (GLUnurbs* nurb, GLint count, GLfloat* data, GLint stride, GLenum type);
 ^
c:\tdm-gcc-32\include\gl\glu.h:261:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluQuadricCallback (GLUquadric* quad, GLenum which, _GLUfuncptr CallBackFunc);
 ^
c:\tdm-gcc-32\include\gl\glu.h:262:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluQuadricDrawStyle (GLUquadric* quad, GLenum draw);
 ^
c:\tdm-gcc-32\include\gl\glu.h:263:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluQuadricNormals (GLUquadric* quad, GLenum normal);
 ^
c:\tdm-gcc-32\include\gl\glu.h:264:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluQuadricOrientation (GLUquadric* quad, GLenum orientation);
 ^
c:\tdm-gcc-32\include\gl\glu.h:265:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluQuadricTexture (GLUquadric* quad, GLboolean texture);
 ^
c:\tdm-gcc-32\include\gl\glu.h:266:1: error: 'GLAPI' does not name a type
 GLAPI GLint APIENTRY gluScaleImage (GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void *dataIn, GLsizei wOut, GL
hOut, GLenum typeOut, GLvoid* dataOut);
 ^
c:\tdm-gcc-32\include\gl\glu.h:267:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluSphere (GLUquadric* quad, GLdouble radius, GLint slices, GLint stacks);
 ^
c:\tdm-gcc-32\include\gl\glu.h:268:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluTessBeginContour (GLUtesselator* tess);
 ^
c:\tdm-gcc-32\include\gl\glu.h:269:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluTessBeginPolygon (GLUtesselator* tess, GLvoid* data);
 ^
c:\tdm-gcc-32\include\gl\glu.h:270:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluTessCallback (GLUtesselator* tess, GLenum which, _GLUfuncptr CallBackFunc);
 ^
c:\tdm-gcc-32\include\gl\glu.h:271:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluTessEndContour (GLUtesselator* tess);
 ^
c:\tdm-gcc-32\include\gl\glu.h:272:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluTessEndPolygon (GLUtesselator* tess);
 ^
c:\tdm-gcc-32\include\gl\glu.h:273:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluTessNormal (GLUtesselator* tess, GLdouble valueX, GLdouble valueY, GLdouble valueZ);
 ^
c:\tdm-gcc-32\include\gl\glu.h:274:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluTessProperty (GLUtesselator* tess, GLenum which, GLdouble data);
 ^
c:\tdm-gcc-32\include\gl\glu.h:275:1: error: 'GLAPI' does not name a type
 GLAPI void APIENTRY gluTessVertex (GLUtesselator* tess, GLdouble *location, GLvoid* data);
 ^
c:\tdm-gcc-32\include\gl\glu.h:276:1: error: 'GLAPI' does not name a type
 GLAPI GLint APIENTRY gluUnProject (GLdouble winX, GLdouble winY, GLdouble winZ, const GLdouble *model, const GLdouble *proj, con
nt *view, GLdouble* objX, GLdouble* objY, GLdouble* objZ);
 ^
c:\tdm-gcc-32\include\gl\glu.h:277:1: error: 'GLAPI' does not name a type
 GLAPI GLint APIENTRY gluUnProject4 (GLdouble winX, GLdouble winY, GLdouble winZ, GLdouble clipW, const GLdouble *model, const GL
 *proj, const GLint *view, GLdouble nearVal, GLdouble farVal, GLdouble* objX, GLdouble* objY, GLdouble* objZ, GLdouble* objW);
Edited by 4mad3u5

Share this post


Link to post
Share on other sites
4mad3u5    116

I hadn't gotten the new command line when I tried TDM the first time so I was still working with the old one, its the new command line that gave me the new error messages

Edited by 4mad3u5

Share this post


Link to post
Share on other sites
Erik Rufelt    5901

You're getting compile errors. These have nothing to do with libs but with source code, as libs are only ever linked to once compiling succeeds without errors.

Your error "'GLAPI' does not name a type" comes from the fact that the file freeglut_std.h has source-code including 'GLAPI' and the compiler doesn't know what that means.

I would guess that is because you include freeglut_std.h without including gl.h or something like that.

 

The following means that on line 11 in Triangle.cpp you include GL/glut.h, and on line 17 in GL/glut.h that file includes freeglut_std.h, and in that file on line 121 is the error encountered. It's often so that if the first error in a long list like yours is fixed then all others are automatically fixed too.

/freeglut_std.h:121:0,
from /GL/glut.h:17,
from Triangle.cpp:11:

It seems very strange that these headers wouldn't guarantee to have GLAPI already defined.

 

Start by changing your file to include <GL/gl.h> at the top. That is just a guess though but if you're lucky it might change something.

 

If it doesn't work, try to compile this program first (as your current program is already dependent on a lot of different libraries, and it's better to add one at a time):

// Triangle.cpp
// Our first OpenGL program that will just draw a triangle on the screen.

#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h> // Windows FreeGlut equivalent

///////////////////////////////////////////////////////////////////////////////
// Window has changed size, or has just been created. In either case, we need
// to use the window dimensions to set the viewport and the projection matrix.
void ChangeSize(int w, int h)
{
    glViewport(0, 0, w, h);
}


///////////////////////////////////////////////////////////////////////////////
// Called to draw scene
void RenderScene(void)
{
    // Clear the window with current blue color
    glClearColor(0.0f, 0.0f, 1.0f, 1.0f );
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // Perform the buffer swap to display back buffer
    glutSwapBuffers();
}


///////////////////////////////////////////////////////////////////////////////
// Main entry point for GLUT based programs
int main(int argc, char* argv[])
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
    glutInitWindowSize(800, 600);
    glutCreateWindow("Triangle");
    glutReshapeFunc(ChangeSize);
    glutDisplayFunc(RenderScene);

    glutMainLoop();

    return 0;
}
Edited by Erik Rufelt

Share this post


Link to post
Share on other sites
4mad3u5    116

Hey I think I can get that to work as soon as I get these libraries in my dir, here is what I get when I used your code Erik

 

F:\school\csci\opengl\SB5\Src\Chapter02\Triangle>g++ -IF:\school\csci\opengl\SB5\Src\GLTools\include -IF:\school\csci\opengl\SB5\freegl
ut-2.6.0\include  -Llib -lglew32 -lfreeglut Triangle.cpp
c:/tdm-gcc-32/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lglew32
c:/tdm-gcc-32/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lfreeglut
collect2.exe: error: ld returned 1 exit status
Edited by 4mad3u5

Share this post


Link to post
Share on other sites
Erik Rufelt    5901

Seems it doesn't find the library paths. Maybe add -L"path to your directory"..

 

Googling tells me you can add "-Wl,--verbose" to add warnings to the linker..

 

Or try removing -lglew32 and -lfreeglut and just enter libglew32.a on the command line instead. Not sure if that works though..

 

Also, with that code you don't need GLEW so try without that first, then add it after freeglut works, so if something else goes wrong you can be sure which part gives the error.

Edited by Erik Rufelt

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Similar Content

    • By tyhender
      Hello, my name is Mark. I'm hobby programmer. 
      So recently,I thought that it's good idea to find people to create a full 3D engine. I'm looking for people experienced in scripting 3D shaders and implementing physics into engine(game)(we are going to use the React physics engine). 
      And,ye,no money =D I'm just looking for hobbyists that will be proud of their work. If engine(or game) will have financial succes,well,then maybe =D
      Sorry for late replies.
      I mostly give more information when people PM me,but this post is REALLY short,even for me =D
      So here's few more points:
      Engine will use openGL and SDL for graphics. It will use React3D physics library for physics simulation. Engine(most probably,atleast for the first part) won't have graphical fron-end,it will be a framework . I think final engine should be enough to set up an FPS in a couple of minutes. A bit about my self:
      I've been programming for 7 years total. I learned very slowly it as "secondary interesting thing" for like 3 years, but then began to script more seriously.  My primary language is C++,which we are going to use for the engine. Yes,I did 3D graphics with physics simulation before. No, my portfolio isn't very impressive. I'm working on that No,I wasn't employed officially. If anybody need to know more PM me. 
       
    • By Zaphyk
      I am developing my engine using the OpenGL 3.3 compatibility profile. It runs as expected on my NVIDIA card and on my Intel Card however when I tried it on an AMD setup it ran 3 times worse than on the other setups. Could this be a AMD driver thing or is this probably a problem with my OGL code? Could a different code standard create such bad performance?
    • By Kjell Andersson
      I'm trying to get some legacy OpenGL code to run with a shader pipeline,
      The legacy code uses glVertexPointer(), glColorPointer(), glNormalPointer() and glTexCoordPointer() to supply the vertex information.
      I know that it should be using setVertexAttribPointer() etc to clearly define the layout but that is not an option right now since the legacy code can't be modified to that extent.
      I've got a version 330 vertex shader to somewhat work:
      #version 330 uniform mat4 osg_ModelViewProjectionMatrix; uniform mat4 osg_ModelViewMatrix; layout(location = 0) in vec4 Vertex; layout(location = 2) in vec4 Normal; // Velocity layout(location = 3) in vec3 TexCoord; // TODO: is this the right layout location? out VertexData { vec4 color; vec3 velocity; float size; } VertexOut; void main(void) { vec4 p0 = Vertex; vec4 p1 = Vertex + vec4(Normal.x, Normal.y, Normal.z, 0.0f); vec3 velocity = (osg_ModelViewProjectionMatrix * p1 - osg_ModelViewProjectionMatrix * p0).xyz; VertexOut.velocity = velocity; VertexOut.size = TexCoord.y; gl_Position = osg_ModelViewMatrix * Vertex; } What works is the Vertex and Normal information that the legacy C++ OpenGL code seem to provide in layout location 0 and 2. This is fine.
      What I'm not getting to work is the TexCoord information that is supplied by a glTexCoordPointer() call in C++.
      Question:
      What layout location is the old standard pipeline using for glTexCoordPointer()? Or is this undefined?
       
      Side note: I'm trying to get an OpenSceneGraph 3.4.0 particle system to use custom vertex, geometry and fragment shaders for rendering the particles.
    • By markshaw001
      Hi i am new to this forum  i wanted to ask for help from all of you i want to generate real time terrain using a 32 bit heightmap i am good at c++ and have started learning Opengl as i am very interested in making landscapes in opengl i have looked around the internet for help about this topic but i am not getting the hang of the concepts and what they are doing can some here suggests me some good resources for making terrain engine please for example like tutorials,books etc so that i can understand the whole concept of terrain generation.
       
    • By KarimIO
      Hey guys. I'm trying to get my application to work on my Nvidia GTX 970 desktop. It currently works on my Intel HD 3000 laptop, but on the desktop, every bind textures specifically from framebuffers, I get half a second of lag. This is done 4 times as I have three RGBA textures and one depth 32F buffer. I tried to use debugging software for the first time - RenderDoc only shows SwapBuffers() and no OGL calls, while Nvidia Nsight crashes upon execution, so neither are helpful. Without binding it runs regularly. This does not happen with non-framebuffer binds.
      GLFramebuffer::GLFramebuffer(FramebufferCreateInfo createInfo) { glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); textures = new GLuint[createInfo.numColorTargets]; glGenTextures(createInfo.numColorTargets, textures); GLenum *DrawBuffers = new GLenum[createInfo.numColorTargets]; for (uint32_t i = 0; i < createInfo.numColorTargets; i++) { glBindTexture(GL_TEXTURE_2D, textures[i]); GLint internalFormat; GLenum format; TranslateFormats(createInfo.colorFormats[i], format, internalFormat); // returns GL_RGBA and GL_RGBA glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, createInfo.width, createInfo.height, 0, format, GL_FLOAT, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); DrawBuffers[i] = GL_COLOR_ATTACHMENT0 + i; glBindTexture(GL_TEXTURE_2D, 0); glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, textures[i], 0); } if (createInfo.depthFormat != FORMAT_DEPTH_NONE) { GLenum depthFormat; switch (createInfo.depthFormat) { case FORMAT_DEPTH_16: depthFormat = GL_DEPTH_COMPONENT16; break; case FORMAT_DEPTH_24: depthFormat = GL_DEPTH_COMPONENT24; break; case FORMAT_DEPTH_32: depthFormat = GL_DEPTH_COMPONENT32; break; case FORMAT_DEPTH_24_STENCIL_8: depthFormat = GL_DEPTH24_STENCIL8; break; case FORMAT_DEPTH_32_STENCIL_8: depthFormat = GL_DEPTH32F_STENCIL8; break; } glGenTextures(1, &depthrenderbuffer); glBindTexture(GL_TEXTURE_2D, depthrenderbuffer); glTexImage2D(GL_TEXTURE_2D, 0, depthFormat, createInfo.width, createInfo.height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glBindTexture(GL_TEXTURE_2D, 0); glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depthrenderbuffer, 0); } if (createInfo.numColorTargets > 0) glDrawBuffers(createInfo.numColorTargets, DrawBuffers); else glDrawBuffer(GL_NONE); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) std::cout << "Framebuffer Incomplete\n"; glBindFramebuffer(GL_FRAMEBUFFER, 0); width = createInfo.width; height = createInfo.height; } // ... // FBO Creation FramebufferCreateInfo gbufferCI; gbufferCI.colorFormats = gbufferCFs.data(); gbufferCI.depthFormat = FORMAT_DEPTH_32; gbufferCI.numColorTargets = gbufferCFs.size(); gbufferCI.width = engine.settings.resolutionX; gbufferCI.height = engine.settings.resolutionY; gbufferCI.renderPass = nullptr; gbuffer = graphicsWrapper->CreateFramebuffer(gbufferCI); // Bind glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo); // Draw here... // Bind to textures glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, textures[0]); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, textures[1]); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, textures[2]); glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, depthrenderbuffer); Here is an extract of my code. I can't think of anything else to include. I've really been butting my head into a wall trying to think of a reason but I can think of none and all my research yields nothing. Thanks in advance!
  • Popular Now