Jump to content

  • Log In with Google      Sign In   
  • Create Account

How do you change back buffer width/height in D3D9?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 Muzzy A   Members   -  Reputation: 638

Like
0Likes
Like

Posted 26 October 2012 - 03:10 AM

by default, the projection to the screen is from -1 to 1 on x and y axis, but i want to change it a little bit, is there a way to do that?

Sponsor:

#2 mhagain   Crossbones+   -  Reputation: 7960

Like
0Likes
Like

Posted 26 October 2012 - 03:49 AM

Generally just loading (or multiplying by) an ortho matrix is sufficient, but is there something else you have in mind? You sound as though you want to do this for some specific reason, but you're not saying what that reason is - there may be a more appropriate answer that better meets your underlying need but doesn't involve changing this projection.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#3 Muzzy A   Members   -  Reputation: 638

Like
0Likes
Like

Posted 26 October 2012 - 04:06 AM

i set up a sprite manager, like D3D9'S ID3DXSprite,sorta, and it creates geometry based on the resolution of the texture.

Works fine if the window width and height are the same.

When they aren't the same, upon rotating the image it gets skewed, or stretched/squished, depending on the resolution of the window

I want to fix this by setting the projection based on the aspect ratio of the window.

#4 Bacterius   Crossbones+   -  Reputation: 8836

Like
0Likes
Like

Posted 26 October 2012 - 06:59 AM

Doesn't the projection matrix helper function have an aspect ratio parameter? Like D3DXMatrixPerspectiveFovLH? Or can't you use that?

The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis


#5 Muzzy A   Members   -  Reputation: 638

Like
0Likes
Like

Posted 26 October 2012 - 05:31 PM

i'm not using a projection matrix, and when i do, my sprites disappear

#6 mhagain   Crossbones+   -  Reputation: 7960

Like
1Likes
Like

Posted 26 October 2012 - 05:47 PM

An ortho matrix will do it.

If you want to keep the -dimension to +dimension scale then use D3DXMatrixOrtho(LH|RH); if you want a 0 to dimension scale use D3DXMatrixOrthoOffCenter(LH|RH).

So, some examples.

D3DXMatrixOrthoLH (&matrix, 2, 2, 0, 1) will preserve to -1 to 1 range in each axis (because the first two params are the size of the view volume, and -1 to 1 is size 2).
D3DXMatrixOrthoLH (&matrix, 4, 4, 0, 1) will bring it to a -2 to 2 range.

Sometimes more usefully, D3DXMatrixOrthoOffCenterLH (&matrix, 0, windowwidth, windowheight, 0, 0, 1) will give you a range that's from 0 to the dimension of your window in each axis, meaning that you can use window co-ordinates for positioning objects. So if you need to draw an object at position (200, 300) that's size 24x24, you just draw it at position (200, 300) at size 24x24 and that's exactly what you get.

Interesting fact.

There is absolutely nothing to stop you from multiplying a perspective matrix by an ortho matrix. If you want to extend the range a little, just do that.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#7 Muzzy A   Members   -  Reputation: 638

Like
0Likes
Like

Posted 27 October 2012 - 11:12 AM

and you just multiply that into the worldMatrix, just like a cam and projection matrix? if so it's still making my sprite disappear =(

Edited by Muzzy A, 27 October 2012 - 11:12 AM.


#8 mhagain   Crossbones+   -  Reputation: 7960

Like
0Likes
Like

Posted 27 October 2012 - 11:30 AM

You're going to need to post some code and give a fuller description of what you're currently doing before I can help any further here.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#9 Muzzy A   Members   -  Reputation: 638

Like
0Likes
Like

Posted 27 October 2012 - 01:56 PM

D3DXMATRIX ortho;
D3DXMatrixOrthoLH(&ortho,2,(wndWidth/wndHeight)*2,0,1);

// Render the sprite
shader->SetMatrix("gWorld",&(worldMatrix*ortho);

// Vertex shader
output.position = mul(float4(position,1),gWorld);

// Correct no? take out the "worldMatrix*ortho" and have just "worldMatrix" and the sprite shows up
// with the ortho in there, it disappears.

EDIT: nvm, i got it. thanks

Edited by Muzzy A, 27 October 2012 - 06:11 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS