# 1:1 pixel:texel ratio with an orthogonal projection matrix

## Recommended Posts

Hi all, Is it possible to get a 1:1 pixel:texel ratio using an orthogonal projection matrix, and if so, how? I know I could use transformed vertices to achieve the same thing, but I'd like the flexability of untransformed vertices. At the moment, I have this:
D3DXMatrixOrthoLH(&matrix,1024.0f,768.0f,1.0f,100.0f);
pDevice->SetTransform(D3DTS_PROJECTION,&matrix);
D3DXVECTOR3 vEye(0.0f,0.0f,-50.0f), vAt(0.0f,0.0f,0.0f), vUp(0.0f,1.0f,0.0f);
D3DXMatrixLookAtLH(&matrix,&vEye,&vAt,&vUp);
pDevice->SetTransform(D3DTS_VIEW,&matrix);


But that causes my 100x100 triangle to end up 78x78 pixels, and obviously messes up the texture on it. It's probably something obvious that I'm missing, but I can't seem to see what it is. Any ideas? Cheers, Steve

##### Share on other sites
Is your window size 1024x768 (or are you running full screen?)? One way you might be able to achieve what you're looking for is to set the ortho projection to 1.0x1.0. Then, use 0 to 1 as the vertices.

float x,y;
x = 400.0f;
y = 200.0f;
float vX = x/1024;
float vY = y/768;

Simple example. Sorry if this doesn't help you out. Maybe if you could post more code, the actual setting of vertices for instance, and how you create your presentation params.

Chris

##### Share on other sites
Well, I found the problem. I'm an idiot.
I managed to create a 800x600 window, then try to use it as if it was 104x768 >_<

It works fine now.