Sign in to follow this  
Virtual_Skippy

Strange Size Bug with DirectX 10?

Recommended Posts

Is anyone else experiencing the problem were the form size or object sizes aren't what you punched into your code? I'm making a pong game with Direct3D with DirectX 10, setting my backbuffer size to 800 x 600 in the OnLoad override function. But I'm noticing when I position my Sprites and bound them to the screen size the boundaries are slightly off screen. Instead of this: this.Size = new Size(SCREEN_WIDTH, SCREEN_HEIGHT); //set to 800 x 600 I've ended up with this: this.Size = new Size(SCREEN_WIDTH + 15, SCREEN_HEIGHT + 35); bizarre. And I've also made a custom font from a bitmap that has each number 45 intervals apart, but I'm having to count 52 intervals to load the font properly. Weird? Anyone else experienced this, and suggest a solution? Edit: sorry not backbuffer. Years of DirectDraw development still occupy my brain lol. I meant just the general size

Share this post


Link to post
Share on other sites
Hi, I believe the problem is due to the adornments (window border thickness etc.). The way I solve this is to use the AdjustWindowRect call like so:

// adjust to client size
RECT rc;
SetRect( &rc, 0, 0, requiredWidth, requiredHeight );
AdjustWindowRectEx( &rc, windowstyle,false,0);

the windowStlye should be set to the flags you use when creating the window e.g.

DWORD kWindowstyleWindowed = WS_OVERLAPPED | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU

the resultant rc is now adjusted so that the client area will be requiredWidth by requiredHeight and so you use this in youir call to CreateWindow

With the second problem is it possible that your texture is being stretched to a power of 2 dimension on load?

Share this post


Link to post
Share on other sites
I'm going to guess that DX10 doesn't stretch the backbuffer to fit the window, like DX9 does.

When you ask for a 800x600 window, you're getting a 800x600 window. The client area (Window area minus the title bar and window borders) will be something like 792x552, but your backbuffer will still be created as 800x600.
You want to use AdjustWindowRectEx to get the appropriate window size for the given client area size.

Share this post


Link to post
Share on other sites
Disappointingly making the size of the texture a power of two made no difference. Any other ideas folks?

As for the screen size I managed to resolve the issue with this equivalent code;

this.SetClientSizeCore(SCREEN_WIDTH, SCREEN_HEIGHT);

Sorry for not explaining I was using C#!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this