Comments (3)
Hello!
Faced same issue while trying to port my cub3D from MacOS to Linux/Windows.
I dived into X11 manuals and found the way to add alpha channel to MLX - by using XRender extension which can blend images.
You can find modified MinilibX Linux on my project page:
https://github.com/Rush-iam/nGragasstein3D-cub3D
May be you need to install required libraries before:
apt install libxrender-dev
To use: function mlx_new_image_alpha()
with same arguments as mlx_new_image()
- it will create image, which will be blended on top of other images. From my tests there is almost no performance penalty.
I checked work only on WSL2 without SHM, so don't know how it behaves on true Linux environment - will be glad if you'll post any bugs.
Alpha channel in X11 works not the same way as in stock MLX.
255 is fully opaque and 0 is full transparent here (inverted to MLX).
So you need to draw accordingly - set upper bits of color to 0xFF if you want them to be opaque.
(if anybody knows how to invert it on X11 side - I will be grateful)
There is also another issue - if you want to play with semi-transparency - you should premultiply your color relative to alpha value before outputting - X11Render don't do that.
Here is screenshot from my cub3D with semi-transparent weapon glow - just made it to work after few days and now happy))
p.s. I also modified MLX by implementing some kind of double buffer - it now writes image to main buffer only once a frame.
In stock MLX it writes every time you call put_image_to_windows, so it can result in flickering images if there are lot of put_image's per frame.
from minilibx-linux.
In the test program, the blowfish sprite is drawn with its transparent pixels as if they were opaque.
from minilibx-linux.
Same problem here. Hope it's fixed someday.
from minilibx-linux.
Related Issues (20)
- man/man1 directory identicall to man/man3 HOT 1
- mlx_destroy_display() HOT 1
- Last version of libmlx.a causes "warning: size of symbol `mlx_int_param_event' changed" issue with program made with the previous version. HOT 2
- Pull #22 Introduced issue with exit on red cross HOT 1
- Segfault in mlx_loop HOT 1
- mlx_put_image_to_window segfault HOT 3
- mlx_new_window segfault, mlx_init returns 0 HOT 3
- ubuntu 22.04
- mlx_mouse_hide causes memory leaks HOT 2
- mlx_do_key_autorepeatoff persists on machine HOT 1
- mlx_mouse_move doesn't move cursor
- get_screen_size gets both of the screen's size (Windows 11)
- SIG \
- OLDPWDが更新されていない! HOT 1
- cd
- having an issue to mlx_init, it returns 0 HOT 1
- Invalid read on DestroyNotify
- Can't compile HOT 1
- Here is a fix that makes makes movement a bit better
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from minilibx-linux.