UCyborg / BerserkerQuake2

Berserker@Quake2 game engine, ported to SDL2 library.
GNU General Public License v2.0
20 stars 9 forks source link

Req: 64bit support #1

Open r2rX opened 7 years ago

r2rX commented 7 years ago

Hey UCyborg,

Just noticed you added commits a couple of months ago. Nice work!

Perhaps it might be a good idea to look into a 64bit version (for compiling & run-time). The process of compiling it in Ubuntu x64 w/ 32bit libs is proving to be a pain. :)

Aside from that, great work dude!

UCyborg commented 7 years ago

It would indeed be nice to have a 64-bit build. It seems the current code is riddled with bugs that show up when compiling in 64-bit mode and would be quite a PITA to fix.

Most of the previous commits were really minor things and it seems there is some catch when it comes to implementing functionality for changing resolution without the need to reload everything. Even just toggling between fullscreen and windowed mode makes the whole thing hang for some reason under certain circumstances.

So at this point, I'd rather just leave things as they are before I break anything further. Maybe I can help with getting 32-bit build working though. Probably the easiest solution for everyone would be if I just provide the precompiled binaries in the Releases section on the project's page.

In the meantime, I haven't tried Ubuntu 16.10 yet, but on 16.04, starting from fresh installation, the following commands yielded success:

sudo dpkg --add-architecture i386 sudo apt-get update sudo apt-get install gcc-multilib git libjpeg8-dev:i386 libpng12-dev:i386 libvorbis-dev:i386 libsdl2-dev:i386 zlib1g-dev:i386 git clone https://github.com/UCyborg/BerserkerQuake2 cd BerserkerQuake2/ make

I'll update the Readme a bit in the following days, remove that broken code I mentioned earlier then put up precompiled binaries so users don't have to compile them themselves. It's probably the best we can get until some expert comes around and makes some improvements.

r2rX commented 7 years ago

Understood. :)

I'll test the compilation process on Ubuntu 16.04 as 16.10 doesn't have libpng12-dev:i386 in the repo. :( (Might just end up having an Ubuntu 16.04 32bit VM just in case).

Manually installing libpng12-dev:i386 gets past the compilation error related to it but then I get the following error:

/usr/bin/ld: cannot find -lGL
/usr/bin/ld: cannot find -lSDL2
collect2: error: ld returned 1 exit status
Makefile:26: recipe for target 'berserker' failed
make: *** [berserker] Error 1

Good times. :p

Providing pre-compiled binaries is a great idea, for those having issues compiling it themselves.

Thanks for all the care and effort, UCyborg. ;)

UCyborg commented 7 years ago

So I've been messing around with the engine lately, fixed some bugs, hopefully didn't break anything critical. It surely behaves nicer in some aspects than before.

Regarding precompiled binaries, it's kinda tricky because if you compile on computer with libpng12, it will link against libpng12 and won't work with libpng16 and vice-versa. And as you can see, package manager will pull a lot of additional packages if you just try installing all dependencies Berserker needs, so maybe precompiled binaries aren't the best idea, at least on Linux. The libpng problem is the thing of past now, should compile with any version that matters now.

