Thursday, 5 December 2024

Bricking Brick with SDL3

Decided to switch Brick Atelier to SDL3 from SDL2. One of the reasons was that SDL3 now has a native file dialog function that removes the need to include windows.h and use a weird hack to call the windows file dialog. SDL3 has changed quite a lot, both function and define names have changed. In Brick Atelier it was possibly harder to migrate, because it's using several event loops etc. But I got there in the end and the file dialog is working, too. It does require an event waiting loop and some funny programming, because it is a callback routine.

However the worst change in my mind was moving from int-based rectangles to SDL_FRect and also mouse coordinates are now float. I guess there is a technical reason for this because GPUs are using float coordinates presumably, but it has been a total chaos in int to float conversions. I am going to fix them all, because I don't like to leave that kind of type conversions, but it takes some time.

I can now compile Brick Atelier in linux I hope, because it no longer requires windows.h. I have not yet tried it, but it should work. Other than that I try to code some difficult features like moving the brushes in the brush pad and also rotation. Some of these features are surprisingly hard to implement, it's no wonder why there are so few drawing programs.

Christmas is getting close. I don't like it, but for family reasons I have to get presents and all that annoying stuff. Christmas is a resource hog, so much crap is produced. I try to figure out presents that are practical and have some kind of use. What I wish is world peace for Christmas.

Tuesday, 19 November 2024

Switching to SDL3 in midlife crisis

Started a new game project where I'm going to use SDL3 to learn it at the same time. This time the game is not going to be a roguelike, but something much simpler. It seems that SDL3 is more like SDL2 compared to switch from SDL1 to SDL2, but some things have changed. If I saw correctly SDL3 has a file dialog which is great news for Brick Atelier.

I think I have a midlife crisis, after all I'm 50. It's like depression with anabolic steroids, because no matter how much you would like to think things are going to get better, some things can't, it's game over. I did have depression when I was younger, although it was never diagnosed. The way I kind of got rid of it was funny, but it's a story for another day. I guess becoming depressed is a personality trait, but in my case I never went too far with the depression, even though I had all the reasons to do that.

To add insult to injury I got my first reading glasses this summer, or was it already in spring I don't remember. My eyesight is not that bad, I can still read text from monitor without glasses, it just looks like there is a outer glow effect in the fonts. But it sucks to have glasses when you always had a great eyesight. Yes, it could be worse, it always could.

The situation with Teemu is fine I guess, it's going to be the first one to be released at some time. As always the role-playing system mostly needs some work, at the moment it's really difficult to kill monsters, because hits don't remove enough hit points. There are lots of ways to fix that, but it's more difficult than you would think.

Wednesday, 17 January 2024

Double trouble

Teemu 1.3 is in testing phase mainly, not much to change in gameplay, although there are some things still unfinished. I wrote a python script which successfully compiles Teemu in both Linux and OSX, although in OSX I had to compile and setup SDL2 from the source code which was tedious, because the wiki doesn't really tell the proper setup information, which I found from a random youtube video as always.

After testing Teemu in OSX and Linux I learned after 15 years of using SDL2 that it has a double buffer drawing. For whatever reason my Windows 10 PC which is my main development computer the second buffer always had the same data as the first, so I never noticed it. This means that all my carefully crafter drawing routines has to go and replaced with routines that make sure the entire area of the screen is always redrawn every time.

Luckily Teemu has extremely simple graphics routines so there isn't that much to rewrite, but some things need more graphical approach since it will be slower to use text output to draw background stuff.

I know some may be wondering how the source code compiled in different platforms. It was quite hilarious, because there were no errors, only couple of warnings. Linux gcc found one extra warning (I used -Wall) and OSX found two other warnings. Not bad.