📜 ⬆️ ⬇️

Haiku operating system: porting applications and creating packages

In the autumn of this year, after 6 years of development, the first beta version of the Haiku operating system R1 / beta1 was released. I have been following this interesting project for a long time, which is aimed at the reconstruction and subsequent development of the BeOS system that existed in 1994-2000. Therefore, as soon as I saw news on the release of the beta version of Haiku on IT news sites, I immediately decided to see what was added to this long-awaited release. After installing the system in a VirtualBox virtual machine and a little familiarization with its main functionality, I thought that it would be nice to help the OpenSource community, which is developing this operating system today. I decided to start with what I have gained a little experience: with porting some game projects.


Desktop Haiku operating system.

Later I tried to modify some already existing applications and libraries. This is my small activity in various open source repositories that this article will be devoted to. In it, I will successively describe the problems I encountered and tell you about the methods for solving them. Most of the patches that were made in the course of this work, I tried to send upstream existing projects in order to provide support for Haiku and interest their developers in the existence of alternative operating systems.

The Haiku operating system uses a hybrid core , which is an implementation of the micronuclear architecture with the ability to dynamically load the necessary modules. It is based on the fork of the NewOS kernel, which was developed by a former Be Inc. engineer . , By Travis Geiselbrecht. Today, this developer is working at Google on a kernel called Zircon for the new Google Fuchsia operating system, but that's another story. So, since the Haiku developers declare binary compatibility with BeOS, they are forced to maintain not two architectural branches that are familiar to everyone, but three: x86_64, x86 and x86_gcc2. The latter architecture is the compiler load compatibility with the old version of GCC 2.95. Thanks to it, it is possible to launch applications written for the original BeOS operating system. Unfortunately, due to this compatibility load, Haiku developers cannot use the advanced features of the C ++ programming language in the system APIs. However, they prepare installation images only for two architectures: x86_64 and x86. The fact is that the Haiku distribution for x86 is a hybrid one: despite the fact that all system components are built under x86_gcc2 to provide binary compatibility, the user is given the opportunity to install or build any modern applications that were made with modern compilers and x86 architecture . The x86_64 Haiku distribution is fully 64-bit and does not have the ability to run 32-bit BeOS and Haiku applications. However, compatibility at the API level is available, so if you have the source code of the application under BeOS or Haiku x86, you can easily compile it under Haiku x86_64 and everything should work. An x86_64 operating system image is recommended for installation on real hardware, if you do not require support for any specific BeOS applications or 32-bit Haiku applications.
')
It is worth saying that this operating system has partial support for the POSIX standard. This foundation makes it akin to UNIX-like systems and makes it easy to port their software. The main programming language is C ++, it is actively used, since Haiku's public APIs mainly pursue an object-oriented programming paradigm. However, no one forbids the use of the C programming language, only for most cases you will have to write the appropriate compatibility layer. The operating system software interface is grouped into separate system frameworks that are responsible for a particular opportunity, for example, the interface or network support. This is a bit like what is available in macOS or in the Qt framework. It is necessary to note that this operating system is single-user, although there are some progress towards providing multi-user operation for Haiku developers.

I can not share with the readers of this article, the positive experience of using the advanced window management system of applications, which is available in Haiku. In my opinion, it is one of the most convenient and of its kind is the hallmark of this OS.


Advanced window management in the Haiku operating system: support for tiling and tabs.

Windows can be fastened together in tabs, as is done in modern browsers, attach them to each other and conveniently change their size. Simple tiling , context transfer of some applications from one window to another, and replicants are supported. For more information about all the features of the local window system can be found in the official documentation , there are also described all the necessary shortcut keys.

I will not write in this article a complete overview of all the features and capabilities of Haiku, since those who are interested in it will easily be able to independently find the necessary information on the Internet.

Content:


1. Packages and repositories in Haiku
2. First Steps: Porting the Adamant Armor Affection Adventure Game
3. Completion of the existing port NXEngine (Cave Story)
4. Porting the Gish game
5. The project BeGameLauncher, which allows you to quickly create launchers for games
6. Porting Xash3D: the legendary game Half-Life and official additions
7. Porting the two parts of the game Serious Sam: The First Encounter and The Second Encounter
8. Porting the game Vangers
9. Implementation of dialogs in the library SDL2 for Haiku
10. Porting my fork to the program Cool Reader
11. Improvement of the program KeymapSwitcher
12. Conclusion

1. Packages and repositories in Haiku


