• Create Account

### #ActualInterminable

Posted 14 July 2012 - 02:10 AM

This might help the issue.

http://msdn.microsof...0(v=vs.85).aspx

What the article describes sounds like it could be related to the issue I'm having.

The problem is, I'm not drawing a 2D texture to a surface. It's a standalone sprite. I'm unsure how I can deal with this.

Do you mean you are using the Sprite class?

What you need to do is shift your Projection Matrix to account for the issue. This is how i setup mine and it seems to work. I'm not a DX master by any means but give it a shot and see if it helps. My Coordinate system has 0,0 at the center of the screen and +Y is up.

Device.SetTransform(TransformState.Projection, Matrix.Translation(-0.5f, 0.5f, 0.0f) * Matrix.OrthoLH(_form.ClientSize.Width, _form.ClientSize.Height, 0, 1));

I was just altering the coordinates I was drawing it at with Id3DDevice::Draw(). ><

But I recall some of this transformation stuff now, I have a feeling I made a thread on here a while back which involved those but was to do with rotations...

Anyway, in trying to look at how you're doing that particular line, I am unsure how you're doing 'TransformState.Projection'. It doesn't seem to be possible with D3DTRANSFORMSTATETYPE. And that's the required first argument for iD3DXDevice::SetTransform().

In addition I assume there's some specific function for filling the D3DTRANSFORMSTATETYPE struct, but I can't seem to find it. ><

I have altered my code to how I was using SetTransform() in the past. First I have a PrepareTransform() function:


void Renderer::PrepareTransform(int input)
{
transformStateType->Projection;
d3dXSprite->SetTransform(
D3DXMatrixTransformation2D(&d3dMatrix,
NULL,
0.0,
&D3DXVECTOR2(1.0,1.0),
&D3DXVECTOR2(texturesToRender[input].objectPointer->originPointer()->x,texturesToRender[input].objectPointer->originPointer()->y),
0.0f,
&D3DXVECTOR2(texturesToRender[input].objectPointer->coordinatesPointer()->x,texturesToRender[input].objectPointer->coordinatesPointer()->y));

d3dXSprite->SetTransform(&d3dMatrix);
}


And I draw after that function is called:


if(FAILED(hResult = d3dXSprite->Draw(*texturesToRender[i].objectPointer->texturePointer()->texturePointer(), NULL, NULL, NULL, 0xffffffff)))
{


Unfortunately the issue still exists, but I would assume this is because I'm not dealing with this projection matrix stuff you're mentioning.

### #2Interminable

Posted 14 July 2012 - 02:10 AM

This might help the issue.

http://msdn.microsof...0(v=vs.85).aspx

What the article describes sounds like it could be related to the issue I'm having.

The problem is, I'm not drawing a 2D texture to a surface. It's a standalone sprite. I'm unsure how I can deal with this.

Do you mean you are using the Sprite class?

What you need to do is shift your Projection Matrix to account for the issue. This is how i setup mine and it seems to work. I'm not a DX master by any means but give it a shot and see if it helps. My Coordinate system has 0,0 at the center of the screen and +Y is up.

Device.SetTransform(TransformState.Projection, Matrix.Translation(-0.5f, 0.5f, 0.0f) * Matrix.OrthoLH(_form.ClientSize.Width, _form.ClientSize.Height, 0, 1));

I was just altering the coordinates I was drawing it at with Id3DDevice::Draw(). ><

But I recall some of this transformation stuff now, I have a feeling I made a thread on here a while back which involved those but was to do with rotations...

Anyway, in trying to look at how you're doing that particular line, I am unsure how you're doing 'TransformState.Projection'. It doesn't seem to be possible with D3DTRANSFORMSTATETYPE. And that's the required first argument for iD3DXDevice::SetTransform().

In addition I assume there's some specific function for filling the D3DTRANSFORMSTATETYPE struct, but I can't seem to find it. ><

I have altered my code to how I was using SetTransform() in the past. First I have a PrepareTransform() function:


void Renderer::PrepareTransform(int input)
{
transformStateType->Projection;
d3dXSprite->SetTransform(
D3DXMatrixTransformation2D(&d3dMatrix,
NULL,
0.0,
&D3DXVECTOR2(1.0,1.0),
&D3DXVECTOR2(texturesToRender[input].objectPointer->originPointer()->x,texturesToRender[input].objectPointer->originPointer()->y),
0.0f,
&D3DXVECTOR2(texturesToRender[input].objectPointer->coordinatesPointer()->x,texturesToRender[input].objectPointer->coordinatesPointer()->y));

d3dXSprite->SetTransform(&d3dMatrix);
}


Then I draw:


if(FAILED(hResult = d3dXSprite->Draw(*texturesToRender[i].objectPointer->texturePointer()->texturePointer(), NULL, NULL, NULL, 0xffffffff)))
{


Unfortunately the issue still exists, but I would assume this is because I'm not dealing with this projection matrix stuff you're mentioning.

### #1Interminable

Posted 14 July 2012 - 02:08 AM

This might help the issue.

http://msdn.microsof...0(v=vs.85).aspx

What the article describes sounds like it could be related to the issue I'm having.

The problem is, I'm not drawing a 2D texture to a surface. It's a standalone sprite. I'm unsure how I can deal with this.

Do you mean you are using the Sprite class?

What you need to do is shift your Projection Matrix to account for the issue. This is how i setup mine and it seems to work. I'm not a DX master by any means but give it a shot and see if it helps. My Coordinate system has 0,0 at the center of the screen and +Y is up.

Device.SetTransform(TransformState.Projection, Matrix.Translation(-0.5f, 0.5f, 0.0f) * Matrix.OrthoLH(_form.ClientSize.Width, _form.ClientSize.Height, 0, 1));

I was just altering the coordinates I was drawing it at with Id3DDevice::Draw(). ><

But I recall some of this transformation stuff now, I have a feeling I made a thread on here a while back which involved those but was to do with rotations...

Anyway, in trying to look at how you're doing that particular line, I am unsure how you're doing 'TransformState.Projection'. It doesn't seem to be possible with D3DTRANSFORMSTATETYPE. And that's the required first argument for iD3DXDevice::SetTransform().

In addition I assume there's some specific function for filling the D3DTRANSFORMSTATETYPE struct, but I can't seem to find it. ><

PARTNERS