Compiling a simple GL program
  • Caterpillar
    Caterpillar
    Posts: 33 from 2013/6/20
    Hello

    (Just for testing purpose) I am trying to compile a simple OpenGL program that only use GL & GLUT (no PC nor Linux dependancies) but the compiler lack of "TinyGLBase" "__tglContext"
    Of course I can open TinyGL manually create a TinyGL context etc... but I was thinking that Morphos certainly can compile a basic GL program with -lgl and without any changes... no ?

    Alain Thellier
  • »26.12.13 - 12:00
    Profile Visit Website
  • Acolyte of the Butterfly
    Acolyte of the Butterfly
    Daytona675x
    Posts: 109 from 2013/12/5
    Forget about -lgl. That's the way I did it and it works:
    Just declare

    Code:
    Library *TinyGLBase=0;
    GLContext *__tglContext=0;


    after all the includes yourself.
    (maybe that's all you need to do to successfully link via -lgl, I suppose you got linker and not compiler errors?!)

    Then open TinyGL

    Code:
    TinyGLBase=(Library*)OpenLibrary("tinygl.library",0);


    then create your window or screen, and then your context and bind it to your window/screen:

    Code:
    __tglContext=GLInit();
    TagItem tags[] = {
    {TGL_CONTEXT_WINDOW,window_handle},
    // {TGL_CONTEXT_SCREEN,screen_handle},
    {NULL,NULL}
    };
    GLAInitializeContext(__tglContext,tags);


    And don't forget to call
    Code:
    GLAReinitializeContextWindowed(__tglContext,window_handle);

    after you resized your window.
  • »26.12.13 - 15:45
    Profile Visit Website
  • Caterpillar
    Caterpillar
    Posts: 33 from 2013/6/20
    Thanks Daytona675x

    I have maded some test and in fact I can compile
    It only need -lgl -lglut

    Badly this glut dont seems to support menus but I was able to make the tests I wanted

    Alain
  • »30.12.13 - 12:26
    Profile Visit Website
  • Paladin of the Pegasos
    Paladin of the Pegasos
    Jupp3
    Posts: 1193 from 2003/2/24
    From: Helsinki, Finland
    thellier,
    Quote:

    It only need -lgl

    Use -lGL instead. On case-insensitive filesystems (like people MOSTLY use on MorphOS) it makes no practical difference, but it's still wrong :-)

    Well, I have seen people write #include <gl\GL.h> in their code - some kind of achievement being able to fit 3 errors in such short piece of text... :-D

    Regarding what glut can and can't do, I'd recommend dumping it as soon as possible - and I mean glut in general, not just the MorphOS implementation...
  • »30.12.13 - 15:57
    Profile Visit Website