Sign in to follow this  

How to translate (x/y) an orthogonal projection

Recommended Posts

I used the sample from to render a large scene. It works perfectly if I use a perspective projection. If I use D3DXMatrixOrthoLH, it works only for a single tile. The reason for this has to be how the projection is offset for each tile. The code is reproduced below. Thanks for any help anyone can provide. // get the current projection matrix and save a copy D3DXMATRIX oldProj,newProj; pDev->GetTransform(D3DTS_PROJECTION,&oldProj); newProj=oldProj; // scale the projection matrix on x and y axis newProj._11*=numTiles; newProj._22*=numTiles; // loop through the tiles in X for (int i=0;i<numTiles;i++) { // offset x coordinates newProj._31=(numTiles-1)-i*2.0f; // loop through the tiles in Y for (int j=0;j<numTiles;j++) { // offset y coordinates newProj._32=-((numTiles-1)-j*2.0f); // set the modified projection matrix pDev->SetTransform(D3DTS_PROJECTION,&newProj); // call the rendering function if (FAILED(hr=renderFunc())) { surf->Release(); return hr; } // get the back buffer pointer if(FAILED(hr=pDev->GetBackBuffer(0,D3DBACKBUFFER_TYPE_MONO,&backbuf))) { surf->Release(); return hr; } // copy the tile to the image buffer and release the back buffer RECT destRect; destRect.left=desc.Width*i; destRect.right=destRect.left+desc.Width;*j;; hr=D3DXLoadSurfaceFromSurface(surf,NULL,&destRect, backbuf,NULL,NULL,D3DX_FILTER_NONE,0); backbuf->Release(); if (FAILED(hr)) { surf->Release(); return hr; } // show current tile pDev->Present(0,0,0,0); } } // restore projection matrix pDev->SetTransform(D3DTS_PROJECTION,&oldProj);

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