Compared to the original BeOS, Haiku has a significant innovation: the package management system, which includes various tools for getting and installing software from various sources. Such sources can be the official Haiku and HaikuPorts repositories, informal repositories and just separate and specially prepared HPKG packages. Such opportunities for installing and updating software have long been known in the world of Unix-like operating systems, but now all their power and convenience have successfully reached Haiku, which cannot but make ordinary users of this operating system happy. Thanks to the infrastructure manager built around the package manager, now any developer can easily port a new or modify an existing open source application, then add the results of his work to the ports repository of HaikuPorts software, after which they will be available to all Haiku users. As a result, the resulting ecosystem resembles that of macOS with their Homebrew , FreeBSD with their ports , Windows with MSYS2 or Arch Linux with its AUR 'ohm.

A tool for building packages and porting software, called HaikuPorter , comes separately from the operating system and installs on a small manual located in the repository on GitHub. After installing this utility, the entire recipe tree is downloaded from the same GitHub and the developer works on it. The recipe is a regular Shell script with instructions on which HaikuPorter will build the required HPKG package. It is noteworthy that the tool itself is written in the Python 2 programming language , works closely with the existing package management system, and uses the standard tool, Git , to capture changes in the software source code and generate a set of patches. Thanks to this stack of technologies, it is very easy and simple to make recipes for assembling HPKG packages and patch sets to software in the form of patchset files. In most cases, I had to use only three commands when working with HaikuPorter:

alias hp="haikuporter -S -j4 --get-dependencies --no-source-packages" hp libsdl2 hp libsdl2 -c hp libsdl2 -e 

The first command simply collects the selected package, the second command clears the build directory, and the third creates or updates the patch set according to your changes, which were recorded in the Git-repository of the working directory via commits.

Thus, to publish a package to the HaikuPorts repository and make it available to all Haiku users, the developer must install the HaikuPorter, expand the recipe tree, locally build the HPKG package and test it, then make a commit in its fork of the recipe tree, after that draw the Pull request on GitHub. The published work must be considered by the Haiku developers, after which they decide to pour your changes into the repository or send them for revision. If changes are accepted, then the same HaikuPorter installed on the build server will remotely assemble the package and automatically publish it to the repository.

A special HaikuDepot program was added to the beta version of R1 / beta1 of the Haiku operating system, which allows you to work with packages and repositories through a graphical user interface, rather than via console commands in the terminal.


The HaikuDepot program running on the Haiku operating system.

Thanks to this tool, inexperienced and novice Haiku users can conveniently manage their package base. It should be noted that this application is not just a GUI shell over the existing package manager, but also implements additional functionality. For example, authorized users can rate and write reviews for packages available for installation. In addition, HaikuDepot has a special Haiku Depot Web site that allows you to view changes to the package base on the Internet or download individual HPKG packages.

<< Skip to content

2. First Steps: Porting the Adamant Armor Affection Adventure Game


After I familiarized myself with the functionality of the operating system in the VirtualBox virtual machine, I decided to evaluate the work of the SDL2 library in it and port the Adamant Armor Affection Adventure game to Haiku, about which I wrote to the Android platform earlier. Building the program did not require any changes to the source code, I just installed all the necessary tools, libraries, their header files from the repository and did the following:

 cmake -DCMAKE_BUILD_TYPE=Release -DGLES=off -DANDROID=off -DCMAKE_C_FLAGS="-D__linux__" -DSDL2_INCLUDE_DIR=`finddir B_SYSTEM_HEADERS_DIRECTORY` -DSDL2_MIXER_INCLUDE_DIR=`finddir B_SYSTEM_HEADERS_DIRECTORY` ../aaaa/src/main/cpp cmake --build . 

Since Haiku has POSIX, the -D__linux__ or -D__unix__ defaults solve many problems associated with the definition of the platform. However, it is worth noting that it is best to abandon their use and implement support for Haiku in the source code of the project, if there are similar problems with the assembly. Calling the system utility finddir with a specific argument allows you to get the correct path to the header files for different architectures.

So, having executed the commands above, I compiled an executable file that started perfectly, and the game worked fine. I thought that it would be cool to prepare a self-sufficient HPKG package with the game and for this I went deep into the Internet in search of the information I needed. Then I didn’t know about any convenient tools for porting software, like HaikuPorter, which I wrote about in the section above, so for the realization of my goal I decided to cheat and disassemble any system package to see how it works inside and done by analogy.

On the Internet, I found the desired information , then unpacked a random system package using the Expander archiver built into the local file manager, found the .PackageInfo file, edited it and, in accordance with the structure of my application, changed the files. Then I just executed the commands to build the HPKG package and install it into the system:

 package create -C AAAA/ aaaa.pkg pkgman install aaaa.pkg 

Unfortunately, the launch of the game from the “Applications” menu was not successful. Having run the executable file in the terminal, I received an error saying that it was impossible to find the data files that were necessary for the launch and operation of the application. At the same time, if you go to the application package directory in the terminal, then everything started up normally. This gave me the idea that when you start the game from the menu you need to make a forced change to the application directory. This can be done either with a shell script or by changing the source of the game. I chose the second option and added something similar to this code:

 #ifdef __HAIKU__ // To make it able to start from Deskbar chdir(dirname(argv[0])); #endif 

At the very beginning of the start function main () , which completely solved this problem and the package turned out to be workable. In the comments on the news about the release of the Haiku beta on Linux.org.ru, I dropped a link to my assembled package and asked someone to send me to some active communities of users of this operating system, then went to bed.


The port of the game Adamant Armor Affection Adventure, running on the Haiku operating system.

In the morning I wrote an e-mail to a person using the nickname 3dEyes . As it turned out later, Gerasim Troyeglazov , one of the active developers of Haiku and the author of the port of the Qt framework for this operating system, was hiding behind this name. He showed me the HaikuPorts repository and told me how to use the HaikuPorter utility. In addition, he wrote a recipe for building the Adamant Armor Affection Adventure HPKG package and added it to HaikuDepot.

After analyzing all the changes made by this developer, I noticed that there were some flaws in my manually assembled package, for example, the settings were not saved because the mounted directories of the installed packages did not have the ability to write. This problem with writing settings or saving in its package was elegantly solved with the help of symlinks in a special recordable directory for saving user data. My package also did not have its own original icon.

In addition, I learned that in Haiku there is no hardware acceleration of 3D graphics and the same OpenGL is drawn programmatically using CPU power. For heavy graphics applications this, of course, is no good, but for old games this is more than enough. I even decided to specifically check the game package and installed Haiku on my old laptop, that is, on real hardware. To my surprise, the Adamant Armor Affection Adventure picture rendered so fast that if I hadn’t been told about the lack of hardware acceleration, I wouldn’t have noticed that the rendering is done by my processor.

Project Source Code: https://github.com/EXL/AdamantArmorAffectionAdventure

I postponed the manual creation of HPKG packages until better times and completely switched to using the HaikuPorter tool and writing recipes. But sometimes there are situations when manual reassembly is required. For example, if HaikuPorter has set the “night” version of Haiku too high in the .PackageInfo file, the package should be tested on the release version of the operating system. It is worth noting that it was thanks to Gerasim’s responsiveness and experience that I was able to understand many of the intricacies of creating packages for the Haiku operating system and continued my work further.

<< Skip to content

3. Completion of the existing port NXEngine (Cave Story)


I was incredibly surprised to find in the HaikuPorts repository a recipe that referred to my fork of the NXEngine engine for the game Cave Story , which I had been analyzing for a long time on my blog. The recipe and patches were prepared by a developer named Zoltán Mizsei , who uses the nickname extrowerk and is the active maintainer of many packages for Haiku.

Surface analysis, package installation and application launch revealed the same problems that I described in the previous section of this article: saving the game did not work, the settings were not saved either, and besides the package did not have the original icon. I decided to correct these shortcomings and started working on the patch, first integrating all the extrowerk's work. I wrote an original Makefile for the Haiku operating system and corrected the recording and saving of various user data.


The port of the game Cave Story based on the NXEngine engine, launched in the Haiku operating system.

Since the game assumed Russian and English versions with a different set of executable files and data files, I decided to make a general package that combines two versions at once and automatically selects the necessary one based on the system language chosen by the user. This was implemented by the simplest shell script:

 #!/bin/bash if [[ `locale -l` == ru* ]] ; then EXE="`finddir B_SYSTEM_APPS_DIRECTORY`/NXEngine/RUS/Cave Story" else EXE="`finddir B_SYSTEM_APPS_DIRECTORY`/NXEngine/ENG/Cave Story" fi "$EXE" $@ 

This script is launched when the game item is selected in the “Applications” menu and determines the current system locale. In the event that the user chose Russian as the system language, the Russian version of the game will be launched, and in all other cases - the English version.

