Showing the changes to interface/src/Application.cpp (1 of 10 files). Show all
Unified · Split
| @@ -875,6 +875,33 @@ void Application::paintGL() { · 874 unmodified lines | ||
| 875 | 875 | PerformanceWarning warn(showWarnings, "Application::paintGL()"); |
| 876 | 876 | resizeGL(); |
| 877 | 877 | |
| 878 | + // Before anything else, let's sync up the gpuContext with the true glcontext used in case anything happened | |
| 879 | + renderArgs._context->syncCache(); | |
| 880 | + | |
| 881 | + if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 882 | + auto primaryFbo = DependencyManager::get<FramebufferCache>()->getPrimaryFramebuffer(); | |
| 883 | + { | |
| 884 | + gpu::Batch batch; | |
| 885 | + batch.setFramebuffer(nullptr); | |
| 886 | + batch.setFramebuffer(primaryFbo); | |
| 887 | + renderArgs._context->render(batch); | |
| 888 | + } | |
| 889 | + renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE; | |
| 890 | + renderRearViewMirror(&renderArgs, _mirrorViewRect); | |
| 891 | + renderArgs._renderMode = RenderArgs::NORMAL_RENDER_MODE; | |
| 892 | + | |
| 893 | + { | |
| 894 | + auto mirrorViewport = glm::ivec4(0, 0, _mirrorViewRect.width(), _mirrorViewRect.height()); | |
| 895 | + float ratio = 1.0f / ((float)QApplication::desktop()->windowHandle()->devicePixelRatio() * getRenderResolutionScale()); | |
| 896 | + | |
| 897 | + auto mirrorViewportDest = glm::ivec4(0, 0, ratio * mirrorViewport.z, ratio * mirrorViewport.w); | |
| 898 | + | |
| 899 | + auto selfieFbo = DependencyManager::get<FramebufferCache>()->getSelfieFramebuffer(); | |
| 900 | + gpu::Batch batch; | |
| 901 | + batch.blit(primaryFbo, mirrorViewport, selfieFbo, mirrorViewportDest); | |
| 902 | + renderArgs._context->render(batch); | |
| 903 | + } | |
| 904 | + } | |
| 878 | 905 | |
| 879 | 906 | { |
| 880 | 907 | PerformanceTimer perfTimer("renderOverlay"); |
| @@ -936,7 +963,7 @@ void Application::paintGL() { · 55 unmodified lines | ||
| 936 | 963 | } |
| 937 | 964 | |
| 938 | 965 | // Sync up the View Furstum with the camera |
| 939 | − loadViewFrustum(_myCamera, _viewFrustum); | |
| 966 | + // loadViewFrustum(_myCamera, _viewFrustum); | |
| 940 | 967 | |
| 941 | 968 | |
| 942 | 969 | renderArgs._renderMode = RenderArgs::DEFAULT_RENDER_MODE; |
| @@ -974,19 +1001,17 @@ void Application::paintGL() { · 31 unmodified lines | ||
| 974 | 1001 | |
| 975 | 1002 | displaySide(&renderArgs, _myCamera); |
| 976 | 1003 | |
| 977 | − if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 978 | − renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE; | |
| 979 | − renderRearViewMirror(&renderArgs, _mirrorViewRect); | |
| 980 | − renderArgs._renderMode = RenderArgs::NORMAL_RENDER_MODE; | |
| 981 | − } | |
| 982 | − | |
| 983 | 1004 | { |
| 984 | 1005 | auto geometryCache = DependencyManager::get<GeometryCache>(); |
| 985 | 1006 | auto primaryFbo = DependencyManager::get<FramebufferCache>()->getPrimaryFramebuffer(); |
| 986 | 1007 | gpu::Batch batch; |
| 987 | 1008 | batch.blit(primaryFbo, glm::ivec4(0, 0, _renderResolution.x, _renderResolution.y), |
| 988 | 1009 | nullptr, glm::ivec4(0, 0, _glWidget->getDeviceSize().width(), _glWidget->getDeviceSize().height())); |
| 1010 | + | |
| 1011 | + batch.setFramebuffer(nullptr); | |
| 1012 | + | |
| 989 | 1013 | renderArgs._context->render(batch); |
| 1014 | + | |
| 990 | 1015 | } |
| 991 | 1016 | |
| 992 | 1017 | _compositor.displayOverlayTexture(&renderArgs); |
| @@ -2958,7 +2983,7 @@ PickRay Application::computePickRay(float x, float y) const { · 1965 unmodified lines | ||
| 2958 | 2983 | } |
| 2959 | 2984 | |
| 2960 | 2985 | QImage Application::renderAvatarBillboard(RenderArgs* renderArgs) { |
| 2961 | − auto primaryFramebuffer = DependencyManager::get<FramebufferCache>()->getPrimaryFramebuffer(); | |
| 2986 | +/* auto primaryFramebuffer = DependencyManager::get<FramebufferCache>()->getPrimaryFramebuffer(); | |
| 2962 | 2987 | glBindFramebuffer(GL_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(primaryFramebuffer)); |
| 2963 | 2988 | |
| 2964 | 2989 | // clear the alpha channel so the background is transparent |
| @@ -2966,17 +2991,41 @@ QImage Application::renderAvatarBillboard(RenderArgs* renderArgs) { · 1 unmodified line | ||
| 2966 | 2991 | glClearColor(0.0, 0.0, 0.0, 0.0); |
| 2967 | 2992 | glClear(GL_COLOR_BUFFER_BIT); |
| 2968 | 2993 | glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); |
| 2994 | + */ | |
| 2995 | + | |
| 2996 | + // const int BILLBOARD_SIZE = 64; | |
| 2997 | + const int BILLBOARD_SIZE = 256; | |
| 2998 | + _glWidget->makeCurrent(); | |
| 2999 | + | |
| 3000 | + auto primaryFbo = DependencyManager::get<FramebufferCache>()->getPrimaryFramebuffer(); | |
| 2969 | 3001 | |
| 2970 | − const int BILLBOARD_SIZE = 64; | |
| 2971 | − // TODO: Pass a RenderArgs to renderAvatarBillboard | |
| 2972 | − renderRearViewMirror(renderArgs, QRect(0, _glWidget->getDeviceHeight() - BILLBOARD_SIZE, | |
| 3002 | + { | |
| 3003 | + gpu::Batch batch; | |
| 3004 | + batch.setFramebuffer(nullptr); | |
| 3005 | + batch.setFramebuffer(primaryFbo); | |
| 3006 | + renderArgs->_context->render(batch); | |
| 3007 | + } | |
| 3008 | + renderArgs->_renderMode = RenderArgs::MIRROR_RENDER_MODE; | |
| 3009 | + renderRearViewMirror(renderArgs, QRect(0, /*_glWidget->getDeviceHeight() - BILLBOARD_SIZE*/ 0, | |
| 2973 | 3010 | BILLBOARD_SIZE, BILLBOARD_SIZE), |
| 2974 | − true); | |
| 3011 | + false); | |
| 3012 | + renderArgs->_renderMode = RenderArgs::NORMAL_RENDER_MODE; | |
| 3013 | + | |
| 3014 | + auto selfieFbo = DependencyManager::get<FramebufferCache>()->getSelfieFramebuffer(); | |
| 3015 | + { | |
| 3016 | + auto mirrorViewport = glm::ivec4(0, 0,BILLBOARD_SIZE, BILLBOARD_SIZE); | |
| 3017 | + gpu::Batch batch; | |
| 3018 | + // batch.blit(primaryFbo, mirrorViewport, selfieFbo, mirrorViewport); | |
| 3019 | + batch.setFramebuffer(nullptr); | |
| 3020 | + renderArgs->_context->render(batch); | |
| 3021 | + } | |
| 3022 | + | |
| 3023 | + | |
| 2975 | 3024 | QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32); |
| 3025 | + glBindFramebuffer(GL_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(primaryFbo)); | |
| 2976 | 3026 | glReadPixels(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE, GL_BGRA, GL_UNSIGNED_BYTE, image.bits()); |
| 2977 | − glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | |
| 2978 | − | |
| 2979 | 3027 | glBindFramebuffer(GL_FRAMEBUFFER, 0); |
| 3028 | + | |
| 2980 | 3029 | return image; |
| 2981 | 3030 | } |
| 2982 | 3031 | |
| @@ -3390,13 +3439,18 @@ void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& regi · 407 unmodified lines | ||
| 3390 | 3439 | gpu::Vec4i viewport; |
| 3391 | 3440 | if (billboard) { |
| 3392 | 3441 | QSize size = DependencyManager::get<FramebufferCache>()->getFrameBufferSize(); |
| 3393 | − viewport = gpu::Vec4i(region.x(), size.height() - region.y() - region.height(), region.width(), region.height()); | |
| 3442 | + // viewport = gpu::Vec4i(region.x(), size.height() - region.y() - region.height(), region.width(), region.height()); | |
| 3443 | + viewport = gpu::Vec4i(0, 0, region.width(), region.height()); | |
| 3394 | 3444 | } else { |
| 3395 | 3445 | // if not rendering the billboard, the region is in device independent coordinates; must convert to device |
| 3396 | 3446 | QSize size = DependencyManager::get<FramebufferCache>()->getFrameBufferSize(); |
| 3397 | 3447 | float ratio = (float)QApplication::desktop()->windowHandle()->devicePixelRatio() * getRenderResolutionScale(); |
| 3398 | − int x = region.x() * ratio, y = region.y() * ratio, width = region.width() * ratio, height = region.height() * ratio; | |
| 3399 | − viewport = gpu::Vec4i(x, size.height() - y - height, width, height); | |
| 3448 | + int x = region.x() * ratio; | |
| 3449 | + int y = region.y() * ratio; | |
| 3450 | + int width = region.width() * ratio; | |
| 3451 | + int height = region.height() * ratio; | |
| 3452 | + // viewport = gpu::Vec4i(x, size.height() - y - height, width, height); | |
| 3453 | + viewport = gpu::Vec4i(0, 0, width, height); | |
| 3400 | 3454 | } |
| 3401 | 3455 | renderArgs->_viewport = viewport; |
| 3402 | 3456 | |
| @@ -3414,8 +3468,7 @@ void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& regi · 11 unmodified lines | ||
| 3414 | 3468 | renderArgs->_context->render(batch); |
| 3415 | 3469 | } |
| 3416 | 3470 | |
| 3417 | − bool updateViewFrustum = false; | |
| 3418 | − loadViewFrustum(_mirrorCamera, _viewFrustum); | |
| 3471 | + // loadViewFrustum(_mirrorCamera, _viewFrustum); | |
| 3419 | 3472 | |
| 3420 | 3473 | // render rear mirror view |
| 3421 | 3474 | displaySide(renderArgs, _mirrorCamera, true, billboard); |