-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace devIL with SDL2_image #344
Conversation
I also began working on this, the day before yesterday. But you are faster. I'm heavily in favour of this change. It makes #120 obsolete. |
does not crash
OpenGL's origin is the lower left corner, while the rest of the world places it in the upper left. Need to flip the captured framebuffer vertically for a savegame screenshot.
Didn't check the editor code though..
drop devIL, add SDL2-image
Ok, now it's in a state where it works just fine, the "Image*" structure is gone and has been replaced with an "SDL_Surface*" everywhere. |
not build-tested though.
Well, it is still an external library. Just one moved into the tree. So not linked at runtime, but still by a third party. And most likely once it's added nobody would keep track of problems in the original one. I can see a certain appeal for such a solution regarding the software renderer, but is SDL2 not pretty much a hard dependency anyways now for input handling and sound? |
SDL image is not core SDL2, but an additional (they call it "satellite") library. But unlike devIL, it's available as default on most distros, including the steamdeck. In this state building a flatpak should be no different than building a flatpak for e.g. xonotic. |
This seems fine, I mainly used DeviL because I had used it successfully in the past for a variety of image formats. I will have to patch this in to make sure it compiles and works on Windows. |
normally, I wouldn't care, but I'd like to get TFE working on my steamdeck and devIL is kind of niche. Out of curiosity: did you remove the screenshot functionality, or was it never fully present? I must admit I never tried to make one until now :) |
Screenshot functionality still works on Windows - screenshots get saved to /Documents/TheForceEngine/Screenshots. As for the lib, I took care of that. So you don't need to worry about Windows. |
Ok stupid question which keypress ? Eh nevermind, I just saw it... |
PrintScreen. Search for TFE_RenderBackend::queueScreenshot(screenshotPath); |
Anyway, once you get Linux working I will merge the PR and then fix up Windows (remove Windows DeviL libs/DLLs, add sdl_image lib/dll, etc.). |
too soon there's a compile error in saveSystem now, please apply this on top --- a/TheForceEngine/TFE_Game/saveSystem.cpp
+++ b/TheForceEngine/TFE_Game/saveSystem.cpp
@@ -50,14 +50,15 @@ namespace TFE_SaveSystem
TFE_RenderBackend::captureScreenToMemory(s_imageBuffer[0]);
// Save to memory.
u8* png = (u8*)malloc(SAVE_IMAGE_WIDTH * SAVE_IMAGE_HEIGHT * 4);
+ u32 pngSize;
if (png)
{
- u32 pngSize = (u32)TFE_Image::writeImageToMemory(png, displayInfo.width, displayInfo.height,
+ pngSize = (u32)TFE_Image::writeImageToMemory(png, displayInfo.width, displayInfo.height,
SAVE_IMAGE_WIDTH, SAVE_IMAGE_HEIGHT,
s_imageBuffer[0]);
} else {
pngSize = 0;
- png = s_imageBuffer[0];
+ png = (u8 *)s_imageBuffer[0];
} |
Got it. |
I was expecting to fix Windows errors anyway. |
Got it working on Windows, will push the results shortly. |
Thanks @mlauss2 - the change now works on Windows and is submitted. The only issue I ran into is that screenshots are upside down, though save game images are fine. I added some code to flip them on save, but will probably want to clean it up in the future. I have tested from a fresh clone/compile on Windows and everything works fine now. |
What about the screengrabs in new saves? |
That actually works fine as-is. |
@mlauss2 Anyway, if you can test screenshots on Linux and let me know if they are upside down or not. If they are, I will just remove the #ifdef _WIN32 block around the code. |
Will do. |
With my local branch, the screenshots are fine. |
Looks like this issue is OS independent, please enable the screenshot flip unconditionally. |
Ohhh... it's due to the different paths: |
@mlauss2 Ah ok - thanks for checking. I will make the flip unconditional for now and then dig into it deeper at a later date. It sounds like I should just modify the PBO/capture code instead. |
@mlauss2 Linux fix pushed, added a TODO to fix it properly later. |
@luciusDXL I think you can close PR #117 and #120 as supersesed. |
made an issue: #351 |
install libsdl2-image from your distros package manager; I think your build didn't place the headers in the correct spot. |
First draft of replacing use of devIL with SDL-image.
Again, main motivation is that SDL-image is much more common, while devIL is more niche (TFE is the only user I know of so far).
This first draft just tries to replace devIL. However, I'd like to replace the TFE_Image::Image struct with SDL_Surface: SDL2 uses it extensively, and it has all the info in "struct Image" plus more.
@luciusDXL: what do you think?
This snapshot already works, only minor issue so far is that the image in a savegame made after this patch is upside down.