Click here to Skip to main content
15,944,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I make video renderer filter with saving video resolution of video film. In windowed mode it works fine. In fullscreen mode (NVidia 3D Vision) image is rendering in the center of screen with source video resolution of video film with half of the width of source video film, when the images are next to the width. There must be black area to fill rest of screen (window) and the video image.
In fullscreen is the same situation as in windowed mode: all coordinated of back buffer are calculeted right.
May be NVidia does something when drawing the video in full screen?
Can you help me?
Here is the code:
D3DVIEWPORT9 local_view_port;
			direct_3D_device->GetViewport(&local_view_port);
			RECT local_view_port_rect = {local_view_port.X,local_view_port.Y,local_view_port.Width,local_view_port.Height};
			SIZE local_view_port_size = {local_view_port.Width,local_view_port.Height};
			RECT local_target_rect;
//			parameter_VideoText->GetTargetRect(&local_target_rect);
			local_target_rect.left = 0;
			local_target_rect.right = cxImage;
			local_target_rect.top = 0;
			local_target_rect.bottom = cyImage;
			RECT local_target_rect_final_window;
			RECT local_target_rect_final_bufer;
			RECT local_window_rect;
			SIZE local_window_size;
			GetClientRect(parameter_VideoText->GetOwnerWindow(),&local_window_rect);
			local_window_size.cx = local_window_rect.right - local_window_rect.left;
			local_window_size.cy = local_window_rect.bottom - local_window_rect.top;
			double local_multiplication_target = 1.0*local_view_port_size.cx/local_view_port_size.cy;
			double local_multiplication_video = 1.0*(local_target_rect.right-local_target_rect.left)/(local_target_rect.bottom-local_target_rect.top);
			double local_multiplication_window = 1.0*local_window_size.cx/local_window_size.cy;
			
			if (local_multiplication_window<local_multiplication_video)
			{
				local_target_rect_final_window.left = 0;
				local_target_rect_final_window.right = local_window_size.cx;
				local_target_rect_final_window.top = local_window_size.cy/2 - 1.0*(local_target_rect.bottom-local_target_rect.top)/(local_target_rect.right-local_target_rect.left)*local_window_size.cx/2;
				local_target_rect_final_window.bottom = local_window_size.cy/2 + 1.0*(local_target_rect.bottom-local_target_rect.top)/(local_target_rect.right-local_target_rect.left)*local_window_size.cx/2;
			}
			else
			{
				local_target_rect_final_window.left = local_window_size.cx/2 - 1.0*(local_target_rect.right-local_target_rect.left)/(local_target_rect.bottom-local_target_rect.top)*local_window_size.cy/2;
				local_target_rect_final_window.right = local_window_size.cx/2 + 1.0*(local_target_rect.right-local_target_rect.left)/(local_target_rect.bottom-local_target_rect.top)*local_window_size.cy/2;
				local_target_rect_final_window.top = 0;
				local_target_rect_final_window.bottom = local_window_size.cy;
			}
			local_target_rect_final_bufer.left = 1.0*local_view_port_size.cx/local_window_size.cx*local_target_rect_final_window.left;
			local_target_rect_final_bufer.right = 1.0*local_view_port_size.cx/local_window_size.cx*local_target_rect_final_window.right;
			local_target_rect_final_bufer.top = 1.0*local_view_port_size.cy/local_window_size.cy*local_target_rect_final_window.top;
			local_target_rect_final_bufer.bottom = 1.0*local_view_port_size.cy/local_window_size.cy*local_target_rect_final_window.bottom;
//			local_target_rect_final_bufer.left = local_view_port_rect.left;
//			local_target_rect_final_bufer.right = local_view_port_rect.right;
//			local_target_rect_final_bufer.top = local_view_port_rect.top;
//			local_target_rect_final_bufer.bottom = local_view_port_rect.bottom;
			{
//				ofstream local_file;
//				local_file.open("log.txt");
//				local_file << local_target_rect_final_bufer.left << " " << local_target_rect_final_bufer.top << " \t" << local_target_rect_final_bufer.right << " " << local_target_rect_final_bufer.bottom;
			}
			{
				if(direct_3D_device->Clear (0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB (0, 0, 0), 0.0f, 0)!=D3D_OK)
				{
					return E_FAIL;
				}
				if(direct_3D_device->BeginScene ()!=D3D_OK)
				{
					return E_FAIL;
				}
				
				CComPtr<IDirect3DSurface9> pDestSurface;
				if(direct_3D_device->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pDestSurface)!=D3D_OK)
				{
					return E_FAIL;
				}
				
				if(pDestSurface)
				{
					if(direct_3D_device->StretchRect(gImageSrc, &srcRect, pDestSurface, &local_target_rect_final_bufer, D3DTEXF_LINEAR)!=D3D_OK)
					{
						return E_FAIL;
					}
				}
				if(direct_3D_device->EndScene ()!=D3D_OK)
				{
					return E_FAIL;
				}
				if(direct_3D_device->Present (NULL, NULL, NULL, NULL)!=D3D_OK)
				{
					return E_FAIL;
				}
			}
Posted

NVidia does something after me with back buffer.
 
Share this answer
 
I have used source surface stretch
if(1.0*(cxImage/2)/cyImage < 1.0)
{
ratio_x = 1.0*(cxImage/2)/cyImage;
ratio_y = 1.0;
}
else
{
ratio_x = 1.0;
ratio_y = 1.0/(cxImage/2)*cyImage;
}


CComPtr<IDirect3DSurface9> local_source_image_final;

RECT local_source_rectangle_final;

local_source_rectangle_final.left = 0;
local_source_rectangle_final.right = local_view_port_size.cx*2*ratio_x;
local_source_rectangle_final.top = 0;
local_source_rectangle_final.bottom = local_view_port_size.cy*ratio_y;

local_handle_result = direct_3D_device->CreateRenderTarget(
local_view_port_size.cx*2*ratio_x,
local_view_port_size.cy*ratio_y,
D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, // Surface is in video memory
0,
TRUE,
&local_source_image_final, NULL);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900