VB.NET User Control overrides DirectX rendering

Started by
-1 comments, last by addy914 11 years, 10 months ago
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()
MyBase.New()
SetStyle(ControlStyles.UserPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.AllPaintingInWmPaint, True)
UpdateStyles()
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
MessageBox.Show("2")
DrawNewCharacterSprite()
MessageBox.Show("2.1")
End Sub
Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
MessageBox.Show("1")
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.

This topic is closed to new replies.

Advertisement