Im having a strange problem that I would appreciate some help with. I have wrote a simple 2D DirectX 9 GameEngine and all is up and running. There is one problem with it though. When I move a sprite around the window tearing occurs frequently. Its like one half of the sprite is drawn in the old coordinates and the rest in the new position.
I thought this was simple a double buffering issue but I have already set up double buffering to work. Here is the code for setting up the device and the back buffer.
[source lang="cpp"]D3DDISPLAYMODE dm; LPDIRECT3DDEVICE9 newDevice; LPDIRECT3DSURFACE9 newbackbuffer; LPD3DXSPRITE new_sprite_handler; this->d3d->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &dm); //set configuration options for Direct3D D3DPRESENT_PARAMETERS d3dpp; ZeroMemory(&d3dpp, sizeof(d3dpp)); d3dpp.Windowed = !targetWindow->IsFullScreen(); d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.EnableAutoDepthStencil = TRUE; d3dpp.AutoDepthStencilFormat = D3DFMT_D16; d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; d3dpp.BackBufferFormat = dm.Format; d3dpp.BackBufferCount = 1; d3dpp.BackBufferWidth = clientWindowRect.right; d3dpp.BackBufferHeight = clientWindowRect.bottom; d3dpp.hDeviceWindow = targetWindow->GetHWND(); //create Direct3D device this->d3d->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, targetWindow->GetHWND(), D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &newDevice); newDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_RGBA(0,0,0,255), 1.0f, 0); if(newDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &newbackbuffer) != D3D_OK) st_engine->LogError("BackBuffer Failed to create");[/source]
Is there anything im missing here. I tried changing the backbuffer count down to 0 so it should be single buffered and it looks the same. That implies to me that even tho im saying use double buffering its not. Any help on this would be greatly appreciated.
Thanks in advance,
MartinSmith160Member Since 28 Mar 2012
Offline Last Active Jun 19 2013 02:09 AM
- Group Members
- Active Posts 39
- Profile Views 1,679
- Submitted Links 0
- Member Title Member
- Age Age Unknown
- Birthday Birthday Unknown