================ CropRenderSize This automatically halves sizes until it fits in the current window size, so if you specify a power of two size for a texture copy, it may be shrunk down, but still valid. ================ */
| 774 | ================ |
| 775 | */ |
| 776 | void idRenderSystemLocal::CropRenderSize( int width, int height, bool makePowerOfTwo, bool forceDimensions ) { |
| 777 | if ( !glConfig.isInitialized ) { |
| 778 | return; |
| 779 | } |
| 780 | |
| 781 | // close any gui drawing before changing the size |
| 782 | guiModel->EmitFullScreen(); |
| 783 | guiModel->Clear(); |
| 784 | |
| 785 | if ( width < 1 || height < 1 ) { |
| 786 | common->Error( "CropRenderSize: bad sizes" ); |
| 787 | } |
| 788 | |
| 789 | if ( session->writeDemo ) { |
| 790 | session->writeDemo->WriteInt( DS_RENDER ); |
| 791 | session->writeDemo->WriteInt( DC_CROP_RENDER ); |
| 792 | session->writeDemo->WriteInt( width ); |
| 793 | session->writeDemo->WriteInt( height ); |
| 794 | session->writeDemo->WriteInt( makePowerOfTwo ); |
| 795 | |
| 796 | if ( r_showDemo.GetBool() ) { |
| 797 | common->Printf( "write DC_CROP_RENDER\n" ); |
| 798 | } |
| 799 | } |
| 800 | |
| 801 | // convert from virtual SCREEN_WIDTH/SCREEN_HEIGHT coordinates to physical OpenGL pixels |
| 802 | renderView_t renderView; |
| 803 | renderView.x = 0; |
| 804 | renderView.y = 0; |
| 805 | renderView.width = width; |
| 806 | renderView.height = height; |
| 807 | |
| 808 | idScreenRect r; |
| 809 | RenderViewToViewport( &renderView, &r ); |
| 810 | |
| 811 | width = r.x2 - r.x1 + 1; |
| 812 | height = r.y2 - r.y1 + 1; |
| 813 | |
| 814 | if ( forceDimensions ) { |
| 815 | // just give exactly what we ask for |
| 816 | width = renderView.width; |
| 817 | height = renderView.height; |
| 818 | } |
| 819 | |
| 820 | // if makePowerOfTwo, drop to next lower power of two after scaling to physical pixels |
| 821 | if ( makePowerOfTwo ) { |
| 822 | width = RoundDownToPowerOfTwo( width ); |
| 823 | height = RoundDownToPowerOfTwo( height ); |
| 824 | // FIXME: megascreenshots with offset viewports don't work right with this yet |
| 825 | } |
| 826 | |
| 827 | renderCrop_t *rc = &renderCrops[currentRenderCrop]; |
| 828 | |
| 829 | // we might want to clip these to the crop window instead |
| 830 | while ( width > glConfig.vidWidth ) { |
| 831 | width >>= 1; |
| 832 | } |
| 833 | while ( height > glConfig.vidHeight ) { |
no test coverage detected