Very very crazy problem :(

Started by
21 comments, last by WuTz 14 years, 2 months ago
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?
Advertisement
Check your projection matrix.
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.
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...
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.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

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.
Whoa that's your engine? Looks sick!!
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 :(

Please help! Maybe with some samplecode how to create a swapchian! Maybe I
did something wrong...
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
:( Havn't found anything bad in my code :(:(:(

fu**!
Try printing out the aspect ratio passed to your projection matrix - the bug you're seeing is almost definitely caused by using the wrong aspect ratio - E.g. Using the aspect ratio of the left viewport in the right viewport.

This topic is closed to new replies.

Advertisement