4391 \note This function is not supported on OpenGL/ES systems. |
4391 \note This function is not supported on OpenGL/ES systems. |
4392 |
4392 |
4393 \note This function temporarily disables depth-testing when the |
4393 \note This function temporarily disables depth-testing when the |
4394 text is drawn. |
4394 text is drawn. |
4395 |
4395 |
|
4396 \note This function can only be used inside a |
|
4397 QPainter::beginNativePainting()/QPainter::endNativePainting() block |
|
4398 if the default OpenGL paint engine is QPaintEngine::OpenGL. To make |
|
4399 QPaintEngine::OpenGL the default GL engine, call |
|
4400 QGL::setPreferredPaintEngine(QPaintEngine::OpenGL) before the |
|
4401 QApplication constructor. |
|
4402 |
4396 \l{Overpainting Example}{Overpaint} with QPainter::drawText() instead. |
4403 \l{Overpainting Example}{Overpaint} with QPainter::drawText() instead. |
4397 */ |
4404 */ |
4398 |
4405 |
4399 void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font, int) |
4406 void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font, int) |
4400 { |
4407 { |
4410 int width = d->glcx->device()->width(); |
4417 int width = d->glcx->device()->width(); |
4411 int height = d->glcx->device()->height(); |
4418 int height = d->glcx->device()->height(); |
4412 bool auto_swap = autoBufferSwap(); |
4419 bool auto_swap = autoBufferSwap(); |
4413 |
4420 |
4414 QPaintEngine::Type oldEngineType = qgl_engine_selector()->preferredPaintEngine(); |
4421 QPaintEngine::Type oldEngineType = qgl_engine_selector()->preferredPaintEngine(); |
|
4422 |
|
4423 QPaintEngine *engine = paintEngine(); |
|
4424 if (engine && (oldEngineType == QPaintEngine::OpenGL2) && engine->isActive()) { |
|
4425 qWarning("QGLWidget::renderText(): Calling renderText() while a GL 2 paint engine is" |
|
4426 " active on the same device is not allowed."); |
|
4427 return; |
|
4428 } |
|
4429 |
|
4430 // this changes what paintEngine() returns |
4415 qgl_engine_selector()->setPreferredPaintEngine(QPaintEngine::OpenGL); |
4431 qgl_engine_selector()->setPreferredPaintEngine(QPaintEngine::OpenGL); |
4416 QPaintEngine *engine = paintEngine(); |
4432 engine = paintEngine(); |
4417 QPainter *p; |
4433 QPainter *p; |
4418 bool reuse_painter = false; |
4434 bool reuse_painter = false; |
4419 if (engine->isActive()) { |
4435 if (engine->isActive()) { |
4420 reuse_painter = true; |
4436 reuse_painter = true; |
4421 p = engine->painter(); |
4437 p = engine->painter(); |
4504 qgluProject(x, y, z, &model[0][0], &proj[0][0], &view[0], |
4520 qgluProject(x, y, z, &model[0][0], &proj[0][0], &view[0], |
4505 &win_x, &win_y, &win_z); |
4521 &win_x, &win_y, &win_z); |
4506 win_y = height - win_y; // y is inverted |
4522 win_y = height - win_y; // y is inverted |
4507 |
4523 |
4508 QPaintEngine::Type oldEngineType = qgl_engine_selector()->preferredPaintEngine(); |
4524 QPaintEngine::Type oldEngineType = qgl_engine_selector()->preferredPaintEngine(); |
|
4525 QPaintEngine *engine = paintEngine(); |
|
4526 |
|
4527 if (engine && (oldEngineType == QPaintEngine::OpenGL2) && engine->isActive()) { |
|
4528 qWarning("QGLWidget::renderText(): Calling renderText() while a GL 2 paint engine is" |
|
4529 " active on the same device is not allowed."); |
|
4530 return; |
|
4531 } |
|
4532 |
|
4533 // this changes what paintEngine() returns |
4509 qgl_engine_selector()->setPreferredPaintEngine(QPaintEngine::OpenGL); |
4534 qgl_engine_selector()->setPreferredPaintEngine(QPaintEngine::OpenGL); |
4510 QPaintEngine *engine = paintEngine(); |
4535 engine = paintEngine(); |
4511 QPainter *p; |
4536 QPainter *p; |
4512 bool reuse_painter = false; |
4537 bool reuse_painter = false; |
4513 bool use_depth_testing = glIsEnabled(GL_DEPTH_TEST); |
4538 bool use_depth_testing = glIsEnabled(GL_DEPTH_TEST); |
4514 bool use_scissor_testing = glIsEnabled(GL_SCISSOR_TEST); |
4539 bool use_scissor_testing = glIsEnabled(GL_SCISSOR_TEST); |
4515 |
4540 |