NanoVG nvgImagePattern draws at wrong position on OSX?

Started by mudlee, October 23, 2019, 18:46:18

Previous topic - Next topic


First time (yes, really) that I'm trying to draw an image with nanovg. It works perfect on simple HD and 4K monitor on Linux, but on OSX (macbook pro with retina screen) the image's position is incorrect.

I'm drawing a simple png with a cursor at the mouse's position. Top-left (0,0) is correct but as soon as I go to let's say bottom-right, the diff between the cursor's real position and the png's position is like quadratic (when the real cursor at the bottom rigth, the png is somewhere 1/4 from the top left). Am I missing something?

float x = image.getPosition().getLeft();
float y = image.getPosition().getTop();

int imageID = nvglCreateImageFromHandle(pointer, image.getTextureId(), width, height, 0);
NVGPaint paint = NVGPaint.create();
nvgImagePattern(pointer, x, y, width, height, 0, imageID, 1f, paint);
nvgRect(pointer, x, y, width, height);
nvgFillPaint(pointer, paint);


OK, after digging more into the code, the problem is somewhere in my code, with the screen resolution.