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


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:
How to compile
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?
- Try compile and share your problems.
- Contribute to the development with pull request or bug reports.
- Donate. Thanks to the donations I can devote more time to the project and speedup development.
Reporting bugs:
If possible, Github is a great place to post issues to a forum.I appreciate any donation to help the project.
.About the author
I'm working on a port of Torque3D to OpenGL and Linux/SteamOS
#82
02/03/2014 (8:44 pm)
Just gave it another shot in mint 16 32-bit. ~30 fps with advanced lighting on. Runs pretty decent. It's really coming along Luis, good job.
#83
But this is definitly my most wanted feature for Torque3D, awesome work!
02/04/2014 (8:44 am)
Maybe we can close the linux port feature request on the Torque3D forum then? :pBut this is definitly my most wanted feature for Torque3D, awesome work!
#84
One thing, i couldn't help notice was the use of:
Doesn't this slightly negate the purpose of using DSA in the first place?
02/08/2014 (12:49 am)
Working well so far Luis, well done.One thing, i couldn't help notice was the use of:
if( gglHasExtension(EXT_direct_state_access) )
Doesn't this slightly negate the purpose of using DSA in the first place?
#85
@Timmy, I've responded in the thread of OpenGL.
Thanks for your comment, do not hesitate to share any ideas or feedback on the project.
02/08/2014 (4:55 am)
@Richard, it's a problem if appear no errors during shaders compilation. Try updating the drivers for the graphics card. Can you give me more details about your OS, graphic cards and drivers?@Timmy, I've responded in the thread of OpenGL.
Thanks for your comment, do not hesitate to share any ideas or feedback on the project.
#86

