Jump to content
  • Advertisement
Sign in to follow this  
kayX

Dx user control

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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!

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!