Rendering text with shadow
Posted: Wed Jun 04, 2014 9:40 am
Hello all,
I'm working to obtain some text with a shadow behind it.
The main idea I had can be resumed in these three simple passages:
1) draw a text, using vgDrawGlyph
2) apply a convolution to blur the image, using vgConvolve or vgSeparateConvolve
3) redraw the same text on top of the blurred text
Apparently this is fine and coloring is not a problem with the use of the color transformation matrix.
I managed to obtain some results and I'm pleased to see that this solution works as intended.
I think the implementation can be improved because:
1) vgDrawGlyph and vgDrawGlyphs can render text only on a EGL surface
2) vgConvolute and vgSeparateConvolute require a VGImage as source and a VGImage as destination
So for each block of text I do these steps:
1) Create two VGImage buffers (let's call them SRC and DEST) and use eglCreatePBufferFromClientBuffer to create two pbuffers from those images
2) Make the SRC pbuffer the current surface with eglMakeCurrent
3) Render the text on the SRC pbuffer, then convolve the SRC VGImage object to obtain the blurred text into DEST VGImage
4) Make the DEST pbuffer the current surface and draw again the text.
5) Finally I will found the shadowed text in DEST VGImage object, that I can blit on my main backbuffer.
6) Destroy the pbuffers and release the VGImage objects.
This process is a bit time consuming, but mostly I'm concerned about stalling the pipeline and I'd like to avoid flushing it each time I draw a shadowed text.
I googled around, but could not find any resource or technique that can be useful in such case. I'm though interested in any suggestion that can be useful and I'd like to understand if it is acceptable to allocate and deallocate buffers during the rendering process, or it should be avoided at all costs.
Thanks!
I'm working to obtain some text with a shadow behind it.
The main idea I had can be resumed in these three simple passages:
1) draw a text, using vgDrawGlyph
2) apply a convolution to blur the image, using vgConvolve or vgSeparateConvolve
3) redraw the same text on top of the blurred text
Apparently this is fine and coloring is not a problem with the use of the color transformation matrix.
I managed to obtain some results and I'm pleased to see that this solution works as intended.
I think the implementation can be improved because:
1) vgDrawGlyph and vgDrawGlyphs can render text only on a EGL surface
2) vgConvolute and vgSeparateConvolute require a VGImage as source and a VGImage as destination
So for each block of text I do these steps:
1) Create two VGImage buffers (let's call them SRC and DEST) and use eglCreatePBufferFromClientBuffer to create two pbuffers from those images
2) Make the SRC pbuffer the current surface with eglMakeCurrent
3) Render the text on the SRC pbuffer, then convolve the SRC VGImage object to obtain the blurred text into DEST VGImage
4) Make the DEST pbuffer the current surface and draw again the text.
5) Finally I will found the shadowed text in DEST VGImage object, that I can blit on my main backbuffer.
6) Destroy the pbuffers and release the VGImage objects.
This process is a bit time consuming, but mostly I'm concerned about stalling the pipeline and I'd like to avoid flushing it each time I draw a shadowed text.
I googled around, but could not find any resource or technique that can be useful in such case. I'm though interested in any suggestion that can be useful and I'd like to understand if it is acceptable to allocate and deallocate buffers during the rendering process, or it should be avoided at all costs.
Thanks!