That error you've posted, I've had it on Ubuntu 15.10, didn't figure out what actually caused it. It means linker can't find the actual libraries to link against, though in my case the libraries were there, just symbolic links to them that linker is looking for were absent. I'm also confused by some people' instruction to use sudo dpkg --add-architecture i386 on x64 Ubuntu, since you can already install x86 packages on it without it. Perhaps we've both encountered some strange problem on Ubuntu or we're just missing something obvious (maybe some package didn't install correctly for some reason?) Theoretically, having both 32-bit and 64-bit libs on the same machine shouldn't present any problem.

I can build Berserker without issue on a virtual machine running Ubuntu 16.10, just need gcc-multilib and all the 32-libs, along with with their dev packages. Installing dev packages should pull actual libraries in anyway.

r2rX commented 7 years ago

So I've been messing around with the engine lately, fixed some bugs, hopefully didn't break anything critical. It surely behaves nicer in some aspects than before.

Sweet! Is there anything that I should look out for or test?

Regarding precompiled binaries, it's kinda tricky because if you compile on computer with libpng12, it will link against libpng12 and won't work with libpng16 and vice-versa. And as you can see, package manager will pull a lot of additional packages if you just try installing all dependencies Berserker needs, so maybe precompiled binaries aren't the best idea, at least on Linux. The libpng problem is the thing of past now, should compile with any version that matters now.

Good to know that libpng is no longer an issue.

That error you've posted, I've had it on Ubuntu 15.10, didn't figure out what actually caused it. It means linker can't find the actual libraries to link against, though in my case the libraries were there, just symbolic links to them that linker is looking for were absent. I'm also confused by some people' instruction to use sudo dpkg --add-architecture i386 on x64 Ubuntu, since you can already install x86 packages on it without it. Perhaps we've both encountered some strange problem on Ubuntu or we're just missing something obvious (maybe some package didn't install correctly for some reason?) Theoretically, having both 32-bit and 64-bit libs on the same machine shouldn't present any problem.

Dealing with symlinks is a bit of a headache. Unless a user sorts that out on their respective machine, at least there's the option to use a VM (or until Berserk reaches 64bit support).

I can build Berserker without issue on a virtual machine running Ubuntu 16.10, just need gcc-multilib and all the 32-libs, along with with their dev packages. Installing dev packages should pull actual libraries in anyway.

I went that route as well. After installing Ubuntu 16.04 with all the necessary libs, compilation is 100% successful.

UCyborg commented 7 years ago

Can't think of anything specific to test right now. I see that this engine has zero support for regular Quake 2 mods, including official mission packs, I'm looking to see if I can do something about it. Looks complicated, so I don't know how far I'll be able to go, I got it to load Ground Zero, intro cinematic plays, but then it crashes.

r2rX commented 7 years ago

No prob, dude. I'll track the progress and, whether it's 64bit support or mod support, i'll be ready to test.

UCyborg commented 7 years ago

Should compile and run in 64-bit mode now. You must delete the cache from baseq2 folder before running new executables for the first time. I would also advise you to delete the line containing fs_cached in baseq2/q2b_config.cfg when running it for the first time so it knows it should regenerate the cache, otherwise, first map loading will take longer than usual.

Also, savegames are not compatible between 32-bit and 64-bit versions. This is common flaw of all Quake II ports as it supposedly can't be solved without major rewrite of the game code.

BTW, I noticed on Ubuntu trouble arises if you try to install dev files for both architectures. At least for certain libraries. When I tried installing dev files for 64-bit libraries, apt complained that I have requested impossible situation and that it won't install SDL2 stuff. When I got rid of 32-bit dev files, everything installed properly. This explains why I had trouble getting the thing to compile in the past without relying on hacks (manual symlinks, since I only had 64-bit dev packages installed).

r2rX commented 7 years ago

Thanks for the update and the info.

It compiled with no issues. I can run it via a terminal just fine but it won't execute via a double-click through Nautilus (with allowing executable file as program enabled):


Could not display "berserkerq2".
There is no application installed for "shared library" files

Additionally, when the executable is run via a terminal, the game runs with no apparent issues so far but the terminal registers an error:

libpng warning: iCCP: known incorrect sRGB profile (several lines, depending on how many maps you load)

But great work, dude. :)

UCyborg commented 7 years ago

The first issue, this is some strange bug in recent gcc compiler versions. They mark an ordinary executable as shared object for some reason. Nautilus inspects the file contents to decide what to do when you double click on it.

Running it through terminal is one option, you can also create a shell script in which you put:

#!/bin/bash ./berserkerq2

Scripts are generally useful because you can pass certain parameters to the executable among other things, eg. you can do ./berserkerq2 +menu_main and the game will open directly in main menu.

You can also try compiling the game with clang compiler, it marks the executables properly:

sudo apt-get install clang

Then navigate to where you have the source code and do:

make clean make CC=clang

The libpng warning has something to do with included .png images/textures not being strictly standard compliant. Nothing to worry about, but maybe they could be fixed by running optipng on them. Will do that some other time and re-upload the archive with the data.

Other than that, let's keep this issue open just in case some hidden bug is discovered sometime in the future.

r2rX commented 7 years ago

You can also try compiling the game with clang compiler, it marks the executables properly

Just wanted to confirm that compiling with clang allows the binary to execute via double-click just fine now.

The libpng warning has something to do with included .png images/textures not being strictly standard compliant. Nothing to worry about, but maybe they could be fixed by running optipng on them. Will do that some other time and re-upload the archive with the data.

Good to know. I'll test it out once you've reuploaded the data archive with the fixes.

Other than that, let's keep this issue open just in case some hidden bug is discovered sometime in the future.

I agree. We'll keep it open, in case anything else pops up.

Nice work, dude. :)

netpipe commented 2 years ago

not sure what i'm doing wrong but i get failed to initialize video every time. built with clang and also built with -m32 libs and just regular 64 bit.