Board index » cppbuilder » DirectX 9.0 and 3D rendering?

DirectX 9.0 and 3D rendering?


2007-07-17 10:48:52 PM
cppbuilder58
Hi All,
I'm trying to create a 3D environment using DirectX. Is there any kind of
tutorial out there for surface flipping 2 images, a left and a right image, that
would sync with my CRT vertical sync so that my shutter glasses would hide the
right image from the left eye and left image from the right eye?
So far, I've got my images flipping but I can't seem to make them sync with the
CRT vertical sync... I'm using IDirect3DDevice9::Present() to accomplish this.
Is there a way to configure the D3DPRESENT_PARAMETERS to auto-sync to the CRT?
If I understand this correctly, all I have to do is ensure that each CRT paint
(at 120Hz) paints alternating images as the shutter glasses sync with the CRT's
vertical sync automatically...
Thanks,
Rob
----------------------------------------------------------------
 
 

Re:DirectX 9.0 and 3D rendering?

Robert G. Hoover wrote:
Quote
So far, I've got my images flipping but I can't seem to make them sync
with the
CRT vertical sync... I'm using IDirect3DDevice9::Present() to accomplish
this.
Is there a way to configure the D3DPRESENT_PARAMETERS to auto-sync to the
CRT?
If I understand this correctly, all I have to do is ensure that each CRT
paint
(at 120Hz) paints alternating images as the shutter glasses sync with the
CRT's
vertical sync automatically...
Set PresentationParameters to D3DPRESENT_INTERVAL_ONE.
HTH
Jon
 

Re:DirectX 9.0 and 3D rendering?

Jonathan Benedicto wrote:
Quote

Set PresentationParameters to D3DPRESENT_INTERVAL_ONE.

HTH

Jon
Hi Jon,
Yep, that's in there. Here's what (I think) I know at this point...
My main message processing loop calls my rendering function which displays the
left or right picture on the screen via Present(). As the PresentationInterval
is INTERVAL_ONE, it should work... and does. But, my guess is, every so often,
my program get forced out of the CPU (WinAmp does this very reliably) and
therefore misses a vSync from the monitor, resulting in my left and right images
reversing and my eyes effectively crossing.
I was thinking about checking each successive call into my ShowSynchronizedFrame
against the Windows TickCount and estimating which image (left or right) I
should be displaying. Alternatively, if I could somehow get the number of vSyncs
that have elapsed, I could easily determine the proper image to display based on
oddness or evenness of this number...
I figure this is 3D {*word*143} 101 because if you can't get your display to stay in
sync, you get killed pretty fast by the guys you're trying to shoot. ;)
Unfortunately, I have little experience with DirectX.
Thanks,
Rob
...
// DirectX painting of backbuffers
void ShowSynchronizedFrame()
{
// flip front and back buffers - this displays new image data
if (g_pd3dDevice->Present(NULL, NULL, g_hWnd, NULL) != D3DERR_WASSTILLDRAWING)
{
// flip left/right surface
PaintLeftFrame = !PaintLeftFrame;
}
}
...
// configure Direct3D Present() parameters
d3dpp.BackBufferWidth = bmInfo->bmiHeader.biWidth;
d3dpp.BackBufferHeight = bmInfo->bmiHeader.biHeight;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferCount = 1;
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
d3dpp.MultiSampleQuality = 0;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = NULL;
d3dpp.Windowed = false;
d3dpp.EnableAutoDepthStencil = false;//true;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
d3dpp.Flags = 0;
d3dpp.FullScreen_RefreshRateInHz = 120;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
...
// main event loop for page flipping window
do
{
// process all events
if (PeekMessage(&uMsg, NULL, 0, 0, PM_REMOVE))
{
// standard message dispatch...
TranslateMessage(&uMsg);
DispatchMessage (&uMsg);
}
// display proper back buffer
ShowSynchronizedFrame();
}
while (uMsg.message != WM_QUIT);
 

{smallsort}

Re:DirectX 9.0 and 3D rendering?

Robert G. Hoover wrote:
Quote
Yep, that's in there. Here's what (I think) I know at this point...
I'd suggest asking over at
microsoft.public.win32.programmer.directx.graphics
Jon
 

Re:DirectX 9.0 and 3D rendering?

Jonathan Benedicto wrote:
Quote

I'd suggest asking over at
microsoft.public.win32.programmer.directx.graphics

Jon
Hi Jon,
Thanks for the tip... looks like this group is what I was looking for.... :)
Rob