| 354 | |
| 355 | |
| 356 | void ChannelManager::setupProjectiveTexture(ProjTextureSetup setup, GLint texSizeInv) |
| 357 | { |
| 358 | mOffscreenBuffer->Bind(); |
| 359 | mOffscreenBuffer->EnableTextureTarget(); |
| 360 | |
| 361 | if (setup == FixedFunction) |
| 362 | { |
| 363 | static const float splane[4] = { 1.0f, 0.0f, 0.0f, 0.0f }; |
| 364 | static const float tplane[4] = { 0.0f, 1.0f, 0.0f, 0.0f }; |
| 365 | static const float rplane[4] = { 0.0f, 0.0f, 1.0f, 0.0f }; |
| 366 | static const float qplane[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; |
| 367 | |
| 368 | glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); |
| 369 | glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); |
| 370 | glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); |
| 371 | glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); |
| 372 | glTexGenfv(GL_S, GL_EYE_PLANE, splane); |
| 373 | glTexGenfv(GL_T, GL_EYE_PLANE, tplane); |
| 374 | glTexGenfv(GL_R, GL_EYE_PLANE, rplane); |
| 375 | glTexGenfv(GL_Q, GL_EYE_PLANE, qplane); |
| 376 | glEnable(GL_TEXTURE_GEN_S); |
| 377 | glEnable(GL_TEXTURE_GEN_T); |
| 378 | glEnable(GL_TEXTURE_GEN_R); |
| 379 | glEnable(GL_TEXTURE_GEN_Q); |
| 380 | } |
| 381 | |
| 382 | if (setup == FixedFunction || setup == ARBShader) |
| 383 | { |
| 384 | glMatrixMode(GL_TEXTURE); |
| 385 | |
| 386 | const int dx = OpenGL::canvasPos[2] - OpenGL::canvasPos[0]; |
| 387 | const int dy = OpenGL::canvasPos[3] - OpenGL::canvasPos[1]; |
| 388 | |
| 389 | // with ARB_texture_rectangle texture coordinates range between |
| 390 | // 0 and dx resp. dy |
| 391 | float factorX = static_cast<float>(dx); |
| 392 | float factorY = static_cast<float>(dy); |
| 393 | |
| 394 | // Otherwise, if the texture rectangle extension is not used: |
| 395 | // Do not check for the non-power-of-two extension, but simply for |
| 396 | // the texture format. This seems safer, since it should work always. |
| 397 | if (!isRectangularTexture()) { |
| 398 | // with ordinary pow-of-two texture coordinates are between 0 and 1 |
| 399 | // but we must assure only the used part of the texture is taken. |
| 400 | factorX /= static_cast<float>(mOffscreenBuffer->GetWidth()); |
| 401 | factorY /= static_cast<float>(mOffscreenBuffer->GetHeight()); |
| 402 | } |
| 403 | |
| 404 | float texCorrect[16] = { factorX, 0.0f, 0.0f, 0.0f, |
| 405 | 0.0f, factorY, 0.0f, 0.0f, |
| 406 | 0.0f, 0.0f, 1.0f, 0.0f, |
| 407 | 0.0f, 0.0f, 0.0f, 1.0f }; |
| 408 | |
| 409 | static const float p2ndc[16] = { 0.5f, 0.0f, 0.0f, 0.0f, |
| 410 | 0.0f, 0.5f, 0.0f, 0.0f, |
| 411 | 0.0f, 0.0f, 0.5f, 0.0f, |
| 412 | 0.5f, 0.5f, 0.5f, 1.0f }; |
| 413 | glPushMatrix(); |
nothing calls this directly
no test coverage detected