Giter Site home page Giter Site logo

Comments (3)

Rush-iam avatar Rush-iam commented on September 27, 2024 11

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))
image

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.

paulo-santana avatar paulo-santana commented on September 27, 2024 3

In the test program, the blowfish sprite is drawn with its transparent pixels as if they were opaque.

mlx

from minilibx-linux.

Rakjlou avatar Rakjlou commented on September 27, 2024 1

Same problem here. Hope it's fixed someday.

from minilibx-linux.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.