Original Post
Hi guys, I've the following files: CreateDevice.cs Vertex.cs CreateDevice.cs ----------------------------------
class CreateDevice : Form
...
PresentParameters presentParams = new PresentParameters();
presentParams.Windowed = true;
presentParams.SwapEffect = SwapEffect.Discard;
m_xRenderDevice = new Device (0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams);
...
public virtual void Render ()
{
if (m_xRenderDevice == null)
return;
// Clear the backbuffer to a blue color
m_xRenderDevice.Clear (ClearFlags.Target, System.Drawing.Color.Black, 1.0f, 0);
// Begin the scene
m_xRenderDevice.BeginScene();
//End the scene
m_xRenderDevice.EndScene();
m_xRenderDevice.Present();
Vertex.cs ----------------------------------
Class Vertex : CreateDevice
{
...
public Vertex ()
{
m_xCreateDevice = new CreateDevice ();
}
public bool InitGraphics ()
{
if (m_xCreateDevice.InitializeGraphics ())
{
m_xRenderDevice = m_xCreateDevice.RenderDevice;
OnCreateDevice (m_xRenderDevice, null);
return true;
}
return false;
}
public override void Render ()
{
if (m_xRenderDevice == null)
return;
// Clear the backbuffer to a blue color
m_xRenderDevice.Clear (ClearFlags.Target, System.Drawing.Color.Black, 1.0f, 0);
// Begin the scene
m_xRenderDevice.BeginScene ();
m_xRenderDevice.SetStreamSource (0, m_xVertexBuffer, 0);
m_xRenderDevice.VertexFormat = CustomVertex.TransformedColored.Format;
m_xRenderDevice.DrawPrimitives (PrimitiveType.TriangleList, 0, 1);
//End the scene
m_xRenderDevice.EndScene ();
m_xRenderDevice.Present ();
}
If I write the code of Vertex.cs in CreateDevice.cs I make a beautiful triangle otherwise if I leave the code of Vertex.cs in this file the Form is not Rendered... Does anyone know why? tnx Here you can find the project in VS 2003 http://it.geocities.com/salvodifazio/littlEngine.zip