Jump to content
  • Advertisement
Sign in to follow this  
exextatic

Issues with rendering into a splitcontainer

This topic is 2526 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 all,

Just trying to make an editor for my game. Im aiming to have directx render into a Split Container (C++ forms). I've managed to have it render into a picturebox, but moving it onto a split container panel has proved problematic. I also have an issue with some of the controls on the form rendering incorrectly (I've got a feeling its related to the directx renderer..?). Anyways, pictures will describe better:
dx_forms_error_1.PNG

And what it should look like (according to visual studio):
dx_forms_error_2.PNG

The DX renderer is initialized like this:
Form1(HINSTANCE hInstance)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//

WNDCLASSEX wc;
ZeroMemory(&wc, sizeof(WNDCLASSEX));

wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.hbrBackground = NULL;
wc.lpszClassName = L"WindowClass";

RegisterClassEx(&wc);

hWnd = CreateWindowEx(NULL, L"WindowClass", NULL, WS_CHILD,
this->splitContainer3->Panel1->ClientRectangle.X, this->splitContainer3->Panel1->ClientRectangle.Y,
this->splitContainer3->Panel1->Width, this->splitContainer3->Panel1->Height,
(HWND)this->splitContainer3->Panel1->Handle.ToPointer(),
NULL,
hInstance,
NULL);

if(hWnd == NULL)
MessageBoxA(NULL, "Error in HWND!", "ERROR", MB_OK | MB_ICONEXCLAMATION);

ShowWindow(hWnd, SW_SHOW);

directxHandle = new DXHandler((HWND)this->splitContainer3->Panel1->Handle.ToPointer(), this->splitContainer3->Panel1->Size.Height, this->splitContainer3->Panel1->Size.Width);
HInstance = hInstance;
}


Thanks,
James Warner

Share this post


Link to post
Share on other sites
Advertisement
You seem to be creating a new window, but then attaching your DXHandler class to the Panel's window rather than your new window.

Share this post


Link to post
Share on other sites

You seem to be creating a new window, but then attaching your DXHandler class to the Panel's window rather than your new window.

Changing the initialiser to:
directxHandle = new DXHandler(hWnd, this->splitContainer3->Panel1->Size.Height, this->splitContainer3->Panel1->Size.Width);
Causes it to render into the whole panel, but when I got to resize it, the DX window doesnt resize.
dx_forms_error_3.PNG

Edit: Adding some code:
System::Void splitContainer3_Panel1_Resize(System::Object^ sender, System::EventArgs^ e)
{
if(directxHandle != NULL && directxHandle->getDevice() != NULL)
{
directxHandle->invalidateDeviceObjects();
directxHandle->updateBackBuffer(splitContainer3->Panel1->Width, splitContainer3->Panel1->Height);
directxHandle->restoreDeviceObjects();
}
}

And updateBackBuffer():
d3dpp.BackBufferWidth = LOWORD(lParam);
screenSize.x = LOWORD(lParam);
d3dpp.BackBufferHeight = HIWORD(lParam);
screenSize.y = HIWORD(lParam);

HRESULT hr = d3ddev->Reset(&d3dpp);

if(hr == D3DERR_INVALIDCALL)
{
MessageBox(NULL, L"Call to Reset() failed with D3DERR_INVALIDCALL! ",
L"ERROR", MB_OK | MB_ICONEXCLAMATION);
}

Share this post


Link to post
Share on other sites
You dont have to create a new window to render into it. Just passing the panels HWND to the device constructor should be enough.


directxHandle = new DXHandler(static_cast<HWND>(this->splitContainer3->Panel1->Handle.ToPointer()), this->splitContainer3->Panel1->Size.Height, this->splitContainer3->Panel1->Size.Width);

Share this post


Link to post
Share on other sites

You dont have to create a new window to render into it. Just passing the panels HWND to the device constructor should be enough.


directxHandle = new DXHandler(static_cast<HWND>(this->splitContainer3->Panel1->Handle.ToPointer()), this->splitContainer3->Panel1->Size.Height, this->splitContainer3->Panel1->Size.Width);


Ok tried that, it seems to stop WM_PAINT being passed to windowproc (and in turn, stops rendering). When I resized the frame, it disappeared entirely (might also be related to WM_PAINT not being passed)

Share this post


Link to post
Share on other sites
Try to Invalidate() or Refresh() the panel. Make sure proper rendering works before you move to resizing, since this will pose a heap of new issues that need to be solved.

Share this post


Link to post
Share on other sites

Try to Invalidate() or Refresh() the panel. Make sure proper rendering works before you move to resizing, since this will pose a heap of new issues that need to be solved.

Iv managed to get it to render onto the panel with the help from MJP, but the only issue now is re-sizing the actual render (I would say backbuffer but im not sure thats the actual term).

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!