Perspective View

I am trying to setup a perspective view having various paths. I am trying to draw/copy my paths(vgPaths) onto an Image(vgImage) and then with some matrix manipulations , get that perspective view angle.
Is this the best way to do it or rather is it even possible?

Yeah, that’s the best way to do it using OpenVG alone.
The transformation matrix when using vgDrawPath() is always affine, so to get perspective you will have to render to a vgImage. The transformation matrix used for vgDrawImage() does not need to be affine. To get the correct transformation matrix, it’s easiest if you use the vguWarpQuadtoQuad() function.
Since everything is still happening in 2D, there is obviously no Z-coordinate. You will have to manage the 3D->2D coordinate transformation yourself.
You’ll also probably want to make sure the OpenVG implementation supports output to surfaces with alpha so that you can more easily control which pixels are written (and which are not) during the vgDrawImage() call.

Alternatively, if your system supports both OpenVG and OpenGL ES, then you can use the output of OpenVG as a texture for OpenGL ES.

Thanks!

  1. I got the perspective view I wanted but using matrix manipulations. Is vguWarpQuadtoQuad() more efficient than what I did?
  2. Is antialiasing going to be a factor? I understand what/how VG_RENDERING_QUALITY is affecting my output, but not how VG_IMAGE_QUALITY_BETTER/VG_IMAGE_QUALITY_NONANTIALIASED are different?
    Thanks again!
  1. the vgu functions are basically a shortcut to help create the projection matrices for you. If you made the matrices yourself [correctly], then you don’t have to worry about it.

  2. As for anti-aliasing, the paths rendered into the vgImage will be anti-aliased (e.g. have gray pixels between white and black areas) depending on whether anti-aliasing was turned on/off during rendering (vgSet() with VG_RENDERING_QUALITY_* [from memory]). The resulting image will then be drawn to the final screen. If the image is drawn with VG_IMAGE_QUALITY_NONANTIALIASED, it will be sampled with nearest neighbor sampling (the nearest texel to the pixel being rendered is used). If VG_IMAGE_QUALITY_BETTER or VG_IMAGE_QUALITY_FASTER is used instead, then you are guaranteed at least bilinear interpolation (a blend of the 4 nearest texels). [the edge of the image will once again be anti-aliased on/off depending on the setting of the VG_RENDERING_QUALITY setting].

For best quality, you almost certainly want VG_IMAGE_QUALITY_BETTER for the image.
As for VG_RENDERING_QUALITY, you may want to experiment. Chances are you’ll want anti-aliasing on for the vgDrawImage() call. For the vgDrawPath() call though, I’m not certain whether it’s best to have it on or off. If off, fine details may be lost and you may see jaggies. If on, you may get the edges of your paths to get some weird colors introduced (for example - if you render a blue path onto a black background and then draw the resulting image to a white background. The result will probably have the blue path with a faint black border). Try it out and see what works best for you.