PDA

View Full Version : Open GL SuperBible problem with setting up IDE



Gelldur
07-02-2011, 07:13 AM
Hello i have litle problem with setting up my IDE (Code Blocks) im working on Linux (Ubuntu)

I have installed all need packages from repository.

Now i have this code from book.


// 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>
#else
#define FREEGLUT_STATIC
#include <GL/glut.h>
#include <GL/glew.h>
#endif
// OS X version of GLUT
// Windows FreeGlut equivalent
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 the back buffer
glutSwapBuffers();
}
///////////////////////////////////////////////////////////////////////////////
// Main entry point for GLUT based programs
int main(int argc, char* argv[])
{
gltSetWorkingDirectory(argv[0]);
glutInit(&amp;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;
}


I have Errors:

||=== Triangle, Debug ===|
obj/Debug/main.o||In function `SetupRC()':|
/home/dawid/NaukaOpenGl/Triangle/main.cpp|31|undefined reference to `GLShaderManager::InitializeStockShaders()'|
/home/dawid/NaukaOpenGl/Triangle/main.cpp|37|undefined reference to `GLBatch::Begin(unsigned int, unsigned int, unsigned int)'|
/home/dawid/NaukaOpenGl/Triangle/main.cpp|39|undefined reference to `GLBatch::End()'|
obj/Debug/main.o||In function `RenderScene()':|
/home/dawid/NaukaOpenGl/Triangle/main.cpp|48|undefined reference to `GLShaderManager::UseStockShader(GLT_STOCK_SHADER, ...)'|
/home/dawid/NaukaOpenGl/Triangle/main.cpp|49|undefined reference to `GLBatch::Draw()'|
obj/Debug/main.o||In function `main':|
/home/dawid/NaukaOpenGl/Triangle/main.cpp|57|undefined reference to `gltSetWorkingDirectory(char const*)'|
/home/dawid/NaukaOpenGl/Triangle/main.cpp|64|undefined reference to `glewInit'|
/home/dawid/NaukaOpenGl/Triangle/main.cpp|66|undefined reference to `glewGetErrorString'|
obj/Debug/main.o||In function `__static_initialization_and_destruction_0':|
/home/dawid/NaukaOpenGl/Triangle/main.cpp|15|undefined reference to `GLBatch::GLBatch()'|
/home/dawid/NaukaOpenGl/Triangle/main.cpp|15|undefined reference to `GLBatch::~GLBatch()'|
/home/dawid/NaukaOpenGl/Triangle/main.cpp|16|undefined reference to `GLShaderManager::GLShaderManager()'|
/home/dawid/NaukaOpenGl/Triangle/main.cpp|16|undefined reference to `GLShaderManager::~GLShaderManager()'|
obj/Debug/main.o||In function `GLBatch::CopyVertexData3f(float*)':|
/home/dawid/Downloads/SB5/Src/GLTools/include/GLBatch.h|89|undefined reference to `GLBatch::CopyVertexData3f(float (*) [3])'|
||=== Build finished: 13 errors, 0 warnings ===|


I have done:

I go to Project->Build Options
Linker Settings and add glut,GL,GLU,Xxf86vm
Search Directories :
Compile:
I add /usr/include
../Src/GLTools/include
Linker
I add /usr/lib

Thats all but i dont really know what add more.
And i can compile by make books examples and they run but i want use CodeBlocks can someoune can help?

mobeen
07-03-2011, 01:05 AM
You need to add gltools.lib too

Gelldur
07-03-2011, 02:46 AM
Ok are you sure? Because it was in folder SB5/VisualStudio2008/GLTools/Release

I'm using Linux (Ubuntu)

I add this to Search Directories and Linker Settings that doesn't help same error.

I have done this in command line


$ nm -D /usr/lib/libGL.so | grep glCreateShader
00052250 T glCreateShader
000529f0 T glCreateShaderObjectARB
00053f80 T glCreateShaderProgramEXT



OK I did it this way:

For CodeBlocks it looks:
https://docs.google.com/leaf?id=0B0LAE78...Ew&amp;hl=en_US (https://docs.google.com/leaf?id=0B0LAE78KhmOmNzA1YWM5OWYtNGI2ZS00YzdlLWJkY mUtYjkyMTJiYjk0M2Ew&amp;hl=en_US)

https://docs.google.com/leaf?id=0B0LAE78...cy&amp;hl=en_US (https://docs.google.com/leaf?id=0B0LAE78KhmOmMDBkNGE4OGEtZjE0Yy00M2QyLWE5Y zctZmU3NjcyMzhkNTcy&amp;hl=en_US)

https://docs.google.com/leaf?id=0B0LAE78...Qz&amp;hl=en_US (https://docs.google.com/leaf?id=0B0LAE78KhmOmY2I2MjFlOWUtZDQ5Yy00MmRkLWIyN zQtOTJhYjY3NTIyZDQz&amp;hl=en_US)

As you see I add to my project GlTools/src folder can i do it in better way? Thx.

Alfonse Reinheart
07-03-2011, 05:29 AM
I'm using Linux (Ubuntu)

Then build and link to libgltools. You must link to the gltools library file that you built for your platform.

I am so glad I used Premake in my tutorial's build system.

Gelldur
07-03-2011, 06:40 AM
Ok i'm satisfied. But could you help how to build this lib on my own? You can send me priv if you don't want write here. I never build such thing.

Ok i think i have done it thx for all here it is : http://sendfile.pl/83498/libGLTools.a