Game Development Community

Torque3D Linux Status

by Luis Anton Rebollo · in Torque 3D Professional · 09/19/2013 (12:36 pm) · 168 replies

img833.imageshack.us/img833/9893/4q3c.pngimagizer.imageshack.us/v2/800x600q90/853/99ok.png

Torque 3D on Linux

This branch is based on the work of RonOHara-GG that you can find at: github.com/GarageGames/Torque3D/tree/linux-rnd. I removed everything related to Nvidia CG because it was not useful for my OpenGL project. The current state is very basic, but enough to be a good starting point.

Changes or updates on Linux, will be posted on this thread. If you have any questions feel free to post.

You can find the code at:

  • github.com/BeamNG/Torque3D/tree/dev_linux_opengl

  • How to compile

  • dl.dropboxusercontent.com/u/28887086/T3D%20CMake%20docs/mdwiki.html#!index.md

  • Status:

    • Only tested on Ubuntu, compiled with gcc.
    • To modify TorqueScript, is needed an editor that can save with Windows EOF.
    • Use CMake for build project.

    Torque 3D Version:

    This branch is based on Torque3D 3.5.1 development.

    What to do if you want to help?


    Reporting bugs:

    If possible, Github is a great place to post issues to a forum.
    I appreciate any donation to help the project. https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif.
    #121
    03/10/2014 (7:04 pm)
    Can I use the OpenGL project on Android?
    #122
    03/11/2014 (4:16 am)
    There is no android port yet for T3D. T2D does run on android though. This is regular desktop OpenGL. Android uses OpenGL ES.
    #123
    03/13/2014 (11:03 am)
    This is really neat. I haven't seen torque run on linux since back in the TGE days, something we lost over the years with all the focus on directX.

    back in the day TGE compiled and ran both the client and server in windows and linux, all right out of the box.

    Nice to see a movement back in that direction. I think getting T3D to be portable will go a long way to extending the life and usefulness of this really awesome engine.
    #124
    03/30/2014 (3:51 pm)
    I'm adding SDL2 to T3D.

    If nothing rare happens in about 2 weeks I hope to be working again in Linux.

    #125
    04/14/2014 (3:23 am)
    Working on Linux...

    i.imgur.com/b8KCwnkl.png
    Click to zoom.

    #126
    04/14/2014 (3:39 am)
    It's a nice IDE Qt Creator. Anyway nice work Luis.
    #127
    04/17/2014 (1:16 am)
    A new update on Github: github.com/BeamNG/Torque3D/tree/dev_linux_opengl
    • Compile on Linux 64bit
    • Updated to Torque v3.5.1
    • Fixes for compile on Linux
    • Added SDL2 for window and input
    • Menubar, message box and file dialog on Linux (full working editor)
    • CMake support (tested on MSVC, make, ninja, Codeblocks, kDevelops, qtCreator)

    You do not need to use Linux OS 32bit or CHROOT to compile T3D on Linux. It can be done easily from a OS 64bit.

    You can not use the old php generator in Linux. Set SDL2 for Linux is too complicated and we need to use CMake.

    CMake is a cross-platform, open-source build system.
    How to use CMake to compile T3D. Not finished, appreciate any help to improve it.
    #128
    04/17/2014 (1:47 pm)
    First of all... congratulations Luis for your work :)

    I wanted to try your implementation on my linux workstation (with amd64 debian sid), but i found some problems when try to playing the maps.

    The first error that occurred concerned the debug OpenGL, i commented the code in question and went ahead.

    Then i had a crash in the vsync, solved by using the SDL to handle it.

    Engine/source/platformX86UNIX/x86UNIXPlatformGL.cpp
    void PlatformGL::setVSync(const int i)
    {
        /*
        Display *dpy = glXGetCurrentDisplay();
        GLXDrawable drawable = glXGetCurrentDrawable();
        const int interval = i;
    
        glXSwapIntervalEXT(dpy, drawable, interval);AntiAliasing has been disabled; it is not compatible with AdvancedLighting.
    % Debugging has finished
        */
        
        SDL_GL_SetSwapInterval(i);
    }

    Also on my machine, resizing the window does not resize the sdl/gl context, and some part of code won't work, like mouse/context traslation or gl texture copy for postfx, so i have crash when start the level. I can not debugging because the mouse is locked. I think the problem is in getSize().x and getSize().y

    Engine/source/gfx/gl/gfxGLWindowTarget.cpp
    glCopyImageSubData(
               static_cast<GFXGLTextureObject*>(mBackBufferColorTex.getPointer())->getHandle(), GL_TEXTURE_2D, 0, 0, 0, 0,
               glTexture->getHandle(), GL_TEXTURE_2D, 0, 0, 0, 0,
               getSize().x, getSize().y, 1);

    And... at ende for now
    AntiAliasing has been disabled; it is not compatible with AdvancedLighting.
    % Debugging has finished

    U can try to use the SDL MSAA to avoid this.
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, (int)AA_Enabled); // AA_Enabled = true for enable
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, AA_Level); // AA_Level = 2 or 4 for example
    #129
    04/17/2014 (2:45 pm)
    @Alfio, thx ... i like bug reports :D

    Tomorrow morning I start with it.
    #130
    04/17/2014 (4:09 pm)
    The Torque GFX code is too dirty. Good luck :/
    #131
    04/17/2014 (5:01 pm)
    Whoah that's a fantastic list. Damn it I wish I had the time to get stuck into this.
    #132
    04/19/2014 (3:43 am)
    A new update on Github:github.com/BeamNG/Torque3D/tree/dev_linux_opengl
    Updated documentation: dl.dropboxusercontent.com/u/28887086/T3D%20CMake%20docs/mdwiki.html#!index.md

    There is some kind of major problem between SDL GL and GLEW in the code. Some of the problems might have suffered due to this. Now it should work, but I need to investigate more.

    @Alfio, i have revised your problems (thx for report):
    Quote:Then i had a crash in the vsync, solved by using the SDL to handle it.
    Not a good idea to use an OpenGL extension without checking if available. I change to use SDL2. Thx.

    Quote:resizing the window does not resize the sdl/gl context
    I can't reproduce this. Posible related to SDL/GLEW problem.

    Quote:AntiAliasing has been disabled; it is not compatible with AdvancedLighting. U can try to use the SDL MSAA to avoid this.
    We can use MSAA with deferred shading. it's a disadvantage of this render technique. If you notice that message also appears in DX9.

    Quote: and some part of code won't work, like mouse/context traslation
    This it's a "feature" onf Linux :P
    When an application grab input, there are only two ways for the release:
    * The application explicitly releasing the grab. This is not possible when a crash occurs, debug breakpoint or similar.
    * The application closes. This is not very useful for dubug.

    I have updated documentation with how to debug in Linux.

    Quote:or gl texture copy for postfx, so i have crash when start the level.
    Posible related to SDL/GLEW problem.
    #133
    04/19/2014 (4:01 am)
    Fix for the GL Debug messages

    Engine/source/gfx/gl/gfxGLDevice.cpp around the line 121
    #if TORQUE_DEBUG
       if( gglHasExtension(KHR_debug)||gglHasExtension(ARB_debug_output))
       {
          glEnable(GL_DEBUG_OUTPUT);
          glDebugMessageCallback(glDebugCallback, NULL);      
          glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
          GLuint unusedIds = 0;
          glDebugMessageControl(GL_DONT_CARE,
                GL_DONT_CARE,
                GL_DONT_CARE,
                0,
                &unusedIds,
                GL_TRUE);
       }
       else if(gglHasExtension(AMD_debug_output))
       {
          glEnable(GL_DEBUG_OUTPUT);
          glDebugMessageCallbackAMD(&glAmdDebugCallback, NULL);
          glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
          GLuint unusedIds = 0;
          glDebugMessageEnableAMD(GL_DONT_CARE, GL_DONT_CARE, 0,&unusedIds, GL_TRUE);
       }
    #endif

    to:
    #if TORQUE_DEBUG
       if( gglHasExtension(ARB_debug_output))
       {
           glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
           glDebugMessageCallbackARB(&glDebugCallback, NULL);
           GLuint unusedIds = 0;
           glDebugMessageControlARB(GL_DONT_CARE,
                 GL_DONT_CARE,
                 GL_DONT_CARE,
                 0,
                 &unusedIds,
                 GL_TRUE);
       }
       else if(gglHasExtension(AMD_debug_output))
       {
          glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
          glDebugMessageCallbackAMD(&glAmdDebugCallback, NULL);
          GLuint unusedIds = 0;
          glDebugMessageEnableAMD(GL_DONT_CARE, GL_DONT_CARE, 0,&unusedIds, GL_TRUE);
       }
    #endif

    And:
    void STDCALL glDebugCallback(GLenum source, GLenum type, GLuint id,
       GLenum severity, GLsizei length, const GLchar* message, void* userParam)
    {
       Con::errorf("OPENGL: %s", message);
    }
    
    void STDCALL glAmdDebugCallback(GLuint id, GLenum category, GLenum severity, GLsizei length,
       const GLchar* message,GLvoid* userParam)
    {
       Con::errorf("OPENGL: %s",message);
    }

    to:
    void GLAPIENTRY glDebugCallback(GLenum source, GLenum type, GLuint id,
       GLenum severity, GLsizei length, const GLchar* message, void* userParam)
    {
       Con::errorf("OPENGL: %s", message);
    }
    
    void GLAPIENTRY glAmdDebugCallback(GLuint id, GLenum category, GLenum severity, GLsizei length,
       const GLchar* message,GLvoid* userParam)
    {
       Con::errorf("OPENGL: %s",message);
    }
    #134
    04/19/2014 (4:53 am)
    I had not noticed that KHR_debug and ARB_debug_output, used different functions.

    Because really we do not use KHR_debug, I will remove it. More simple.

    I will preserve GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB and GL_DEBUG_OUTPUT because according to the specs have different functions.

    Quote:
    When DEBUG_OUTPUT_SYNCHRONOUS_ARB is disabled, the driver is optionally allowed to concurrently call the debug callback routine from potentially multiple threads,...
    #135
    04/19/2014 (5:54 am)
    It makes no sense, because in this case the debug messages will be set only once and directly in the GL initialization phase. At the end... during the first call to the callback will be used equally single-thread mode. Why glEnable (GL_DEBUG_OUTPUT_SYNCHRONOUS) automatically disable the multi-threading.

    phase1 : set multi-thread
    phase2 : link the callback
    phase3 : set single-thread
    phase... : call the callback
    phase... : call the callback
    phase... : call the callback
    ...

    So glEnable (GL_DEBUG_OUTPUT) have no effect, because it is canceled by phase3.

    And, i have used glDebugMessageCallbackARB instead the no ARB glDebugMessageCallback, with a pointer to the callback code.
    #136
    04/19/2014 (6:24 am)
    Have the debugging messages on the primary gl thread add more control in the dubugging session, so i prefer GL_DEBUG_OUTPUT_SYNCHRONOUS for the messages.
    #137
    04/19/2014 (8:05 am)
  • GLAPIENTRY are not defined on Windows. Revert to SDTCALL. STDCALL are the same define as GLAPIENTRY.
  • The ARB functions/enums are used because they are defined in GL_ARB_debug_output. Non-ARB are form GL_KHR_debug

  • Sorry I have explained badly :D

    About:
    Quote: I will preserve GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB and GL_DEBUG_OUTPUT because according to the specs have different functions.
    I wanted to say that GL_DEBUG_OUTPUT_SYNCHRONOUS or GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB not automatically activates the debug output, only controls the way he does. You removed glEnable(GL_DEBUG_OUTPUT) in your code.

    Thx for take the time to review.
    #138
    04/20/2014 (10:11 am)
    Fix for get the current free video memory amount (AMD/ATI only for now):

    On file Engine/source/gfx/gl/sdl/gfxGLDevice.sdl.cpp around the line 179

    From:
    U32 GFXGLDevice::getTotalVideoMemory()
    {
       // CodeReview [ags 12/21/07] Figure out how to do this.
        return 0;
    }

    to:
    U32 GFXGLDevice::getTotalVideoMemory()
    {
        // Source: http://www.opengl.org/registry/specs/ATI/meminfo.txt
        if( gglHasExtension(ATI_meminfo))
        {
            GLint mem[4] = {0};
            glGetIntegerv(0x87FC, mem);  // Retrieve the texture pool
           
            /* With mem[0] i get only the total memory free in the pool in KB
             *
             * mem[0] - total memory free in the pool
             * mem[1] - largest available free block in the pool
             * mem[2] - total auxiliary memory free
             * mem[3] - largest auxiliary free block
             */
      
            return  mem[0] / 1024; 
        }
    
        return 0;
    }

    The engine log now:
    % Device created, setting adapter and enumerating modes
    % Initializing GFXCardProfiler (GL4.3)
    %    o Chipset : 'ATI Technologies Inc.'
    %    o Card    : 'AMD Radeon HD 5450'
    %    o Version : '4.3.12798 Compatibility Profile/Debug Context 13.35.1005'
    %    o VRAM    : 910 MB
    %    - Scanning card capabilities...
    % GFXCardProfiler (GL4.3) - Setting capability 'maxTextureWidth' to 16384.
    % GFXCardProfiler (GL4.3) - Setting capability 'maxTextureHeight' to 16384.
    % GFXCardProfiler (GL4.3) - Setting capability 'maxTextureSize' to 16384.
    % GFXCardProfiler (GL4.3) - Setting capability 'GL::suppVertexBufferObject' to 1.
    % GFXCardProfiler (GL4.3) - Setting capability 'GL::suppRenderTexture' to 1.
    % GFXCardProfiler (GL4.3) - Setting capability 'GL::suppRTBlit' to 1.
    % GFXCardProfiler (GL4.3) - Setting capability 'GL::suppFloatTexture' to 1.
    % GFXCardProfiler (GL4.3) - Setting capability 'GL::suppAnisotropic' to 1.
    % GFXCardProfiler (GL4.3) - Setting capability 'GL::suppFragmentShader' to 1.
    % GFXCardProfiler (GL4.3) - Setting capability 'GL::APPLE::suppFence' to 1.
    % GFXCardProfiler (GL4.3) - Setting capability 'GL::Workaround::needsExplicitGenerateMipmap' to 0.
    % GFXCardProfiler (GL4.3) - Setting capability 'GL::Workaround::X1600DepthBufferCopy' to 0.
    % GFXCardProfiler (GL4.3) - Setting capability 'GL::Workaround::HD2600DepthBufferCopy' to 0.
    % GFXCardProfiler (GL4.3) - Setting capability 'GL::Workaround::noManualMips' to 0.
    #139
    04/20/2014 (3:42 pm)
    Nvidia:

    //source http://www.opengl.org/registry/specs/NVX/gpu_memory_info.txt
    if( gglHasExtension(NVX_gpu_memory_info))  
    {
       GLint mem = 0;
       glGetIntegerv(0x9048, &mem);//GL_GPU_MEM_INFO_TOTAL_AVAILABLE_MEM_NVX
       return mem / 1024;
    }
    #140
    04/21/2014 (1:33 am)
    Thx, I will add this in the next update.