
Drop shadows in SFML
Drop shadows are created using a Gaussian blur drawn underneath the original element. You can do this using either a fixed texture or a post-processing fragment shader.
Drop shadows are created using a Gaussian blur drawn underneath the original element. You can do this using either a fixed texture or a post-processing fragment shader.
Data binding greatly reduces the amount of code you need to connect user-interfaces with ViewModels. It keeps Activity and Fragment code small, and makes it easier to manage lifecycles.
<EditText
android:id="@+id/username"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="@={viewModel.username}"/>
I discovered that there was no attribute to bind the elements in a RecyclerView, due to the fact that a RecyclerView needs an adapter to be able to create element views. It would also be nice to automatically use data binding to create the viewholders. There are a number of guides to do both of these halves, but I now present the code to do the whole.
Read more of "Android: Complete, generic data-binding RecyclerView adapter"
Since switching to GitLab, a few people have asked me why. There are several draws towards GitLab, and several pushes from GitHub.
SFML is an excellent library that can be used to create 2D games and similar applications in C++. It’s an abstraction over OpenGL and various system APIs, presenting a consistent and easy-to-use interface.
Providing a Graphical User Interface (GUI / UI) API is out of scope for SFML. GUIs are complicated, and there’s no single good way to implement them. The S in SFML stands for Simple but GUI code rarely is.
There are many different options to choose from when making GUIs. This article is an in-depth comparison of the options for making GUIs in SFML, discussing their pros and cons.
Read more of "A Comparison of SFML GUI Libraries: TGUI vs SFGUI vs ImGui"
Ruben’s Virtual World Project is a game I’ve been working on for almost 4 years now. Recently I rewrote the rendering code to support voxel lighting and multiple z-level - heights of the map.
Read more of "Rendering a topdown world with layers and z-levels using SFML"
YouTube Music is a great way to listen for music for free, and with no adverts if you use an adblocker. There is one annoying problem however: after listening for a while, Youtube will keep pausing the music to show a dialog which says “Are you still listening?”. This article will show how to automatically confirm the dialog.
Read more of "Getting rid of YouTube Music's "Are you still listening?" dialog"
Google’s C++ testing library has a nice syntax for registering tests, without needing to remember to add the tests to some central index. This article will show how to use macros to allow the creation of tests using only the following code:
Test(IntegerComparisonTest) {
int a = 3;
assert(a == 3);
}
Read more of "C++: Self-registering functions using macros for test libraries"
Recently I had to reinstall Windows to debug a hardware issue. I decided to try to make the most of this by trying to build my game on Windows.
Read more of "Porting C++ programs from Linux to Windows using vcpkg, CMake, and Visual Studio"
Progress Renderer (Steam | GitHub) is a brilliant mod that takes a screenshot once a day, and dumps it into a folder.
The following bash script can be used to generate an mp4 timelapse of the screenshots. Simply specify a region to cut out of the screenshots, and some other parameters, and run the script in the working directory.
Read more of "RimWorld: Create timelapse from Progress Renderer on Linux"
I wrote a raytracer and a rasteriser as part of my university course. The raytracer supported features such as indirect lighting, reflection, refraction, and a photon mapper capable of simulating the final positions of 60,000,000 photons in a few minutes (and quite a few GBs of RAM).
I wrote a Bash script to sort git commits into buckets, to be used as the first step of making a change log. It supports rewording commit messages, can be stopped and resumed, and supports automatic filtering based on keywords.
After cross-compiling your project for Windows, you find that it crashes due to missing DLLs. I will show how to identify any required DLLs using objdump, and copy them to your build directory.
Read more of "Finding and copying DLLs from MinGW-W64 directories to bin directory"
During the second year of university, I created a kernel for the ARMv7 instruction set. I went above and beyond what was required on this project, achieving a clean design and features such as a blocked process queue, piping, kill, and a simple filesystem. This was my favourite coursework so far. I found it very interesting to learn about and implement the things that we take for granted as programmers.
I tried to stick to POSIX as much as possible, and stuck to the Linux method of having everything as either a file or process. Because pipes and standard in/out were both “files”, I was able to implement both popen and piping of the output of a process to another process.
Shara and I exhibited on behalf of Minetest at Freenode #Live. Our stall had a computer where visitors could play Minetest. We talked about it and handed out leaflets.
If you’d like to support Minetest, then please get involved and consider donating:
Whilst Maya claims to have Linux support, it only officially supports RedHat and CentOS Linux. It is, however, still possible to install it on Debian and Ubuntu based systems with some leg work.
For the last two years, I have been working on a very ambitious game. The game is a top-down sandbox with multiplayer support. I’m aiming towards a city-based game, where players can wander around a procedurally generated city. One of the main reasons I started creating this game is to learn about multiplayer networking at a low level - client-side prediction, server-side reconcilliation, cheat preventation, and reducing the visual effect of latency.
Read more of "RVWP: Multiplayer Topdown Sandbox Game in C++"
I had an issue where CMake was failing on a compiler test with the following error:
error: unrecognized option '-rdynamic'
The problem was that CMake caches settings such as compiler flags in CMakeCache.txt, so you need to clear the cache when changing the platform. Do this by deleting CMakeFiles and CMakeCache.txt
Read more of "Mingw-w64 and CMake: unrecognised option -rdynamic on Ubuntu"
I created a very short C++ snippet to accumulate a series of Mat
s into
a single Mat
strip. It works like acc = acc + m
- a new mat is added to the
accumulator each time, then stored in the accumulator again.
Usecase: shells dropping in sync with firing, fake bullets, etc
You must use a particle emitter to create particles, however this doesn’t mean it’s impossible to create single particles on command. You can create a particle emitter which simply adds particles from a queue to the system
Read more of "How to emit a single particle using SFML's Thor Particle System"
Simply get the SFGUI window size using GetAllocation, the sfml window size using getSize, then do this arithmetic:
auto window = sfg::Window::Create();
auto win_rect = window->GetAllocation();
sf::Vector2f size(win_rect.width, win_rect.height);
window->SetPosition(((sf::Vector2f)rwindow->getSize() - size) / 2.0f);