Sign in to follow this  
_Flecko

DirectX in a windows form component

Recommended Posts

_Flecko    196
I'm working on a Windows Forms program in C# that has to have a DirectX display in it. I wrote the component (draws using the regular OnIdle method) and added it to the form, but I'm having some weird issues with it I never experienced just rendering directly to the form: -The device's render state and transformation gets reset each frame. I literally have to redefine all of its render states before I start drawing or it just uses the defaults. -When I leave device.RenderState.lighting=true, the quad is just black, as expected. When I turn lighting off, it just doesn't render at all. I'm pretty new to Windows forms, so there's a pretty good chance I'm just doing something dumb. Anyone have any idea what might be up? Thanks, Max

Share this post


Link to post
Share on other sites
Zipster    2365
Quote:
The device's render state and transformation gets reset each frame. I literally have to redefine all of its render states before I start drawing or it just uses the defaults.

I'd suspect that the device is being lost each frame to the parent handle, or something along those lines. Put a breakpoint or message box inside your device reset event to see how often it fires.

Quote:
When I leave device.RenderState.lighting=true, the quad is just black, as expected. When I turn lighting off, it just doesn't render at all.

What vertex format are you're using? It sounds like PositionNormal.

Share this post


Link to post
Share on other sites
_Flecko    196
I resolved the reset issue. Apparently it only resets three times, and although frankly I have no idea when the later two occur or why, it seemed easy enough to put the render state setup in the OnReset event since it probably belongs there anyway.

I'm using PositionColoredTextured vertices. I still can't figure that problem out.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this