Developing OpenGl Applications
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    eliot
    Posts: 565 from 2004/4/15
    Hello,

    I jsut tried to compile and my own 3D engine on MorphOs (3.9, g++ 5).
    That's how I link:
    Code:

    g++ -o example_frist_person example_first_person.o -noixemul -L./ -lGl -lglut -lm -lexdevgfx2


    Everything seems to be fine.
    But when I start the executable, I get the following error:

    Code:

    Work:workspace/ExdevGfx2> example_frist_person
    terminate called after throwing an instance of 'std::ios_base::failure'
    what(): basic_ios::clear
    Program aborted


    Any idea what's going wrong?
    On other platforms it runs well.

    EDIT:
    When I am not linking against gl and glut, I get the following error from ld:
    Code:

    example_first_person.o: In function `main':
    example_first_person.o(.text.startup+0x106): undefined reference to `__tglContext'
    example_first_person.o(.text.startup+0x10e): undefined reference to `__tglContext'
    example_first_person.o(.text.startup+0x112): undefined reference to `TinyGLBase'
    example_first_person.o(.text.startup+0x11a): undefined reference to `TinyGLBase'
    collect2: error: ld returned 1 exit status


    [ Edited by eliot 26.01.2016 - 19:53 ]
    regards
    eliot
  • »26.01.16 - 18:46
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    eliot
    Posts: 565 from 2004/4/15
    Ok,

    I have now a working example.
    But I do not get any keyboard events vom glut view.
    I did set glutKeyboardFunc and glutSpecialFunc.
    On other systems (Mac Os X and Linux) I get the keyboard events.
    Any idea what I have to do on Morphos?
    regards
    eliot
  • »26.01.16 - 20:33
    Profile
  • MorphOS Developer
    kiero
    Posts: 129 from 2003/2/28
    Quote:

    eliot wrote:
    Ok,

    I have now a working example.
    But I do not get any keyboard events vom glut view.
    I did set glutKeyboardFunc and glutSpecialFunc.
    On other systems (Mac Os X and Linux) I get the keyboard events.
    Any idea what I have to do on Morphos?


    Can You provide an example? In general keyboard func should be working.

    Regards
  • »01.02.16 - 10:49
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    eliot
    Posts: 565 from 2004/4/15
    Hi,

    just tested a very small example:

    Code:

    #include <iostream>
    #include <GL/gl.h>
    #include <GL/glut.h>

    using namespace std;

    class GlutView {
    public:
    GlutView() {
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
    glutInitWindowSize(640, 480);
    glutInitWindowPosition(0, 0);
    glutCreateWindow("Test");
    glutDisplayFunc(GlutView::display_);
    glutKeyboardFunc(GlutView::keyPressedEvent_);
    glutSpecialFunc(GlutView::specialKeyPressedEvent_);
    glutMainLoop();
    }


    static void display_() {
    glClear(GL_COLOR_BUFFER_BIT);
    glutWireTeapot(0.5);
    glutSwapBuffers();

    }

    static void keyPressedEvent_(unsigned char key, int x, int y) {
    cout << "keyPressedEvent_: key=" << (int) key << ", x=" << x << ", y=" << y << endl;
    }

    static void specialKeyPressedEvent_(int key, int x, int y) {
    cout << "keyPressedEvent_: key=" << key << ", x=" << x << ", y=" << y << endl;
    }

    };

    int main(int argc, char **argv) {
    glutInit(&argc, argv);
    GlutView v;
    return 0;
    }


    compiled with: g++ TestGlut.cpp -std=c++11 -O0 -noixemul -I lib/include -lm -lGl -lglut

    It works well!
    In my project I do some more things (glut timer and idle function).
    I will check if it makes something strange.
    Good to know that the basics are working well. I will go on look for the reason
    If I know what's going wrong I will reply here!
    regards
    eliot
  • »01.02.16 - 17:51
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    eliot
    Posts: 565 from 2004/4/15
    Ok,

    Timer is also working as expected. Now key events do also work in my other project.
    There was an issue in the timer function, which might the reason for the error.
    Thank you very much for reply and mental support ;)

    Now I have to figure out why I am getting wrong colors on MorphOs.

    regards
    eliot
    regards
    eliot
  • »01.02.16 - 18:35
    Profile
  • Paladin of the Pegasos
    Paladin of the Pegasos
    Jupp3
    Posts: 1193 from 2003/2/24
    From: Helsinki, Finland
    If you're interested, a few years back I wrote a simple OpenGL example and overview of functionality in TinyGL.

    I'd say both are slightly outdated (since VBO is finally supported), but are otherwise still quite "valid" (telling you to not use immediate mode etc.)

    Also some thoughts on error checking.

    [ Edited by Jupp3 01.02.2016 - 23:02 ]
  • »01.02.16 - 19:59
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    eliot
    Posts: 565 from 2004/4/15
    @Jupp3

    Ok, thx, I will read it.

    I have just found diffferent behaviour on MorphOs to other systems (Linux, Mac).
    Installing a timer with glutTimerFunction(...) the timer will be called on Linux and Mac exactly once.
    In timer funtion I have to install it again to call it again.

    On MorphOs the timer is called every x milliseconds (repeated).
    regards
    eliot
  • »02.02.16 - 18:15
    Profile