Dx user control

Started by
5 comments, last by remigius 18 years, 7 months ago
hi.. i am currently writing a dx user control. I get a DriverInternalErrorException when i try to minimize the window application that is using the control. I hit the error when running base.OnResize. Can someone please shed some light. Thanks in advance
Advertisement
Quote:Internal driver error. Applications should generally shut down when receiving this error.

It seems you are doing something that DX or the driver really does not like. Can you get around the problem by doing the same thing in a different way? Otherwise post some code relevant to the error.
Hack my projects! Oh Yeah! Use an SVN client to check them out.BlockStacker
protected override void OnResize(EventArgs e)
{

base.OnResize (e);

if(null != renderer)
renderer.ChangeSize();
}

Since its a user control, i presume that its size might change either during design time or if its size is changed using codes. I need to resize the renderer so that it reflect the higher or lower resolution (instead of strecthing, i actually resize them as if changing resolution in game). And also recreate all my resources since stuff that is in video memory will be lost during this resizing. Things works well until i minimized it

When i minimized the program that uses it, this function is called too. (because its being resize until its as small as a title bar like in mdi form?) i did do a width height equal 0 check before resizing but the an exception is thrown before the execution reaches my code. Its in the base.OnResize(e) that cause it to happen
I'm just guessing mind you, but maybe the renderer breaks when the size of the control it's rendering to is set to 0,0 (which probably happens in base.OnResize(e) when minimizing). Try checking the resize bounds before calling base.OnResize(e) and disable the renderer when this is the case.
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!
protected override void OnResize(EventArgs e)
{
if (base.ParentForm != null && base.ParentForm.WindowState == FormWindowState.Minimized)
{
return;
}

base.OnResize (e);

if(null != renderer)
renderer.ChangeSize();
}

I put a checking for minimize state just to try it out and i got the same error right after the return statement. has anyone code a user control using dx before?
Anwyay i have already found a solution.

protected override void OnResize(EventArgs e)
{
if (base.ParentForm != null && base.ParentForm.WindowState == FormWindowState.Minimized)
{
renderer.Dispose();

return;
}

base.OnResize (e);

if(null != renderer)
renderer.ChangeSize();
}

when a minimized is detected, i just dispose my device (renderer is just a wrapper to it) and return. When the windows is being restore, renderer.ChangeSize() will handle the recreation.

Thanks for the feedback.
Good to see you got it to work kayX. I created a simple DirectX user control myself a while ago, but up until now I never minimized the window :) It turned out I had the same problem you had, so thanks for sharing the solution!
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!

This topic is closed to new replies.

Advertisement