Sign in to follow this  
VitaliBR

Video Settings of my Game

Recommended Posts

I wonder if there is any site, tutorial or article to comment on the options i can add in my game. For example I do not know how I change my device "filtering mode" / "texture detail" / etc ..

And I can use the following method when changing the Resolution?

   IDirect3DStateBlock9* pStateBlock = NULL;
m_pDevice->CreateStateBlock(D3DSBT_ALL, &pStateBlock);
pStateBlock->Capture();


pStateBlock->Apply();
pStateBlock->Release();


Thanks

Share this post


Link to post
Share on other sites
To change resolution:

1. release unmanaged resources
2. for others you might need to use OnResetDevice() method
3. fill present params with your new resolution
4. then call IDirect3DDevice9::Reset method with your new present params
5. restore resources

For "texture detail" (if i understood you correctly) check IDirect3DBaseTexture9::SetLOD method

Share this post


Link to post
Share on other sites
my thinking is correct?
void DxManager::ChangeScreenResolution(int iWidth, int iHeight, bool bFullscreen)
{
if(bFullscreen && m_pFullscreen) // If we are fullscreen already..
if((iWidth == m_pWidth) && (iHeight == m_pHeight))
return; // Already in requested mode.

d3dpp.Windowed = !bFullscreen;
d3dpp.BackBufferWidth = iWidth;
d3dpp.BackBufferHeight = iHeight;

if(!bFullscreen)
{
RECT client = {0, 0, iWidth, iHeight};
AdjustWindowRect(&client, WS_OVERLAPPEDWINDOW, false);

d3dpp.FullScreen_RefreshRateInHz = 0;
d3dpp.BackBufferFormat = D3DFMT_R5G6B5;

SetWindowLongPtr(wndHandle, GWL_STYLE, WS_POPUP);
SetWindowPos(wndHandle, HWND_TOP, 100, 100, client.right, client.bottom, SWP_NOZORDER | SWP_SHOWWINDOW);
}
else
{
d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
d3dpp.BackBufferFormat = D3DFMT_R5G6B5;

SetWindowLongPtr(wndHandle, GWL_STYLE, WS_POPUP);
SetWindowPos(wndHandle, HWND_TOP, 0, 0, iWidth, iHeight, SWP_NOZORDER | SWP_SHOWWINDOW);
}


direct3dDevice->Reset(&d3dpp);


return;
}

Share this post


Link to post
Share on other sites
Quote:

my thinking is correct?

Partialy yes.

Take this step before changing resolution:
release resources (meshes, vertex/index buffers, render targets, "regular" textures...) based on creation flags (MANAGED, DEFAULT, SYSTEMMEM...) for example:

//some managed "resources" have OnLostDevice()/OnResetDevice() methods
//so you dont need to recreate them from scratch
//they can "survive" device->Reset() method

void DxManager::OnPreReset()//function to release all res.
{
effect1->OnLostDevice();
effect2->OnLostDevice();
effect3->OnLostDevice();
...
//release dynamic V/I B's
vertexBuffer1->Release();
vertexBuffer2->Release();
indexBuffer1->Release();
...
}

void DxManager::OnPostReset()//function to recreate res.
{
effect1->OnResetDevice();
effect2->OnResetDevice();
effect3->OnResetDevice();
...
//here create V/I B's again from scratch
...
}

void DxManager::ChangeScreenResolution(int iWidth, int iHeight, bool bFullscreen)//your function
{
//ommited your code
...
OnPreReset();
device->Reset(newParams)
hr = device->TextCooperativeLevel();//check if succeded
if (succesfuly reseted )
{
OnPostReset();
}
...
}


Check all function that returns HRESULT for possible failure!
Check supported resolutions/backbuffer formats before feeding it into d3dpparams!

You might want to read this also

I am writing this from memory so i might made mistake.

Quote:


...
d3dpp.Windowed = !bFullscreen;//why '!' if you pass bFullscreen as parametar?
//d3dpp.Windowed = bFullscreen;//should be this
...


Share this post


Link to post
Share on other sites
I think the texture detail setting is supposed to reduce texture memory usage, which means you physically have to load smaller resolution textures. SetLOD only controls the mip level used from a texture with mip levels already loaded. In order to selectively load mip map levels from a texture, I think you would have to load the texture with default resolution and then go through all levels (see GetLevelCount) and call GetSurfaceLevel to copy data into another, "reduced" texture while skipping the first "n" number of levels depending on how low the quality is. Then unload the original texture and use the "reduced" texture in its place.

There is also a Filtering setting in most games, which controls sampler state between Point, Linear and Anisotropic (see D3DTEXTUREFILTERTYPE). Newever implementations may also have Pyramidal, Quad, etc. You set that with SetSamplerState for MagFilter and MinFilter states.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this