Ticket #698 (closed defect: wontfix)
Problem with rendering text to a procedual texture
|Reported by:||eventhorizon5||Owned by:||thebolt|
Description (last modified by sunshine) (diff)
There's a bug involving drawing text to a procedural texture and has to do with the code giving the text a negative vertical position, due to it getting the smaller viewport (texture) size instead of the canvas size, and subtracting the given Y value from that (which includes the clipping offset).
Here's some basic code I'm using to render to a texture:
int vleft, vtop, vwidth, vheight; g2d->GetViewport(vleft, vtop, vwidth, vheight); g2d->Write(font, vleft, vtop, g2d->FindRGB(255, 255, 255), -1, text);
GetViewport() needs to be used to get the clipping offset used for the texture; otherwise the Write() call fails due to the position being outside the clipping region. For a texture that has a 128x128 size, and if vtop is let's say 320, the Write() function will try to use a Y offset of 128 minus about 320.
The issue generally involves both lines 654 and 655 of libs/csplugincommon/opengl/glfontcache.cpp - I made a patch that fixes line 655, but I'm unsure if it's the proper way to do it (seems to work fine though).