Writing text in OpenGL is a 2d Raster Operation. OpenGL does not support that if the bottom left corner of the drawing rectangle is outside of the drawing area. If that is what you are seeing, It may be possible to write some custom clipping for text that intersects the bottom left corner. --
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/fltkgeneral/5c17309d-e581-4c53-910a-ba929964741en%40googlegroups.com.
You can usually improve things if you do all of this:
bool GL2TextShape::setRasterPos(double x, double y, size_t
pos)
{
GLboolean result = GL_TRUE;
glRasterPos2d(x, y);
glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID,
&result);
if (result == GL_FALSE)
{
double width = gl_width(txt.c_str(), pos) / viewZoom;
double height = (gl_height() / viewZoom);
double xMove, yMove, bxMove, byMove;
xMove = width;
yMove = height;
bxMove = -xMove * pixels_per_unit * viewZoom;
byMove = -yMove * pixels_per_unit * viewZoom;
glRasterPos2d(x + xMove, y + yMove);
result = GL_TRUE;
glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID,
&result);
if (result == GL_FALSE)
{
// Probably bottom right corner, don't offset x.
bxMove = 0;
glRasterPos2d(x, y + yMove);
glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID,
&result);
}
glBitmap(0, 0, 0, 0, bxMove, byMove, NULL);
}
return (bool)result;
}
void GL2TextShape::draw()
{
double height = gl_height() / viewZoom;
// Copy text to process it line by line
txt = text;
GLboolean result;
std::size_t pos = txt.find('\n');
double x = pts[0].x / pixels_per_unit;
double y = pts[0].y / pixels_per_unit;
for (; pos != std::string::npos; y -= height, pos =
txt.find('\n'))
{
result = setRasterPos(x, y, pos);
if (result)
gl_draw(txt.c_str(), pos);
if (txt.size() > pos)
txt = txt.substr(pos + 1, txt.size());
}
if (!txt.empty())
{
result = setRasterPos(x, y, txt.size());
if (result)
gl_draw(txt.c_str());
}
}
-- Gonzalo Garramuño ggar...@gmail.com