Sign in to follow this  

VB.NET User Control overrides DirectX rendering

Recommended Posts

addy914    158
Hello, the title isn't the most specific but here's an overview of what I meant. I have a UserControl that I am going to render DirectX to. It is going to be a character preview for this game I am creating. The problem is that whenever OnPaint is called, I will render the texture onto it, and then at the end, it turns the control back to the backcolor. I have even disabled OnPaintBackground. It is really confusing for me, and any help would be great. I actually saw a topic very similar to this and there was one suggestion that it was SharpDX/SlimDX's fault.

Partial Public Class TestPictureBox : Inherits UserControl
Public Sub New()
SetStyle(ControlStyles.UserPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.AllPaintingInWmPaint, True)
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
End Sub
Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
End Sub
End Class

DrawNewCharacterSprite renders the DirectX texture, and it does fine, it just gets overriden by User Control.
Here's what happens when I run it:
1, 2, Character Drawn, 2.1, Back to back color, 1, 2, Character Drawn, 2.1, Back to back color.
If I use e.Graphics.Draw___ then it is fine and it will render it completely, but it does not pay attention to DirectX.

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