有directx的sample吗?除了donkey,framework sdk的.

解决方案 »

  1.   

      C#里面能用 opengl32.dll  吗?
      

  2.   

    public void FromImageImage(PaintEventArgs e) {
        // Create image.
        Image imageFile = new Bitmap(300, 200);
        
        // Create graphics object for alteration.
        Graphics newGraphics = Graphics.FromImage(imageFile);
        
        // Alter image.
        newGraphics.FillRectangle(new SolidBrush(Color.Black), 100, 50, 100, 100);
        
        // Draw image to screen.
        e.Graphics.DrawImage(imageFile, new PointF(0.0 F, 0.0 F));
        
        // Release graphics object.
        newGraphics.Dispose();
    }
    这就是GDI+中的double buffer。
      

  3.   

    至于DirectX,还是等DirectX 9.0中的Managed DirectX吧。
      

  4.   

    to westaf(西狂):
            谢谢你的回答。你有没有试过这种方法,不可取的。效果不比直接写两次屏好,同样有闪烁,而且如果全屏的话,速度其慢(相信是DrawImage效率太低)。GDI+让我失望!
            有DX9有关消息的连接吗?
      

  5.   

    闪烁是可以克服的,关键是不要让背景重绘。
    不过DrawImage的确很慢,因为它在做alphablending,而且不使用硬件!
      

  6.   

    private void button1_Click(object sender, System.EventArgs e)
    {
    Graphics g = Graphics.FromHwnd(Handle); // Create image.
    Image memImg = new Bitmap(ClientRectangle.Width, ClientRectangle.Height);
      
    // Create graphics object for alteration.
    Graphics memGraph = Graphics.FromImage(memImg); for(int i = 0; i < 100; i++)
    {
    // Alter image.
    memGraph.FillRectangle(new SolidBrush(Color.Black), 0, 0, 400, 600);
      
    memGraph.DrawString(i.ToString(), new Font("Varanda", 20), new SolidBrush(Color.Beige), 0,0);
    // Draw image to screen.
    g.DrawImageUnscaled(memImg, 0, 0);
    }
    }
      

  7.   

    注意如果你的form上有别的空间的话,这些控件是不会被覆盖掉的。
      

  8.   

    to westaf(西狂):
       我试了,效果似乎不错,其实是有闪烁的,只不过你做得不容易察觉。用你的方法,画个圆形在桌面弹来弹去,闪烁就明显了。
       不过给了我两点经验:
       第一图形简单,闪烁不容易察觉。
       第二写的速度快一点,闪烁可能反而不明显。例如用while(true)。
       谢谢!!
      

  9.   

    没有闪烁呀?我把代码改成这样,也察觉不出来的:
    memGraph.DrawString(i.ToString(), new Font("Varanda", 20), new SolidBrush(Color.Beige), i*3,i);不过DrawImage实在太慢了,在我的GF MX上最大化也只有20-30fps,看来只有等DX9了……