But with the creation of the original icons for the application had to pretty tricky. The fact is that in the Haiku operating system, only vector icons of a special HVIF format are allowed , which are set as attributes of the Be File System file system. In the official documentation, there are two large manuals dedicated to creating your own icons for applications: the first manual describes the styling and design, and the second manual describes in detail how to use the Icon-O-Matic system program for creating icons.

Icon-O-Matic allows you to import simple SVG files and export the resulting icon to the necessary format for HaikuPorter, called HVIF RDef, which is the same HVIF, but converted to text. RDef files can contain not only images, but also additional information, for example, the version of the application and its description. Something these files resemble RES-files used in Windows. The following commands in the recipe compile RDef files and set the result to special attributes:

 rc nxengine-launcher.rdef resattr -o "$appsDir/NXEngine/Cave Story" nxengine-launcher.rsrc addResourcesToBinaries $sourceDir/build/nxengine-rus.rdef "$appsDir/NXEngine/RUS/Cave Story" 

In addition, the recipes define the addResourcesToBinaries function to automate this work. The problem with the Icon-O-Matic program is one, but very serious: those SVG files that are saved by the popular Inkscape vector editor either do not open or are imported without the support of some necessary features, for example, gradients. Therefore, an adventure quest with converting raster images into vectors through the use of various paid and free online and offline converters, and then opening the resulting SVG files in Icon-O-Matic, I failed miserably. Later, I solved the problem of opening SVG files and found a workaround, but I'll write about this below. In the meantime, I decided to use the standard features of Icon-O-Matic and draw an icon on my own. After half an hour of work on hard copying pixels, I got the following art:


The standard program is Icon-O-Matic in the Haiku operating system.

Yes, I used a vector editor to create an image in the Pixel Art genre. In my amateurish opinion, a person who is poorly versed in art, turned out quite well. I saved this icon in the right format, prepared all the changes, updated the recipe and sent everything to the HaikuPorts repository.

Project Source Code: https://github.com/EXL/NXEngine

I sent the resulting packages, just in case, to the fan site of the game Cave Story (Doukutsu Monogatari) , the administration of which added the Haiku operating system to the downloads section.

<< Skip to content

4. Porting the Gish game


The next project I decided to transfer to Haiku was Gish , which I previously transferred to Android. In the HaikuPorts repository there was a recipe for an unfinished free implementation of the game called Freegish , so I decided to add the original game there, but without the data files, since they, unlike the engine, are supplied separately and are not free at all.


The port of the game Gish, launched in the Haiku operating system.

I had no particular problems with porting this game. The executable file was assembled immediately after the execution of the following build commands:

 cmake gish/src/main/cpp/ \ -DGLES=0 \ -DANDROID=0 \ -DSDL2_INCLUDE_DIR=`finddir B_SYSTEM_HEADERS_DIRECTORY` \ -DCMAKE_C_FLAGS="`sdl2-config --cflags` -D__linux__" \ -DCMAKE_BUILD_TYPE=Release cmake --build . 

Next, I implemented the ability to launch the game from the “Applications” menu and provided support for storing user data in a writable and dedicated directory:

 char* getHaikuSettingsPath() { char path[PATH_MAX]; find_directory(B_USER_SETTINGS_DIRECTORY, -1, false, path, sizeof(path)); strcat(path, "/Gish/"); return strdup(path); } 

The getHaikuSettingsPath () function using the find_directory () function from the Haiku API generates the full path to the directory I need.

Project Source Code: https://github.com/EXL/Gish

It remained to solve the following question: how should the user choose the directory with the original files of the game Gish? The problem could be solved using Shell-scripts and the alert system utility, but I decided to approach this problem more thoroughly and implement a convenient GUI launcher using the Haiku API and the Interface Kit framework.

<< Skip to content

5. The project BeGameLauncher, which allows you to quickly create launchers for games


My project BeGameLauncher was decided to write in C ++ the old standard of 1998, using native operating system tools for creating applications with a graphical user interface. Since the names of many programs for Haiku and BeOS begin with the re-fix “Be”, I also decided to choose such a name for the project. I decided to start with an introduction to the Interface Kit framework, which is part of the Haiku API. In addition to sufficiently detailed documentation on the official Haiku website, I found two simply excellent courses of lessons from DarkWyrm , which allow the novice developer to quickly understand how these or other system classes work. The first course is called Learning to Program with Haiku and at the very beginning touches upon the foundations of the C ++ programming language, which will be very useful for beginning programmers. The second course is called Programming With Haiku and is intended for those who are already familiar with C ++ and have a basic knowledge of this language. Both courses talk about the most diverse aspects of the Haiku API and therefore will be very helpful to anyone who wants to start building applications for this operating system.

After reading this excellent material diagonally, I made a general impression of the Haiku API and began to consider my further actions. I already had some experience developing application applications using the Qt framework, which is also written in the C ++ programming language and uses the object-oriented paradigm of building programs. So, the Haiku API is very similar to it, except for the absence of a system of signals and slots, so I will often carry out some parallels and comparisons with Qt. In addition, it is worth noting the use of the principle of Event-driven programming , which is common in Haiku API, which allows various entities to interact with each other by transmitting events or messages. The analogue of the QEvent class here is the BMessage class, around which the system of interaction of objects is built. An instance of the BMessage class generally gets a unique number that allows you to identify the sender and its action in the general event filter.

For my project, it was necessary to select the appropriate Haiku API classes that would allow to implement the conceived functionality. First, to launch an external application, it was necessary to find an analogue of the QProcess class or the POSIX execve () function, which, by the way, also works fine in the Haiku operating system, but I decided that using native tools would be preferable, but just case left the ability to run applications through the POSIX-function. The inter -process interaction class BRoster was excellent for this purpose. It found the appropriate Launch () method, which allows you to set the path to the executable file and pass arguments to it. Since the launcher should be able to save some parameters, for example, a user-selected directory with game data files, I needed a class that does all this. In Qt, this class has the name QSettings , and in the Haiku API, as Gerasim suggested to me, there is a class BMessage already familiar to me, which has a very useful feature. The thing is that information of this class can be easily serialized and, for example, saved to disk. This is very convenient and is often used to record any user data in programs, so I chose this class to save the settings in my project for the implementation of launchers. , Haiku API QDebug , stderr , fprintf() C:

 // .h #if __cplusplus >= 201103L #define BeDebug(...) fprintf(stderr, __VA_ARGS__) #else extern void BeDebug(const char *format, ...); #endif // __cplusplus == 201103L // .cpp #if __cplusplus < 201103L #include <cstdarg> void BeDebug(const char *format, ...) { va_list args; va_start(args, format); vfprintf(stderr, format, args); va_end(args); } #endif 

BeDebug() , , . - , C++98 .

Qt QMessageBox , - , , , . Haiku API BAlert , , Qt. , , , - . , - .

. , , . , BeLauncherBase , , GUI-. , BeAboutWindow , « ...» , . , , , Gish, :

 class GishAboutWindow : public BeAboutWindow { ... }; class GishLauncher : public BeLauncherBase { ... }; int main(void) { BeApp *beApp = new BeApp(SIGNATURE); GishLauncher *gishLauncher = new GishLauncher(BeUtils::GetPathToHomeDir()); beApp->SetMainWindow(gishLauncher); beApp->Run(); delete beApp; beApp = NULL; return 0; } 


-, main() , - . C++- Gish .


« ...» Gish.

, . . . «Run» setenv() , getenv() , . , , BRoster Launch() : , , . . . . , . , , . , . .

, . : Makefile « » CMake . , Haiku makefile-engine , , , Haiku API, , . , , CMake makefile-engine. , .


Gish Haiku.

. Qt - tr() , lrelease lupdate , . Qt Linguist , . Haiku API . , , B_TRANSLATE() , B_TRANSLATION_CONTEXT , . : -DB_COLLECTING_CATKEYS , - grep PRE- . collectcatkeys , CATKEYS-. linkcatkeys , . , . , Haiku API . , Localizing an application , . , BeOS Locale Kit Haiku.

C++. , Haiku Qt, HaikuPorts IDE, Qt Creator KDevelop . , JVM , IDE, Java, , NetBeans IntelliJ IDEA . Qt Creator, LibClang , .


Qt Creator, Haiku.

IDE Haiku . ? , DarkWyrm Adam Fowler , Paladin . Pe IDE.


Paladin Haiku, HaikuPorts.

Haiku Paladin Pe . HaikuPorts Koder , Notepad++ Windows Scintilla . PLD- , Paladin IDE, .

Qt Creator , . , , . BeOS GUI- . , , , . , Haiku Layout API , Interface Kit.


Layout API Haiku.

Layout API, . Haiku Laying It All Out , , .

, , . , Haiku . , Launch() BRoster . , , , . Haiku , , , Launch() , .

 // Error const char* args[] = { "/bin/open", fURL.String(), NULL }; be_roster->Launch(&ref, 2, args); // Good const char* args[] = { fURL.String(), NULL }; be_roster->Launch(&ref, 1, args); // See "src/kits/app/Roster.cpp", BRoster::ArgVector::Init() method: if (error == B_OK) { fArgs[0] = fAppPath.Path(); // <= Here if (argc > 0 && args != NULL) { for (int i = 0; i < argc; i++) fArgs[i + 1] = args[i]; if (hasDocArg) fArgs[fArgc - 1] = fDocPath.Path(); } // NULL terminate (eg required by load_image()) fArgs[fArgc] = NULL; } 

Launch() , , . . Haiku? . , ! GitHub Gerrit- Haiku Code Review , SSH-, Haiku, Code review :

 git clone ssh://EXL@git.haiku-os.org/haiku --depth=1 -b master && cd haiku git commit git push origin master:refs/for/master 

, commit- ID, Haiku Code Review. , , Haiku , . . , jam , Perforce Jam Haiku, . ReadMe.Compiling.md , .

, Icon-O-Matic SVG-, Inkscape. , Icon-O-Matic viewBox , , SVG- , Inkscape Plain SVG file , Icon-O-Matic. SVG-, Icon-O-Matic . ReadMe- , Inkscape.

, . , . , GetBitmap() BTranslationUtils NULL:

 // Somewhere fBitmap = BTranslationUtils::GetBitmap(B_PNG_FORMAT, fIndex); void BeImageView::Draw(BRect rect) { // Fail const BRect bitmapRect = fBitmap->Bounds(); ... } 

And in the Draw () method, I inadvertently forgot to check the field of the fBitmap class for validity. Therefore, the application was expected to fall if it did not find a specific picture, but according to the plan it was necessary to draw a red square instead. I told this story to the fact that static analyzers are far from a panacea and care when working with code in the C ++ programming language is required in any case.

I upload the source code of the BeGameLauncher project and all my work in the repository on GitHub. I hope this program will be useful to someone and may become a kind of textbook as a simple application for Haiku:

Project source code: https://github.com/EXL/BeGameLauncher

, HaikuPorts. Haiku, , , :

 settype -t application/x-vnd.Be-elfexecutable $appsDir/Gish/engine/Gish rc $portDir/additional-files/gish.rdef -o gish.rsrc resattr -o $appsDir/Gish/engine/Gish gish.rsrc 

QuickLaunch , . .

<<

6. Xash3D: Half-Life


Xash3D GoldSrc, Half-Life . Xash3D , . , FWGS Xash3D , , Windows. FWGS Xash3D mittorn a1batross ( libpony ), MotoFan.Ru , .

: Haiku, Xash3D , Haiku Half-Life, ? — .

, , Xash3D, Haiku. -, -D__linux__ . , , Half-Life Black Mesa.


Xash3D Haiku Qt Creator.

, SDL2, , - , , : , OpenGL-, . SDL2 . , Haiku , , , .

, , . C++- :


Xash3D Haiku.

: , . , . , XASH3D_BASEDIR , . XASH3D_GAME , . XASH3D_MIRRORDIR , . Xash3D . , , - Xash3D Haiku :

• ./cl_dlls/libclient-haiku.so
• ./dlls/libserver-haiku.so
• ./cl_dlls/libclient-haiku64.so
• ./dlls/libserver-haiku64.so

. Xash3D Half-Life, Blue Shift Opposing Force , , - .

Xash3D . , , --help , MAX_SYSPATH , MAX_PATH , Haiku API. , , . , - stderr . - , MAX_PATH Haiku. 1024 . , 4096 , . : MAX_PATH , .


Half-Life, Blue Shift Opposing Force, Xash3D Haiku (, ).

. , XASH_INTERNAL_GAMELIBS , . . a1batross , , OpenVGUI . Xash3D Haiku , XASH_INTERNAL_GAMELIBS .

Haiku WebPositive Xash3D . , , . execve() , system() , - .

Xash3D SDL_ShowSimpleMessageBox() SDL_ShowMessageBox() , SDL2 Haiku . . .


Xash3D, Haiku Depot.

, Xash3D Haiku, SDL2 ; 3D- . , , . , , . , . SDL2 Haiku Half-Life . , 3D- . , FPS. GPU, Intel.

: https://github.com/FWGS/xash3d

FWGS Xash3D, , HaikuPorts HaikuDepot Haiku.

<<

7. Serious Sam: The First Encounter The Second Encounter


Croteam Serious Engine , Serious Sam: The First Encounter The Second Encounter . Haiku, .


Serious Engine Haiku.

