Nuklear
Nuklear copied to clipboard
OpenGL - Upside down textures using nk_button_image
Hello everyone,
I have a small issue regarding textures rendering upside down using nk_button_image
.
I am building a small game engine in C which makes use of GLFW.
I'm using stb_image
to load textures, which I then flip vertically using stbi_set_flip_vertically_on_load(1)
.
This, however, causes nk_button_image
to render its textures upside down (whereas the textures I render myself are upright). However, if I change the above setting to stbi_set_flip_vertically_on_load(0)
, button images render upright, but nothing else on my engine does.
This leads me to believe the GLFW backend Nuklear uses flips images automatically. I have tried modifying the internal shader and orhtographic matrix Nuklear uses to no avail (results in invisible widgets).
Is there an straightforward way of flipping the images on Nuklear without changing the way my engine handles textures?
Thank you in advance!
Use a custom shader for nuklear and just flip the uv.
v_texcoord = vec2(a_texcoord.s, 1.0 - a_texcoord.t);
But if you have to flip images by default you probably are building your vertex buffer incorrectly and the texcoord x and y are swapped.