Any enhacements we make I can throw back your way as pull requests.
Thanks for all your hardwork.
-Tim
02/08/2014 (8:35 am)
I got the linux branch integrated into our custom version of T3D 3.5. Still have a lot of errors to fix, but here is a screenshot thats not T3D demo :)
Any enhacements we make I can throw back your way as pull requests.
Thanks for all your hardwork.
-Tim
#87
Edit: Found another bug dealing with script compilation. If you have /// on a line by itself in a script file, it will comment out the next line since there are no windows EOL markers. This is causing script compilation failures on some functions. This was also causing complete variables to get commented out. I do not have a fix for this since i do not know much about modifying the compiler, I am just fixing all of the cs files that have the issue.
02/09/2014 (11:01 am)
Fixed one issue so far. keys like backspace are producing garbage in text edits. I traced it down to TranslateOSString which converts the XKeyEvent to ascii and the code calling it sends a charEvent for all returned values except for 0. Really this code should be replaced with something that does proper unicode since its casting a S8 to S16, but I fixed the garbage for now by changing the return to check:if (c[0] > 31 && c[0] < 127) return c[0]; else return 0;
Edit: Found another bug dealing with script compilation. If you have /// on a line by itself in a script file, it will comment out the next line since there are no windows EOL markers. This is causing script compilation failures on some functions. This was also causing complete variables to get commented out. I do not have a fix for this since i do not know much about modifying the compiler, I am just fixing all of the cs files that have the issue.
#88
So at first I thought I was missing a dependancy, but after I googled it I found:
https://bugs.launchpad.net/ubuntu/+source/libsdl1.2/+bug/66217
More specifically:
So, I commented it out to see how far I could get without it. It compiled fine after that but when I run it I get a white screen for about 20 seconds then it closes. I checked the console.log and this is what I'm getting:
pastebin.com/YX8uKZNm
I truncated the end of it since it continued for 10000+ lines.
02/12/2014 (2:06 pm)
Just tried make files on slackware 14.1. First run it wouldn't build because of these lines in the file x86UNIXInputManager.client.cpp:extern "C" Uint16 X11_KeyToUnicode( SDLKey keysym, SDLMod modifiers ); ... key = X11_KeyToUnicode( skey, mod );
So at first I thought I was missing a dependancy, but after I googled it I found:
https://bugs.launchpad.net/ubuntu/+source/libsdl1.2/+bug/66217
More specifically:
Quote:... this is an internal function which should not be used by new SDL-using code.
So, I commented it out to see how far I could get without it. It compiled fine after that but when I run it I get a white screen for about 20 seconds then it closes. I checked the console.log and this is what I'm getting:
pastebin.com/YX8uKZNm
I truncated the end of it since it continued for 10000+ lines.
#89
@Andrew, We will use SDL2 for window and input, I'll have to check all the old code that uses SDL1.2.
02/12/2014 (5:09 pm)
@Tim, thx for the fix :D ... weird script compilation bug. Added to my ToDo.@Andrew, We will use SDL2 for window and input, I'll have to check all the old code that uses SDL1.2.
#90
02/13/2014 (6:26 am)
@Luis: I was told that the script compilation bug was happening cause the parser was looking for CRLF, so for the /// to work correctly you need windows EOL. I don't know enough about flex and bison to fix it. I think /// is defined in CMDscan.l. You will have to regenerate the cpp files on windows unless you want to get the torque flex and bison script working on linux :)
#91
02/14/2014 (5:58 pm)
Found another bug. While working on a custom shader I noticed that vBinormal comes out all black so it seems to not be getting set correctly in opengl. vNormal and vTagent are fine though. So for now I fixed it in my shader buy just setting the binormal to cross(vNormal,vTangent)
#92
02/16/2014 (1:13 pm)
Has anyone tried Precipitation on linux? Trying to track it down but not sure if its a problem with stock or our game. We have snow in a level and its snowing blue squares. Does not look to be a path issue so I am thinking it is something with opengl. I have not had a chance to look at it much yet, but if I come up with a fix I will post it here.
#93
02/16/2014 (1:25 pm)
@Tim, Again I have Ubuntu running, I'll devote some time to the problems you mention.
#94
#define IN_uv0 gvTexCoord0
should be changed to
#define IN_uv0 vTexCoord0
02/16/2014 (6:35 pm)
Found and fixed a shader typo. in common/gl/basicCloudsV.glsl#define IN_uv0 gvTexCoord0
should be changed to
#define IN_uv0 vTexCoord0
#95
02/16/2014 (6:43 pm)
Awesome to see you on board Tim, and great to see DH running on Linux :).
#96
Replace setupGenericShaders in gfx/gl/gfxGLDevice.cpp with:
Then in T3D/fx/precipitation.cpp Replace the two calls to GFX->disableShaders() with:
Continued in next post...
02/16/2014 (10:37 pm)
I fixed the precipitation bug now that I got a chance to check it. The problem is it calls disableShaders which uses fixed function on DX, but on OGL it calls setupGenericShaders which defaults to GSColor so it does not use the texture. I fixed it with the following changes:Replace setupGenericShaders in gfx/gl/gfxGLDevice.cpp with:
void GFXGLDevice::setupGenericShaders( GenericShaderType type )
{
AssertFatal(type != GSTargetRestore, "");
if( mGenericShader[GSColor] == NULL )
{
ShaderData *shaderData;
shaderData = new ShaderData();
shaderData->setField("OGLVertexShaderFile", "shaders/common/fixedFunction/gl/colorV.glsl");
shaderData->setField("OGLPixelShaderFile", "shaders/common/fixedFunction/gl/colorP.glsl");
shaderData->setField("pixVersion", "2.0");
shaderData->registerObject();
mGenericShader[GSColor] = shaderData->getShader();
mGenericShaderBuffer[GSColor] = mGenericShader[GSColor]->allocConstBuffer();
mModelViewProjSC[GSColor] = mGenericShader[GSColor]->getShaderConstHandle( "$modelView" );
shaderData = new ShaderData();
shaderData->setField("OGLVertexShaderFile", "shaders/common/fixedFunction/gl/modColorTextureV.glsl");
shaderData->setField("OGLPixelShaderFile", "shaders/common/fixedFunction/gl/modColorTextureP.glsl");
shaderData->setSamplerName("$diffuseMap", 0);
shaderData->setField("pixVersion", "2.0");
shaderData->registerObject();
mGenericShader[GSModColorTexture] = shaderData->getShader();
mGenericShaderBuffer[GSModColorTexture] = mGenericShader[GSModColorTexture]->allocConstBuffer();
mModelViewProjSC[GSModColorTexture] = mGenericShader[GSModColorTexture]->getShaderConstHandle( "$modelView" );
shaderData = new ShaderData();
shaderData->setField("OGLVertexShaderFile", "shaders/common/fixedFunction/gl/addColorTextureV.glsl");
shaderData->setField("OGLPixelShaderFile", "shaders/common/fixedFunction/gl/addColorTextureP.glsl");
shaderData->setSamplerName("$diffuseMap", 0);
shaderData->setField("pixVersion", "2.0");
shaderData->registerObject();
mGenericShader[GSAddColorTexture] = shaderData->getShader();
mGenericShaderBuffer[GSAddColorTexture] = mGenericShader[GSAddColorTexture]->allocConstBuffer();
mModelViewProjSC[GSAddColorTexture] = mGenericShader[GSAddColorTexture]->getShaderConstHandle( "$modelView" );
shaderData = new ShaderData();
shaderData->setField("OGLVertexShaderFile", "shaders/common/fixedFunction/gl/textureV.glsl");
shaderData->setField("OGLPixelShaderFile", "shaders/common/fixedFunction/gl/textureP.glsl");
shaderData->setSamplerName("$diffuseMap", 0);
shaderData->setField("pixVersion", "2.0");
shaderData->registerObject();
mGenericShader[GSTexture] = shaderData->getShader();
mGenericShaderBuffer[GSTexture] = mGenericShader[GSTexture]->allocConstBuffer();
mModelViewProjSC[GSTexture] = mGenericShader[GSTexture]->getShaderConstHandle( "$modelView" );
}Then in T3D/fx/precipitation.cpp Replace the two calls to GFX->disableShaders() with:
GFX->setupGenericShaders(GFXDevice::GenericShaderType::GSTexture);
Continued in next post...
#97
textureV.glsl
textureP.glsl
02/16/2014 (10:37 pm)
Also need to add two shaders to common/fixedFunction/gl/textureV.glsl
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../gl/hlslCompat.glsl"
attribute vec4 vPosition;
attribute vec2 vTexCoord0;
uniform mat4 modelview;
varying vec2 texCoord;
void main()
{
gl_Position = mul(modelview, vPosition);
correctSSP(gl_Position);
texCoord = vTexCoord0.st;
}textureP.glsl
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
uniform sampler2D diffuseMap;
varying vec2 texCoord;
void main()
{
gl_FragColor = texture2D(diffuseMap, texCoord);
}
#98
1. Make sure the provider is set to OpenAL in script. If you use something else in windows you can use the follow code to set it on linux.
2. Open sfx/openal/aldlist.cpp
At the top of the file replace:
with
3. Open sfx/openal/LoadOAL.h and at top of file replace:
with:
4. Around line 63 of sfx/openal/sfxALDevice.cpp make the following changes:
5. Add the sfx/openal folder to your project files (excluding the mac and win32 directories) and create a new folder called linux and untar the following file there:
www.playmech.com/LoadOAL.linux.cpp.tar.gz and then add the linux folder to your project files.
02/17/2014 (2:59 pm)
I have ported OpenAL to work on Linux now. I know I should make a pull request but I am working out of a custom repo so I am not setup to be able to do a pull request. Ill go ahead and post the changes here for luis to add like I have previous stuff. You will need to make sure that 1. Make sure the provider is set to OpenAL in script. If you use something else in windows you can use the follow code to set it on linux.
if ($platform $= "x86UNIX")
$pref::SFX::provider = "OpenAL";2. Open sfx/openal/aldlist.cpp
At the top of the file replace:
#if defined(TORQUE_OS_MAC) #include <OpenAL/alc.h> #else #include <al/alc.h> #endif
with
#if defined(TORQUE_OS_MAC) #include <OpenAL/alc.h> #elif defined(TORQUE_OS_LINUX) #include <AL/alc.h> #else #include <al/alc.h> #endif
3. Open sfx/openal/LoadOAL.h and at top of file replace:
#if defined(TORQUE_OS_MAC) # include <OpenAL/al.h> # include <OpenAL/alc.h> #else # include <al/al.h> # include <al/alc.h> #endif
with:
#if defined(TORQUE_OS_MAC) # include <OpenAL/al.h> # include <OpenAL/alc.h> #elif defined(TORQUE_OS_LINUX) # include <AL/al.h> # include <AL/alc.h> #else # include <al/al.h> # include <al/alc.h> #endif
4. Around line 63 of sfx/openal/sfxALDevice.cpp make the following changes:
#ifndef TORQUE_OS_LINUX //ADD THIS
if( !Con::getBoolVariable( "$_forceAllMainThread" ) )
{
SFXInternal::gUpdateThread = new AsyncPeriodicUpdateThread
( "OpenAL Update Thread", SFXInternal::gBufferUpdateList,
Con::getIntVariable( "$pref::SFX::updateInterval", SFXInternal::DEFAULT_UPDATE_INTERVAL ) );
SFXInternal::gUpdateThread->start();
}
#endif //ADD THIS5. Add the sfx/openal folder to your project files (excluding the mac and win32 directories) and create a new folder called linux and untar the following file there:
www.playmech.com/LoadOAL.linux.cpp.tar.gz and then add the linux folder to your project files.
#99
About ///[EOL]:
Modify the lex file, is very simple. The problem is that we need to use the same versions of lex & bison than those used so far, to avoid possible errors in TorqueScript. The simple workaround is to use a text editor that saves to Win eol.
About vBinormal:
I was unable to spend time for this.
02/17/2014 (6:42 pm)
New update on Github: github.com/LuisAntonRebollo/Torque3D/tree/dev_linux_opengl- Linux Fix: No audio. Thx to Tim Newell.
- Linux Fix: Some keys like "delete" are producing garbage in text edits. Thx to Tim Newell.
- Linux Fix: Compilation error on precipitation.cpp
About ///[EOL]:
Modify the lex file, is very simple. The problem is that we need to use the same versions of lex & bison than those used so far, to avoid possible errors in TorqueScript. The simple workaround is to use a text editor that saves to Win eol.
About vBinormal:
I was unable to spend time for this.
#100
02/18/2014 (3:00 am)
Does this already support QT Creator?
raa brubb