大佬教程收集整理的这篇文章主要介绍了c – 如何使用QOpenGLWidget渲染文本,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
有没有简单的方式来渲染文本使用QOpenGLWidget?我不想从头开始用OpenGL构建整个文本渲染
void MapCanvas::renderText(double x,double y,double z,const QString &str,const QFont & font = QFont()) { // Identify x and y LOCATIOns to render text within widget int height = this->height(); GLdouble textposx = 0,textposy = 0,textPosZ = 0; project(x,y,0f,&textposx,&textposy,&textPosz); textposy = height - textposy; // y is inverted // Retrieve last OpenGL color to use as a font color GLdouble glColor[4]; glGetDoublev(GL_CURRENT_COLOR,glColor); QColor fontColor = QColor(glColor[0],glColor[1],glColor[2],glColor[3]); // Render text QPainter painter(this); painter.setPen(fontColor); painter.setFont(font); painter.drawText(textposx,textposy,text); painter.end(); }
以上是大佬教程为你收集整理的c – 如何使用QOpenGLWidget渲染文本全部内容,希望文章能够帮你解决c – 如何使用QOpenGLWidget渲染文本所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。