Immediate-Mode-UI / Immediate-Mode-UI/Nuklear

OpenGL - Upside down textures using nk_button_image

Open
#489 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
11.4k
Forks
686
Avg merge
4d 1h
Merged PRs (30d)
3

Description

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!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing nk_button_image through the GLFW backend and compare its texture-coordinate handling with stbi_set_flip_vertically_on_load(1). Review the reported shader and orthographic-matrix changes, then establish a reproducible texture-orientation case; done means documenting or implementing a straightforward way to keep engine textures upright while rendering button images correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.