Jump to content
  • Advertisement
Sign in to follow this  
lodoss118

2d game fullscreen and window

This topic is 3267 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

Hi i am having problems when running my game in fullscreen my scaling and bounding boxes are in different positions i.e. i have a bounding box class which draws a square depending on the width and height specified in window it draws the square fine but fullscreen it overlaps the line.

Share this post


Link to post
Share on other sites
Advertisement
What language? What OS? What graphics API? Can we get a screenshot (You can upload one to imageshack or a similar site, and then use HTML to link it here).

Assuming C++/Win32, when you create the window, do you call AdjustWindowRectEx to get the correct window size for the client area?

Share this post


Link to post
Share on other sites
Quote:
Original post by lodoss118
Hi i am having problems when running my game in fullscreen my scaling and bounding boxes are in different positions i.e. i have a bounding box class which draws a square depending on the width and height specified in window it draws the square fine but fullscreen it overlaps the line.


Need more information, what APIs are you using?

Share this post


Link to post
Share on other sites
I am using a direct 8 wrapper for example the createwindow is set to 1024/768
i have also two variables that sotre lastModeX = 1024 and lastModey = 768

in my scaling i am multiplying the scale i.e spriteScaleX * (GetMAxX()/lastModeX)

c++, oh yeah i suck at maths wippeeeeeeeee

Share this post


Link to post
Share on other sites
Quote:
Original post by lodoss118
I am using a direct 8 wrapper for example the createwindow is set to 1024/768
i have also two variables that sotre lastModeX = 1024 and lastModey = 768

in my scaling i am multiplying the scale i.e spriteScaleX * (GetMAxX()/lastModeX)

c++, oh yeah i suck at maths wippeeeeeeeee


Quote:
Original post by Evil Steve
Assuming C++/Win32, when you create the window, do you call AdjustWindowRectEx to get the correct window size for the client area?


CreateWindow takes a window size, not a client area size. Direct3D renders to the backbuffer, which is then copied to the client area. If the client area size doesn't match the backbuffer size, you'll get stretching and odd artifacts.
The correct way to handle this is to call AdjustWindowRectEx to find out the window size for the client area size you want (1024x768 in your case).

Share this post


Link to post
Share on other sites
hmm looking at my code i have this


//Create a WIN32 window: add +6 and + 26 to account for window borders
if(!DXUCreateWindow(hinstance, 0, 0, 1024+6, 760+26))
{
DXUUnloadDirectXGraphics();
DXUDisplayLastError();
return -1;
}

//Initialise Windowed Graphics:
//Note: Default Full Screen Mode is ( 1152x864x16 )
if(!DXUInitGraphics())
{
DXUUnloadDirectXGraphics();
DXUDisplayLastError();
return -1;
}





i am not sure how DXUCreateWindow works but how would i use AdjustWindowRectEx in this scenario on when creating the window or do i have update all my sprite rects :( sorry for being a noob

Share this post


Link to post
Share on other sites
Where are these DXU* functions defined? I can't find anything in the SDK about them, which makes me think you're using some code from a book or some other source.
If you go into DXUCreateWindow(), does it call AdjustWindowRect? In any case, adding random values to the width and height of the window to account for the window borders is very wrong; they can be different across OSs, and even across PCs (If the user uses different fonts for the UI for instance).

Share this post


Link to post
Share on other sites
Its a wrapper class



DXUAPI BOOL DXUCreateWindow(HINSTANCE hInst,int x,int y,int screenW,int screenH)
{
HWND hwnd;
WNDCLASS wc;

if (!dxuSystemInfo.isInitialised)
DXUSetWindowInfo("DXU-API","DXU-API",LoadIcon((HINSTANCE)dllInstance,(LPCTSTR)IDI_DXUICON));
else if (!dxuSystemInfo.hIcon)
dxuSystemInfo.hIcon = LoadIcon((HINSTANCE)dllInstance,(LPCTSTR)IDI_DXUICON);

wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = DXUDefaultWindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInst;
wc.hIcon = dxuSystemInfo.hIcon;
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
wc.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = dxuSystemInfo.menuName;
wc.lpszClassName = dxuSystemInfo.wndClassName;
RegisterClass( &wc );

hwnd = CreateWindowEx(0,
dxuSystemInfo.wndClassName,
dxuSystemInfo.wndName,
dxuSystemInfo.windowStyle,
x, y,
screenW,
screenH,
NULL,
NULL,
hInst,
NULL);

if ( !hwnd )
{
DXUSetLastError(DXUERR_NOHWND);
return FALSE;
}

dxuSystemInfo.hWnd = dxuSystemInfo.hWndFocus = hwnd;
dxuSystemInfo.hInst = hInst;
dxuSystemInfo.isActive = TRUE;
dxuSystemInfo.isCursor = TRUE;
dxuSystemInfo.isWindowed = TRUE;
dxuSystemInfo.windowW = screenW;
dxuSystemInfo.windowH = screenH;
// Save window properties
//dxuSystemInfo.windowStyle = GetWindowLong( hwnd, GWL_STYLE );
GetWindowRect( hwnd, &dxuSystemInfo.rcBounds );
GetClientRect( hwnd, &dxuSystemInfo.rcClient );

return TRUE;
}


Share this post


Link to post
Share on other sites
Well, you can see it doesn't call AdjustWindowRectEx, so you'll have to:

// Setup a RECT to describe the requested client area size
RECT rcClient;
rcClient.top = 0;
rcClient.left = 0;
rcClient.right = 1024; // Your client area width
rcClient.bottom = 768; // YOour client area height

// Adjust rcClient for the window borders, given the window style
AdjustWindowRectEx(&rcClient, CS_HREDRAW | CS_VREDRAW, FALSE, 0);

//Create a WIN32 window, using the size adjusted to include window borders
if(!DXUCreateWindow(hinstance, 0, 0, rcClient.right-rcClient.left, rcClient.bottom-rcClient.top))
/// Etc...

I'd also be a little wary of the code, given that the author doesn't seem to know what window styles he wants - The two given are useless for Direct3D, and he doesn't specify WS_OVERLAPPEDWINDOW or WS_POPUP, which is unusual (Although not incorrect).

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!