• 13
• 15
• 19
• 27
• 9

# Very very crazy problem :(

This topic is 2949 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello! I have a big problem with my engine, and I can't go on, if I don't fix it. :( I made two screenshots of it: http://i47.tinypic.com/6rpkkj.jpg and for a very extrem example: http://i47.tinypic.com/6xyoie.jpg As you see, the contents of the right viewport (Swapchain) are resized with the main viewport. Any Ideas why?? I don't know :( What code do you may need to help me?

##### Share on other sites
If you're using for example the D3DXMatrixPerspectiveFovLH function to create the projection matrix, there's "Aspect" parameter which can be responsible for this behaviour when not set correctly.

##### Share on other sites
I create the Proj matrix every frame. For debugging.
This is the function:

void DXSubWindows::OnResizedChain(){	D3D10_TEXTURE2D_DESC BackBufferDesc;	BackBuffer->GetDesc(&BackBufferDesc);		float fAspect = static_cast<float>(BackBufferDesc.Width ) / static_cast<float>( BackBufferDesc.Height );	D3DXMatrixPerspectiveFovLH( &Proj, FOV , fAspect, 0.5f, 1000.0f );  }

(How do I made those codeboxes???)

This is the rendereing code:

D3DXVECTOR3 OldLoc;	D3DXVECTOR3 OldRot;	WActor* A=(WActor *)PreviewActor;	OldLoc=A->Location;	OldRot=A->Rotation;	A->bContentMarkMode=false;	A->SetLocation(D3DXVECTOR3(-11,9,50));	A->SetRotation(D3DXVECTOR3(timeGetTime()*0.001,0,0));	//PreviewActor->SetLocation(TheScene->CurCam->Location);	SetMatrices(A);	A->PreRenderContentMark();	A->Render();	ResetMatrices(A);

The Func "SetMatrices()" sets the proj matrix into the Actor.
"PreRenderContentMark()" passes them to the mesh:

void WActor::PreRenderContentMark(){	Foreach(Components,WComponent *)		(*Out)->View=ViewMatrix;		(*Out)->Proj=ProjMatrix;		(*Out)->PreRenderContentMark();			FE_End}

They are passed to the shader here:

void WMesh::PreRenderContentMark(){	ForeachV(MyMesh.Materials,WShader *,Out)		CheckNULL((*Out)->ViewVariable)CheckNULL(View)(*Out)->ViewVariable->SetMatrix( ( float* )View );		CheckNULL((*Out)->ProjectionVariable)CheckNULL(Projection)(*Out)->ProjectionVariable->SetMatrix( ( float* )Projection );		CheckNULL((*Out)->TimeVariable)(*Out)->TimeVariable->SetFloat(DXUTGetTime());		FE_End}

And as you see, the Tree-Mesh at the seconf picture is scaled to the left/Right
AspectRation can't do that, right?

Maybe you have some codesamples for me, which show how to create a swapchain right...

##### Share on other sites
To perhaps clarity what Tom KQT said: Do you set the viewport and projection matrix for each view you render? The viewport and proj matrix will not be the same for the two views.

##### Share on other sites
Yes, of course!
The code I posted was from the Problem-Viewport at the right side. You can see
how the Proj matrix is passed to the shader.

And I checked the adresses, when the matrices get set to the shader.
They are all passed right.

I'm gonna despair of that crap :(
Is there any other solution for a second viewport than a swap chain?

Oh, and: I can draw text on the right viewport. Without any problems...
And: I tried already to NOT set the new proj matrix, and to leave the old one.
Then, nothing is drawn/Outside the screen. So, what could it be?

EDIT: Ah. What do you mean with "Do you set the [[[[viewport]]] and projection matrix for each view you render?"

Viewport matrix? Or what? View-Matrix? Jup, I set it.

##### Share on other sites
Whoa that's your engine? Looks sick!!

##### Share on other sites
Yeah, thanks! :)
Here is a link to our ModDB page:

http://www.moddb.com/engines/wtech/news/wtech-completely-rewritten

I linked directly to the interrestin stuff, because
currently it is full of the crap of my first try.
Read the newspage and you will know, WHY I had to make it "sick". :)

It is VERY important, that we can fix that problem, because all development had
to stop because of this. :(

Well not all, but I can't make anything big anymore :(

did something wrong...

##### Share on other sites
here's a link for a DX9 swap chains tutorial, I guess the application is almost the same in DX10. http://www.codesampler.com/dx9src/dx9src_1.htm#dx9_swap_chains

##### Share on other sites
:( Havn't found anything bad in my code :(:(:(

fu**!