Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualEpicCupcakes

Posted 04 February 2013 - 07:49 PM

Edit: I apologize for the misleading post title. I mean to type "Innacurate Draw Positions in DX9".

 

Hello, all. I'm working on a simple project involving drawing a grid using the DirectX 9 API, and I've run into a problem where the position of shapes drawn to my window don't match up to the position my mouse is (supposedly) in. I'm using this code to retrieve my mouse position:

 

    POINT point;
    GetCursorPos(&point);
    ScreenToClient(givenhwnd, &point);

 

but when I draw a shape to any specific area, my mouse shows it as being about 10 pixels off in either direction. Strangely, this only happens the further away from the topleft corner of the window. This is making hit testing my grid hell. I'm not sure if my problem lies in my backbuffer size(1024x768), or in my inability of use AdjustWindowRect correctly (I'm sure I haven't), or whether I should use AdjustWindowRectEx instead, but any help that would be greatly appreciated.

 

Here are my AdjustWindowRectEx and CreateWindowEx calls.

	RECT rect = {0,0, gnBackBufferWidth, gnBackBufferHeight};
	AdjustWindowRectEx(&rect, GetWindowLong(m_hwnd, WS_OVERLAPPEDWINDOW), FALSE, NULL);

	    m_hwnd = CreateWindowEx (
           0,                  
           szClassName,       
           "Grid App",     
           WS_OVERLAPPEDWINDOW,
           CW_USEDEFAULT,      
           CW_USEDEFAULT,     
           rect.right,               
           rect.bottom,               
           HWND_DESKTOP,      
           NULL,             
           hThisInstance,      
           NULL               
           );

#1EpicCupcakes

Posted 04 February 2013 - 07:12 PM

Hello, all. I'm working on a simple project involving drawing a grid using the DirectX 9 API, and I've run into a problem where the position of shapes drawn to my window don't match up to the position my mouse is (supposedly) in. I'm using this code to retrieve my mouse position:

 

    POINT point;
    GetCursorPos(&point);
    ScreenToClient(givenhwnd, &point);

 

but when I draw a shape to any specific area, my mouse shows it as being about 10 pixels off in either direction. Strangely, this only happens the further away from the topleft corner of the window. This is making hit testing my grid hell. I'm not sure if my problem lies in my backbuffer size(1024x768), or in my inability of use AdjustWindowRect correctly (I'm sure I haven't), or whether I should use AdjustWindowRectEx instead, but any help that would be greatly appreciated.

 

Here are my AdjustWindowRectEx and CreateWindowEx calls.

	RECT rect = {0,0, gnBackBufferWidth, gnBackBufferHeight};
	AdjustWindowRectEx(&rect, GetWindowLong(m_hwnd, WS_OVERLAPPEDWINDOW), FALSE, NULL);

	    m_hwnd = CreateWindowEx (
           0,                  
           szClassName,       
           "Grid App",     
           WS_OVERLAPPEDWINDOW,
           CW_USEDEFAULT,      
           CW_USEDEFAULT,     
           rect.right,               
           rect.bottom,               
           HWND_DESKTOP,      
           NULL,             
           hThisInstance,      
           NULL               
           );

 


PARTNERS