locked
using directx in a panel RRS feed

  • Question

  • Hi all,

    I am trying to do the drawing part of a control with DirectX (instead of GDI+).

    This works fine if I create my own paint eventhandler for a form. The code looks like:

    private void Form1_Paint(object sender, PaintEventArgs e)

    {

    // code to do the directx drawing *here*

    this.Invalidate();

    }

    If I use the paint eventhandler of a panel it doesn't work

    I use a code like:

    private void panel1_Paint(object sender, PaintEventArgs e)

    {

    // code to do the directx drawing *here*

    this.panel1.Invalidate();

    }

    It seems that the "this.panel1.Invalidate();" isn't enough to make the operating system redraw the panel (?). If I use "this.Invalidate();" in the second example it works for the panel - but messes up the rest of the form because of the paint-invalidate-endless-loop.

    Any hint? Please?

    Or any hint where to start looking on the web?

    Thanks in advance

    Martin

     

    Thursday, January 12, 2006 10:41 PM

Answers

  • Hi,

    I was using a loop (not the Paint event) to render a scene in a panel.

    while(app.IsRunning())
    {
        app.Render();
    }

    and in the Render method I'd draw the scene and it updates the scene inside the panel. I'm not using paint event at all.
    Friday, January 13, 2006 12:37 AM

All replies

  • Hi,

    I was using a loop (not the Paint event) to render a scene in a panel.

    while(app.IsRunning())
    {
        app.Render();
    }

    and in the Render method I'd draw the scene and it updates the scene inside the panel. I'm not using paint event at all.
    Friday, January 13, 2006 12:37 AM
  • Thanks for the hint! :)

    I did it like this:

    static void Main()

    {

    using (Form1 myform = new Form1())

    {

    Application.EnableVisualStyles();

    myform.Show();

    while (myform.Created)

    {

    myform.panel1render();

    myform.panel2render();

    Application.DoEvents();

    }

    }

    }

    That is according to DirectX-sources "old style" but it seems you have to do it that way so Windows still gets enough information to handle the rest of the application.

     

    Saturday, January 14, 2006 11:56 AM