memononen / nanovg

Antialiased 2D vector drawing library on top of OpenGL for UI and visualizations.
zlib License
5.06k stars 767 forks source link

Perspective scale coordinate plane #583

Closed shrublet closed 12 months ago

shrublet commented 4 years ago

Sorry for noob question, I'm really inexperienced. Was hoping there was a way to scale the coordinate plane so I could give the appearance of perspective (am trying to replicate these icons in the background and the way the bg looks tilted). I'm currently using a tileable image with repeat tag. Thanks in advanced!

ghost commented 3 years ago

Hmm, I'm replying to this a little bit late, but I try to do something like this recently and in case someone is reading this from the future, I can reasonably say that this is impossible to do with nanovg. From what I understand from the problem, you want to stretch a texture so that it appears in 3 dimension. To achieve this using a matrix transformation, you'll need a full 3x3 matrix.

Nanovg will only let you use 2x3 (ie: affine matrix), even though in the source there is room to handle full 3x3 matrix (ie: what is sent to the vertex shader).

That being said, I realized that to achieve what I wanted to do, I also needed the depth buffer. At this point, it is better to bypass nanovg and use OpenGL directly.