Jump to content

  • Log In with Google      Sign In   
  • Create Account


VB.NET User Control overrides DirectX rendering


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 addy914   Members   -  Reputation: 158

Like
0Likes
Like

Posted 21 June 2012 - 09:35 AM

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.

Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS