PDA

View Full Version : how to change coordinates



smartmobili
11-03-2009, 01:38 PM
Hi,

I am developping a 2D API based on OpenVG and I am using AmanithVG implementation for now.
However I would like to use a coordinate system where 0,0 corresponds to top left (like GDI or
quartz) instead of bottom left, so how can I did this ?

I suppose I need something like :

vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
vgLoadMatrix( ?, ?, ?, ?, ?, ?, ?, ?, ?);
vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
vgLoadMatrix( ?, ?, ?, ?, ?, ?, ?, ?, ?);
...

Let's say my window is width x height what should I pass to vgLoadMatrix ?

Thanks

jpilon
11-03-2009, 04:07 PM
It's been a while, but you can probably scale based on the size of your window, rotate by 270 or -90 then translate by -height.

Ivo Moravec
11-03-2009, 04:12 PM
No, just vgScale(1,-1), and vgTranslate(0, height);
not sure which order though off the top of my head.

jpilon
11-03-2009, 04:32 PM
Good point Ivo! Couldn't remember the easiest way to inverse the y. The negative scale is ringing some bells.