Ok, im gonna describe how im doing pixel aspect ratio in windowed mode and post pics.
This envolve direct3d9. Please someone help me how to do it well.
- First i have a fuction that resizes the window to the desired client window size. Lets says SetWindowX(HWND hwnd, int x). I have tested calling after "GetClientRect()" and is resized correctly.
The body of SetWindowX() is as follow:
Are those images well point sampled and interpolated??
now i have D3D9 interface well created and "RecreateD3D()" is as follow:
"ResetD3D()" just check if it has to recreate surfaces. It free up surfaces is they are created and THEN RecreateD3D() recreates all the surfaces again. I know it could be done better but its just for starting.
The biggest thing: i use StrectchRect() D3D9 interface to "blt" between surfaces. I have one "offscreen" surface of 256x240 where pixels are put in. I know basic cards doesn't handle surfaces that are not power of 2, but my Nvidia 440 can handle as well as others nvidia and ati cards.
I use this, and is my main blitting function, that blt surfaces.
rcClip is just to crop the upper and lower 8 pixels of the image.
Now if you took a look to RecreateD3D() the Width of stage_one is multiplied by 2.
Sincerely i don't know what to do i get this:
1X:
2X:
3X:
This envolve direct3d9. Please someone help me how to do it well.
- First i have a fuction that resizes the window to the desired client window size. Lets says SetWindowX(HWND hwnd, int x). I have tested calling after "GetClientRect()" and is resized correctly.
The body of SetWindowX() is as follow:
Code:
void SetWindowX(HWND hwnd, int x)
{
g_WinX = x;
RecreateD3D(hwnd, x);
ClientResize(hwnd, 292 * x, (240 - 16) * x);
}
{
g_WinX = x;
RecreateD3D(hwnd, x);
ClientResize(hwnd, 292 * x, (240 - 16) * x);
}
Are those images well point sampled and interpolated??
now i have D3D9 interface well created and "RecreateD3D()" is as follow:
Code:
int RecreateD3D(HWND hWnd, int x)
{
ResetD3D();
D3DPRESENT_PARAMETERS d3dpp; // create a struct to hold various device information
ZeroMemory(&d3dpp, sizeof(d3dpp)); // clear out the struct for use
d3dpp.Windowed = TRUE; // program windowed, not fullscreen
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; // discard old frames
d3dpp.hDeviceWindow = hWnd; // set the window to be used by Direct3D
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferWidth = 292 * x;
d3dpp.BackBufferHeight = 240 - 16;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
g_hr = d3d->CreateDevice(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp,
&d3ddev);
if (FAILED(g_hr))
return 0;
//g_hr = d3ddev->CreateOffscreenPlainSurface(256,256, D3DFMT_X8R8G8B8 ,D3DPOOL_DEFAULT, &off_screen, 0);
g_hr = d3ddev->CreateOffscreenPlainSurface(256,240, D3DFMT_X8R8G8B8 ,D3DPOOL_DEFAULT, &off_screen, 0);
if (FAILED(g_hr))
return 0;
g_hr = d3ddev->CreateRenderTarget(256 *x * 2,(240 - 16),
D3DFMT_X8R8G8B8 ,D3DMULTISAMPLE_NONE, 0, 0, &stage_one, 0);
if (FAILED(g_hr))
return 0;
g_hr = d3ddev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO,&back_buffer);
if (FAILED(g_hr))
return 0;
}
{
ResetD3D();
D3DPRESENT_PARAMETERS d3dpp; // create a struct to hold various device information
ZeroMemory(&d3dpp, sizeof(d3dpp)); // clear out the struct for use
d3dpp.Windowed = TRUE; // program windowed, not fullscreen
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; // discard old frames
d3dpp.hDeviceWindow = hWnd; // set the window to be used by Direct3D
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferWidth = 292 * x;
d3dpp.BackBufferHeight = 240 - 16;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
g_hr = d3d->CreateDevice(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp,
&d3ddev);
if (FAILED(g_hr))
return 0;
//g_hr = d3ddev->CreateOffscreenPlainSurface(256,256, D3DFMT_X8R8G8B8 ,D3DPOOL_DEFAULT, &off_screen, 0);
g_hr = d3ddev->CreateOffscreenPlainSurface(256,240, D3DFMT_X8R8G8B8 ,D3DPOOL_DEFAULT, &off_screen, 0);
if (FAILED(g_hr))
return 0;
g_hr = d3ddev->CreateRenderTarget(256 *x * 2,(240 - 16),
D3DFMT_X8R8G8B8 ,D3DMULTISAMPLE_NONE, 0, 0, &stage_one, 0);
if (FAILED(g_hr))
return 0;
g_hr = d3ddev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO,&back_buffer);
if (FAILED(g_hr))
return 0;
}
"ResetD3D()" just check if it has to recreate surfaces. It free up surfaces is they are created and THEN RecreateD3D() recreates all the surfaces again. I know it could be done better but its just for starting.
The biggest thing: i use StrectchRect() D3D9 interface to "blt" between surfaces. I have one "offscreen" surface of 256x240 where pixels are put in. I know basic cards doesn't handle surfaces that are not power of 2, but my Nvidia 440 can handle as well as others nvidia and ati cards.
I use this, and is my main blitting function, that blt surfaces.
Code:
RECT rcClip = {0,8,256,240 - 8};
void EndScene(void)
{
off_screen->UnlockRect();
g_hr = d3ddev->StretchRect(off_screen, &rcClip, stage_one, 0, D3DTEXF_POINT);
g_hr = d3ddev->StretchRect(stage_one, 0, back_buffer, 0, D3DTEXF_LINEAR);
g_hr = d3ddev->EndScene(); // ends the 3D scene
g_hr = d3ddev->Present(NULL, NULL, NULL, NULL); // displays the created frame
}
void EndScene(void)
{
off_screen->UnlockRect();
g_hr = d3ddev->StretchRect(off_screen, &rcClip, stage_one, 0, D3DTEXF_POINT);
g_hr = d3ddev->StretchRect(stage_one, 0, back_buffer, 0, D3DTEXF_LINEAR);
g_hr = d3ddev->EndScene(); // ends the 3D scene
g_hr = d3ddev->Present(NULL, NULL, NULL, NULL); // displays the created frame
}
rcClip is just to crop the upper and lower 8 pixels of the image.
Now if you took a look to RecreateD3D() the Width of stage_one is multiplied by 2.
Sincerely i don't know what to do i get this:
1X:
2X:
3X: