Jump to content
  • Advertisement
Sign in to follow this  
WuTz

Very very crazy problem :(

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
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.

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 :(

Please help! Maybe with some samplecode how to create a swapchian! Maybe I
did something wrong...

Share this post


Link to post
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 this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!