It is currently Fri Sep 20, 2019 1:07 pm



Reply to topic  [ 43 posts ]  Go to page Previous  1, 2
 fantastic! I've gotten my first 3d vision demo running!! 
Author Message
One Eyed Hopeful

Joined: Mon Aug 27, 2012 10:59 am
Posts: 4
Reply with quote
superlxt wrote:
HWND g_hWnd = NULL;
LPDIRECT3D9 g_pD3D = NULL;
LPDIRECT3DDEVICE9 g_pd3dDevice = NULL;
IDirect3DSurface9* gImageSrc = NULL; // Source stereo image beeing created
IDirect3DSurface9* gBackBuf = NULL; //BackBuffer

int gImageWidth = 1680; // Source image width
int gImageHeight = 1050; // Source image height


g_pD3D = Direct3DCreate9( D3D_SDK_VERSION );
D3DPRESENT_PARAMETERS d3dpp;
d3dpp.Windowed = FALSE;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferWidth = 1680;
d3dpp.BackBufferHeight = 1050;
d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
d3dpp.BackBufferCount = 1;

g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hWnd,
flags, &d3dpp, &g_pd3dDevice )
//create offscreenplainsurface and load the stereo image "TestPic.bmp" ( width is gImageWidth*2 and height is gImageHeight )
g_pd3dDevice->CreateOffscreenPlainSurface(gImageWidth*2, gImageHeight, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &gImageSrc, NULL);
D3DXLoadSurfaceFromFile(gImageSrc, NULL, NULL, L"G:/TestPic.bmp", NULL, D3DX_FILTER_NONE, 0, NULL);

// Lock the stereo image
D3DLOCKED_RECT lr;
gImageSrc->LockRect(&lr,NULL,0);
// write stereo signature in the last raw of the stereo image
LPNVSTEREOIMAGEHEADER pSIH =
(LPNVSTEREOIMAGEHEADER)(((unsigned char *) lr.pBits) + (lr.Pitch * (gImageHeight-1)));
// Update the signature header values
pSIH->dwSignature = NVSTEREO_IMAGE_SIGNATURE;
pSIH->dwBPP = 32;
pSIH->dwFlags = SIH_SWAP_EYES; // Src image has left on left and right on right
pSIH->dwWidth = gImageWidth*2;
pSIH->dwHeight = gImageHeight;
// Unlock surface
gImageSrc->UnlockRect();

g_pd3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &gBackBuf);

//then present
void render( void )
{
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET,
D3DCOLOR_ARGB(1,0,0,0), 1.0f, 0 );
g_pd3dDevice->BeginScene();
g_pd3dDevice->StretchRect(gImageSrc, &imageSrcRect, gBackBuf, &backBufferRect, D3DTEXF_NONE);
g_pd3dDevice->EndScene();
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}


Does this NVSTEREOIMAGEHEADER method still work on the latest NVidia Geforce 301.42 driver?


Mon Aug 27, 2012 11:46 am
Profile
One Eyed Hopeful
User avatar

Joined: Sun Feb 03, 2013 5:11 pm
Posts: 15
Reply with quote
NVSTEREOIMAGEHEADER still works. Because various NVIDIA applications use it (the 3D Vision Video player) I assume it will be supported for a long time. And though NVIDIA doesn't actively publish the spec for it (they are miserable at supporting 3D Vision development!), they do mention it in presentations on the technology that they give at conferences.

Has anyone found a way to get around the "rename to googleearth.exe" hack? I find it ridiculous that I need to ship my game in this manner!


Thu Feb 07, 2013 9:37 pm
Profile
One Eyed Hopeful

Joined: Thu Apr 25, 2013 3:43 am
Posts: 2
Reply with quote
Hi,


Thank you very much for your contribution.

I'm trying to transform two live webcam feeds into a 3D stereoscopic one. I managed to display two still images thanks to your code, but I'm totally new to DirectX/Show/3D...

Do you think I could load a webcam live feed instead of a still image?

Maybe using a loop which would display an image using the D3DXLoadSurfaceFromFile function, and acquiring a new image at each iteration? Ideally, it'd awesome if a D3DXLoadSurfaceFromWebcam were to exist :p


Fri Apr 26, 2013 2:18 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 43 posts ]  Go to page Previous  1, 2

Who is online

Users browsing this forum: whyme466 and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by STSoftware.