DirectX in a windows form component

Started by
1 comment, last by _Flecko 19 years, 9 months ago
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
--------------Trans2D - 2D library for C# / Managed DirectX
Advertisement
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.
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.
--------------Trans2D - 2D library for C# / Managed DirectX

This topic is closed to new replies.

Advertisement