Loading and Saving Images
Today's goal: Get an image rendering on screen and save the composition to a file!
Updates
- I wired up
main.c
to load script files again! - Felipe found a better way to store a handle to the
FluxWindow
withGLFWwindow
Let's finally start handling images
We'll use the libspng
library or lodepng
to decode a PNG file into an OpenGL texture and then render it to the screen.
Once we get that working, we'll try to render the screen to a PNG file, possibly with optimizations. This will be an important step toward creating thumbnails with flux-compose
!
Tasks
DONE Add PNG loading
DONE Render an image texture to the screen
TODO See if we can render the OpenGL context back to a PNG
TODO Automate the process of rendering an image file from the command line
Notes
The code for this stream can be found here: https://github.com/FluxHarmonic/flux-compose/commit/29db69e81baf6ea81b8df61a6c15a1f84363f1ef
- libspng: https://github.com/randy408/libspng
- example.c: https://github.com/randy408/libspng/blob/v0.7.1/examples/example.c
- Load a PNG to texture: https://raw.githubusercontent.com/lvandeve/lodepng/master/examples/example_opengl.cpp
- Save an PNG: https://raw.githubusercontent.com/lvandeve/lodepng/master/examples/example_encode.c
- Optimizing PNG size: https://raw.githubusercontent.com/lvandeve/lodepng/master/examples/example_optimize_png.cpp
- Power of 2 textures have better performance