- , - , SDL2, Haiku. stderr , .


Serious Sam: The Second Encounter, Serious Engine Haiku.

Having decomposed the downloaded files into the required directories, I was able to launch the second part of this wonderful game without any problems and even ran a little through the beautiful jungle. Despite the lack of 3D acceleration, the processor pulls out the graphic charms of the game, if you run it in a window, and not in full-screen mode. This engine works, of course, where with a smaller FPS than the Xash3D engine, about which I wrote above, but the graphics here are more modern and better. After some manipulations, it was possible to launch the first part of the game, which requires a different executable file and a different set of dynamic libraries. Surprisingly, she earned a little faster, apparently the graphics in it are not so demanding. Having climbed the settings of the engine, I found a huge number of graphical parameters that can significantly reduce the load on the processor,that in the case of Haiku was very helpful.


Serious Sam: The First Encounter, Serious Engine Haiku.

, . , Serious Sam: The First Encounter, . Serious Sam: The Second Encounter, , .

, . . Linux . . , , SDL_Window , OpenGL- - . SDL2 Haiku . , , . , : , , .

. Linux, , . , libvorbisfile , , dlopen() , OGG-. , Haiku , .

 void CUnixDynamicLoader::DoOpen(const char *lib) { // Small HACK for Haiku OS (: #ifdef __HAIKU__ static int vorbis_cnt = 3; char path[PATH_MAX]; char libpath[PATH_MAX]; find_directory(B_SYSTEM_LIB_DIRECTORY, -1, false, libpath, PATH_MAX); if (strstr(lib, "vorbis")) { snprintf(path, sizeof(path), "%s/libvorbisfile.so.%c", libpath, char(vorbis_cnt + '0')); vorbis_cnt++; lib = path; } #endif // fprintf(stderr, "dlopen => %s\n", lib); module = ::dlopen(lib, RTLD_LAZY | RTLD_GLOBAL); SetError(); } 

, , . , . , API.

, , x86, x86_64 . x86 SERIOUS_MHZ , . , - . , , Haiku API , :

 #include <kernel/OS.h> #include <stdio.h> ... uint64 cpuFreq = 0; uint32 count = 0; get_cpu_topology_info(NULL, &count); if (count != 0) { cpu_topology_node_info *topology = new cpu_topology_node_info[count]; get_cpu_topology_info(topology, &count); for (uint32 i = 0; i < count; ++i) { if(topology[i].type == B_TOPOLOGY_CORE) { cpuFreq = topology[i].data.core.default_frequency; } } delete[] topology; } fprintf(stderr, "%llu\n", cpuFreq); 

. x86_64 , CPU 1 MHz, . , __GNU_INLINE_X86_32__ , , x86, x86_64. , SDL2, inline- rdtsc /proc/cpuinfo , , x86, .

. CMakeLists.txt -march=native , : , .

 if(NOT PANDORA AND NOT HAIKU) message("Warning: arch-native will be used!") add_compile_options(-march=native) endif() if(HAIKU) if(CMAKE_SIZEOF_VOID_P EQUAL 4) # 32-bit message("Warning: Will building 32-bit executable with MMX, SSE, SSE2 support.") add_compile_options(-mmmx -msse -msse2) else() # 64-bit message("Warning: Will building 64-bit executable.") endif() endif() 

- build- , . MMX, SSE SSE2 , inline- , , .

, Croteam - , :

: https://github.com/EXLMOTODEV/Serious-Engine

, Serious Sam, HaikuPorts. .

<<

8. (Vangers)


, , 90- KD Lab. Telegram IM , Haiku, GitHub- , .


Haiku.

Haiku - . FFmpeg , . , VANGERS_DATA , .


Haiku Qt Creator.

, KD Lab. «» «» «» «», «» . , , .


, Haiku.

, , , , GOG.com Steam , . , stalkerg Linux. , . , .

NXEngine (Cave Story), , , , . stalkerg -DBINARY_SCRIPT=Off , , , . , . : , , , .


, Haiku Depot.

, , Haiku. libclunk.so , . Linux, , LD_LIBRARY_PATH , , , , Haiku , Windows. , , Haiku ./lib/ , . .

: https://github.com/KranX/Vangers

, HaikuPorts HaikuDepot, , Linux- Fedora .

<<

9. SDL2 Haiku


When porting the Xash3D and Serious Engine engines, about which I wrote above, I stumbled across the local port of the SDL2 library at the complete lack of dialogue implementation. Dialogues are called by two functions SDL_ShowSimpleMessageBox () and SDL_ShowMessageBox () , which allow you to inform the user about any important information, such as an error. The implementation of these dialogs is available on many platforms and operating systems: Windows, macOS, iOS, X11 and Android, but for some reason is missing from Haiku. I decided to correct this omission and add this functionality to the SDL2 library port.

In the Haiku API, or rather in the Interface Kit framework, there is an excellent BAlert class . , . . , , , , , BAlert , . , : , , Go() . , , .


SDL2 Haiku.

, , , BAlert , BApplication , app_server . , BAlert , , BApplication , . Haiku API BApplication , be_app , Qt qApp , . , be_app NULL, , , . .

, SDL2 C, Haiku API, , C++. - extern "C" , . , new new(std::nothrow) , NULL, , SDL2, , .

. , SDL2 , Haiku API . which I occasionally ran on different operating systems, analyzed the results and evaluated my work. In the end, I got so carried away that I even made customization support, such as setting different colors to the buttons and dialogue background. This is supported by the SDL2 library API, but initially I did not plan to implement such things.

If the programmer decides to spit out a very, very long line into this dialog, then the BTextView class object that is used inside the BAlert class object needs to call the SetWordWrap () method with the argument true , , . , : strlen() . , SDL2 UTF-8, , strlen() , . Haiku API BString , CountChars() , , :

 bool CheckLongLines(const char *aMessage) { int final = 0; // This UTF-8 friendly. PS G_MAX_STRING_LENGTH = 120 BString message = aMessage; int32 length = message.CountChars(); for (int i = 0, c = 0; i < length; ++i) { c++; if (*(message.CharAt(i)) == '\n') { c = 0; } if (c > final) { final = c; } } return (final > G_MAX_STRING_LENGTH); } 

120- . UTF-8 , Haiku . , , - , . .

x86_gcc2, SDL2. , GCC 2.95 , , :

 rgb_color ConvertColorType(const SDL_MessageBoxColor *aColor) const { // return { aColor->r, aColor->g, aColor->b, 255 }; rgb_color color = { aColor->r, aColor->g, aColor->b, color.alpha = 255 }; return color; } 

, .

SDL2 HaikuPorts, Xash3D Serious Engine - , , . SDL2 , HaikuPorts upstream SDL2. - BE_* HAIKU_* , .

<<

10. Cool Reader


Cool Reader , ( Buggins ), . , - , .


Cool Reader, Haiku.

HaikuPorts Cool Reader, - - , SourceForge , , . HaikuPorts, Cool Reader. , , Haiku. Cool Reader GitHub-:

: https://github.com/EXLMOTODEV/coolreader

, , . __HAIKU__ , - _LINUX , , . , Haiku , _LINUX , . , , . , .

<<

11. KeymapSwitcher


Meta/Opt/Cmd/Win+Space . , . macOS, Windows Linux GNOME 3 . Android . , .

, KeymapSwitcher , Haiku, , - . . , Haiku, . , HaikuPorts . , KeymapSwitcher Haiku, API - .


KeymapSwitcher Haiku .

, KeymapSwitcher, , - Haiku. , , , Opt . , Opt . , HaikuPorts, KeymapSwitcher Haiku.

: https://github.com/HaikuArchives/KeymapSwitcher

, .

<<

12.


Haiku API, , , . Haiku , .


, Haiku.

, 3D- , , Haiku , . , 3D- GTK+3 , HaikuPorts QtWebEngine . GTK+3 Firefox Chromium, QtWebEngine Blink , Qt, Otter Browser Falkon .

, , , Lubuntu Windows XP. , . , - , , .

Haiku. . , . stackoverflow.com google.com , .

1. Haiku .
2. Haiku .
3. Haiku .
4. Haiku .
5. Haiku .
6. Haiku .
7. Icon-O-Matic .
8. HVIF .
9. Interface Kit .
10. Locale Kit .
11. , Haiku .
12. Layout API .
13. , Haiku Layout API .
14. GitHub- Haiku .
15. GitHub- HaikuPorts .
16. HPKG- Haiku Depot Web .
17. «Haiku: -» INSTEAD, .
18. «Haiku: » INSTEAD, .
19. «Learning to Program with Haiku» DarkWyrm .
20. «Programming With Haiku» DarkWyrm .
21. « Haiku?» Linux.org.ru, .
22. Telegram IM, Haiku .

habr ! , , 2019 !

<<

Source: https://habr.com/ru/post/434690/


All Articles