User Tools

Site Tools


proton:linux_setup

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
proton:linux_setup [2012/02/26 11:21]
aki created
proton:linux_setup [2018/07/28 09:15] (current)
seth [Command line arguments]
Line 3: Line 3:
 In order to build the examples on Linux you first need some dependencies installed on your system. All of the needed dependencies are common in Linux distributions so you'll probably find everything needed through your distribution'​s package manager. The name of the packages vary slightly from distribution to another so you'll might need to search for the specific names a little. In order to build the examples on Linux you first need some dependencies installed on your system. All of the needed dependencies are common in Linux distributions so you'll probably find everything needed through your distribution'​s package manager. The name of the packages vary slightly from distribution to another so you'll might need to search for the specific names a little.
  
-The build scripts available for Linux use [[http://​www.cmake.org/​|cmake]] so you have to have that installed. In addition you need a bunch of other usual build tools like gcc, libc, make and possibly others. The Linux version uses SDL so you'll also need some development packages for SDL. It's usually called ​SDL-devel and in order to hear sounds you'll also need SDL_mixer-devel. This is not a complete list of the dependencies so you might need to try if the building succeeds and if not then install some more dependencies. Sometimes the build process outputs a sane error message that tells what is missing, sometimes it doesn'​t. Good luck :-P+The build scripts available for Linux use [[http://​www.cmake.org/​|cmake]] so you have to have that installed. In addition you need a bunch of other usual build tools like gcc, libc, make and possibly others. The Linux version uses SDL so you'll also need some development packages for SDL2. It's usually called ​SDL2-devel and in order to hear sounds you'll also need SDL2_mixer-devel. This is not a complete list of the dependencies so you might need to try if the building succeeds and if not then install some more dependencies. Sometimes the build process outputs a sane error message that tells what is missing, sometimes it doesn'​t. Good luck :-P
  
-=== Compiling RTBareBones ===+==== Grabbing Proton SDK ==== 
 + 
 +Ok, this was tested on a Raspberry Pi with Stretch, but normal linux distributions should be roughly the same. 
 + 
 +<code bash> 
 +cd ~ 
 +git clone https://​github.com/​SethRobinson/​proton.git 
 +</​code>​ 
 + 
 +Projects you compile are put INTO the Proton directory. ​ Sort of weird, but the end result is all paths and dependencies are relative when possible which make compiled for many platforms easier. ​ Nothing to setup. 
 + 
 +There is no lib/dll to make for Proton, the .cpp files are just used directly in the projects. ​ There is however a tool called RTPack that is used to build fonts (.rtfont files), images (.rttex files, don't have to use them though), and general purpose compression. (one gotcha: compressed files use the .rtpack extension EXCEPT .rtfont/​.rttex,​ those keep the same extension. ​ Proton'​s file handling automatically decompresses things when needed) 
 + 
 +Let's make the RTPack tool now. 
 + 
 +<code bash> 
 +cd proton/​RTPack/​linux 
 +sh linux_compile.sh 
 +</​code>​ 
 + 
 +Hopefully that worked. 
 + 
 +**Note:** By default, RTPack is compiled with the RT_NO_PVR flag, so support for a weird texture format called PVRTC isn't included. ​ If you really want that, you an go download the PVRTC libs. [[proton:​rtpack|(more info here)]], but you probably don't need it unless you're trying to optimize an iOS game or something. ​ It was a big thing in 2010, I don't know about now. 
 + 
 + 
 +==== Compiling ​and running ​RTBareBones ​====
  
 This is the process I follow when compiling the examples. You may vary this to your needs if you want since cmake is quite flexible in what it can do. But it's a safe bet to follow these quidelines if you are not yet too familiar with cmake. This is the process I follow when compiling the examples. You may vary this to your needs if you want since cmake is quite flexible in what it can do. But it's a safe bet to follow these quidelines if you are not yet too familiar with cmake.
  
-It'​s ​good practice to do so called out-of-source builds. This way the compiled object and other files don't pollute ​the source directory but instead they are put to a directory of their own. With cmake out-of-source builds are really easy.+Generally with linux stuff, you make "​build"​ directory and do your stuff there We do that too, but we do it from the <project name>/​linux/​build which is slightly different.  ​This is a side effect of linux related things being relegated to the linux dir due to the originally window-centric approach ​of Proton.
  
-So fire up your console and let's start typing.+So to compile RTBareBones,​ just do:
  
-First let'​s ​make a directory ​where the building will happen.+<code bash> 
 +cd proton/​RTBareBones/​linux 
 +sh linux_compile.sh 
 +</​code>​ 
 + 
 +(If you look at linux_compile.sh,​ it creates the build dir, does the cmake and make stuff, then copies the resulting binary to ../bin, which is where you should run it from.  (../bin is the standard location to put binaries in Proton SDK and where resources like jpgs/sounds are put) 
 + 
 +If the build finishes without errors you'll end up with a binary called ''​RTBareBones''​ in the ../bin directory. 
 + 
 +To try it:
  
 <code bash> <code bash>
-cd RTBareBones/linux +cd ../bin 
-mkdir build+./​RTBareBones
 </​code>​ </​code>​
  
-Then enter that directorycall cmake and then make.+On my Raspberry Pi I see a spinning triangle fullscreen. ​ Under Gnome or something I assume it would open in a window due to SDL2 being smart? (Not sure, didn't test it. -Seth ) 
 + 
 +====Compiling and running the other examples==== 
 + 
 +The compilation process for the other examples is exactly the same that what was explained for RTBareBones above.  
 + 
 +But in addition the other examples than RTBareBones need resources to be built as explained here: [[proton:​win_setup2|Compiling RTSimpleApp]].  
 + 
 +To do this in linux using RTPackyou need to move into your projects media directory ​and run build_media.sh, which itself runs RTPack/​linux/​build_media.sh to do the work. 
 + 
 +Let's build RTSimpleApp,​ then build its media:
  
 <code bash> <code bash>
-cd build +cd RTSimpleApp/​linux 
-cmake .. +sh linux_compile.sh 
-make+cd ../media 
 +sh build_media.sh 
 +cd ../bin 
 +./​RTSimpleApp
 </​code>​ </​code>​
  
-The argument to cmake (..) tells where it's supposed to search for the CMakeLists.txt build file that tells it what to doIf you make your build directory somewhere else than shown above you would need to adjust this argument accordingly but other than that the process should be exactly ​the same as here.+If that worked, the final stuff (.rtfont and .rttex and .rtpack files probablywill be copied into ../​bin/​interface,​ and you'll run the app.
  
-If the build finishes without errors you'll end up with a binary called ''​rtbarebones''​ in the build directory. In the process cmake has created a bunch of subdirectories and files but you don't need to care about these - let cmake do its stuff.+===How update_media.sh works===
  
-In order to run the compiled program you'll need to change ​to the directory which contains the images and other resources and execute ​the binary ​from there. This way the program ​can find the resources ​and load them correctly.+The resource building script goes to the subdirectories of the ''​media''​ directory and converts fonts and images ​to the Proton format. It uses a configuration file called ''​texture_conversion_flags.txt''​ that contains ​options for converting ​the images. The examples'​ ''​media''​ directories already contain these configuration files but if you'll build your own applications ​and want to use this system make sure you have these files in place. 
 +==== Debug builds ​ ==== 
 + 
 +The process described above for building ​the examples produces a binary ​that can be called a release build. We didn't give any special instructions for cmake so it chose the default settings. Especially the binary doesn'​t contain any debug symbols so it's not really suitable for a debugger. Luckily doing debug builds with cmake is quite easy. 
 + 
 +Let's use the RTBareBones as an example. This is one place where the out-of-source builds used above come handy. You already have a release build made to a directory ''​RTBareBones/​linux/​build''​. You can let the release build be there and do a debug build to another directory like this:
  
 <code bash> <code bash>
-cd ../../bin +cd RTBareBones/linux 
-../​linux/​build/​rtbarebones+mkdir build-debug 
 +cd build-debug 
 +cmake -DCMAKE_BUILD_TYPE=Debug ​.. 
 +make
 </​code>​ </​code>​
  
-Now you should see the application window.+Now you have the debug and release builds in separate subdirectories and they don't mess with each other. You can off course have more subdirectories to different kinds of builds as you desire.
  
-=== Building ​RTPack ​===+==== Building ​====
  
 +You basically only have to run cmake manually once per build directory. After that you can just run make. If the CMakeLists.txt file has been changed it is noticed by the build scripts and cmake is run automatically with the same parameters as it was run the first time.
  
-=== update_media ​===+==== Command line arguments ​==== 
 + 
 +**Note 7/​28/​2018:​** ​ I don't think any of this applies anymore since I switched the linux builds to use the normal SDL/​SDL2Main.cpp file as a base? -Seth 
 + 
 +The Linux versions of the examples accept a few command line arguments. You can choose the video mode and emulated environment (e.g. iOS, Android,​...) from a predefined set of presets. You can get a list of the available modes by running any of the examples with option ''​-l''​. 
 + 
 +<code bash> 
 +[user@localhost]$ ./​RTSimpleApp -l 
 +Available video modes: 
 + 
 +Windows 
 +Windows Wide 
 +OSX 
 +OSX Wide 
 +Linux 
 +Linux Wide 
 +iPhone 
 +iPhone Landscape 
 +[...] 
 +</​code>​ 
 + 
 +You can choose any of these modes by giving the name of it as an argument to the program. For example testing how an application might look on an iPad you can command: 
 + 
 +<code bash> 
 +./​RTSimpleApp "iPad Landscape"​ 
 +</​code>​
  
 +Note that you need to enclose modes with spaces between quotes.
  
-=== debug builds ​===+==== IDEs ====
  
 +All of the tools mentioned on this page work from the command line. It means that no IDE is chosen for you beforehand. You are free to use any editor or IDE you like, be it emacs or vi or something more sophisticated.
  
-=== IDEs ===+As a personal preference I'm using QtCreator. It has a nice built-in importer for cmake projects. Although QtCreator is mainly meant for Qt development it's a great IDE for any C++ development. You can open the CMakeLists.txt file with QtCreator and it automatically imports the project in to the IDE. You might need to set some paths or such in the project settings but it's relatively easy to get the building work with Ctrl+B and running with Ctrl+R. QtCreator also has a great UI for debugger.
  
 +You can set multiple run configurations so you can run the applications with different command line arguments for example - perhaps setting a different window resolution for each configuration.
  
proton/linux_setup.1330255296.txt.gz · Last modified: 2012/02/26 11:21 by aki