Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Open GL SuperBible problem with setting up IDE

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2011
    Posts
    10

    Open GL SuperBible problem with setting up IDE

    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:raw()'|
    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?

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Mar 2009
    Location
    Singapore
    Posts
    800

    Re: Open GL SuperBible problem with setting up IDE

    You need to add gltools.lib too
    Regards,
    Mobeen

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2011
    Posts
    10

    Re: Open GL SuperBible problem with setting up IDE

    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=0B0LAE78...cy&amp;hl=en_US

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

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

  4. #4
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948

    Re: Open GL SuperBible problem with setting up IDE

    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.

  5. #5
    Junior Member Newbie
    Join Date
    Jul 2011
    Posts
    10

    Re: Open GL SuperBible problem with setting up IDE

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •