简体   繁体   English

仅渲染文本FTGL,Op​​enGL的一部分

[英]Rendering only a part of text FTGL, OpenGL

I'm using FTGL library to render text in my C++ project. 我正在使用FTGL库在C ++项目中渲染文本。

I can easily render text by using: 我可以使用以下方法轻松呈现文本:

CFontManager::Instance().renderWrappedText(font, lineLength, position, text);

Unfortunately there is a situation in which this Button which displays text, is partly hidden because of resizing container in which it is situated. 不幸的是,这种显示文本的按钮由于其所位于的容器的大小而被部分隐藏。 I'm able without any problem to draw Button's background to fit the container, but I've got a problem with doing the same with a text. 我可以毫无问题地绘制Button的背景以适合容器,但是在处理文本时却遇到了问题。 Is it possible to somehow draw only text for given width and the rest just ignore? 是否有可能以某种方式仅绘制给定宽度的文本,而其余文本只是忽略?

This is a screen which presents my problem: 这是显示我的问题的屏幕:

仅画一部分文字的问题

As you can see, the Button "Click here" is being drawn properly, but I can't do the same with "Click here" text. 如您所见,“单击此处”按钮已正确绘制,但是“单击此处”文本无法做到这一点。

You may try using glScissor like this: 您可以像这样尝试使用glScissor

glEnable(GL_SCISSOR_TEST);
glScissor(windowPosition.x, windowPosition.y, windowWidth, windowHeight);
// here put your draw method of your window and objects inside it
glDisable(GL_SCISSOR_TEST);

More info : http://www.opengl.org/sdk/docs/man/xhtml/glScissor.xml 更多信息: http : //www.opengl.org/sdk/docs/man/xhtml/glScissor.xml

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM