Witam,
chciałbym w swojej aplikacji (projekt na uczelnię) mieć kontrolkę, za pomocą której będę ładnie wyświetlał wykresy w 3D.
Korzystając z tutoriali dostępnych w necie wyskrobałem już coś takiego:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
namespace gk3
{
class Plot3D : PictureBox
{
public Color background = Color.DarkSlateBlue;
private Device device;
private float angle = 0f;
public Plot3D()
{
this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);
this.InitializeDevice();
}
public void InitializeDevice()
{
PresentParameters presentParams = new PresentParameters();
presentParams.Windowed = true;
presentParams.SwapEffect = SwapEffect.Discard;
device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams);
}
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
device.Clear(ClearFlags.Target, background, 1.0f, 0);
device.Present();
this.Invalidate();
}
}
}
Tyle, że jak dodam tę kontrolkę do forma to strasznie mryga (na przemian kolor tła (ciemno-niebieski) i czarny).
Ustawiłem w formie DoubleBuffered na true.
W czym leży problem?