by Lars-Inge » Sun, 19 Dec 2004 06:20:21
gt; I'd love to be shown
Here is something I just wrote for you:
Add a reference to "Microsoft.DirectX" and "Microsoft.DirextX.Direct3D"
( I would recomend C# or VB.net for managed DirectX. )
A J# example to get you started:
import System.Drawing.*;
import System.Collections.*;
import System.ComponentModel.*;
import System.Windows.Forms.*;
import System.Data.*;
public class Form1 extends System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private Microsoft.DirectX.Direct3D.Device dev = null;
private System.Windows.Forms.Panel panel1;
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
this.SetUp();
}
/**
* Setup the DirectX environment.
*/
private void SetUp()
{
Microsoft.DirectX.Direct3D.PresentParameters[] pParams = new
Microsoft.DirectX.Direct3D.PresentParameters[1];
pParams[0] = new Microsoft.DirectX.Direct3D.PresentParameters();
// The DirectX frame will be shown in a window.
pParams[0].set_Windowed( true );
pParams[0].set_SwapEffect(
Microsoft.DirectX.Direct3D.SwapEffect.Discard );
// Setup the display device. We are using software for processing Vertexes
since
// I don't know what your gfx card supports.
dev = new Microsoft.DirectX.Direct3D.Device( 0,
Microsoft.DirectX.Direct3D.DeviceType.Hardware,
this.panel1.get_Handle(),
Microsoft.DirectX.Direct3D.CreateFlags.SoftwareVertexProcessing,
pParams);
}
protected void Dispose(boolean disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
super.Dispose(disposing);
}
#region Windows Form Designer generated code
/**
* Required method for Designer support - do not modify
* the contents of this method with the code editor.
*/
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.SuspendLayout();
//
// button1
//
this.button1.set_Location(new System.Drawing.Point(96, 352));
this.button1.set_Name("button1");
this.button1.set_TabIndex(1);
this.button1.set_Text("button1");
this.button1.add_Click( new System.EventHandler(this.button1_Click) );
//
// panel1
//
this.panel1.set_Location(new System.Drawing.Point(8, 32));
this.panel1.set_Name("panel1");
this.panel1.set_Size(new System.Drawing.Size(328, 280));
this.panel1.set_TabIndex(2);
//
// Form1
//
this.set_AutoScaleBaseSize(new System.Drawing.Size(5, 13));
this.set_ClientSize(new System.Drawing.Size(352, 430));
this.get_Controls().Add(this.panel1);
this.get_Controls().Add(this.button1);
this.set_Name("Form1");
this.set_Text("Form1");
this.ResumeLayout(false);
}
#endregion
/**
* The main entry point for the application.
*/
/** @attribute System.STAThread() */
public static void main(String[] args)
{
Application.Run(new Form1());
}
private void button1_Click (Object sender, System.EventArgs e)
{
// Clear the directX surface with the Aqua color.
this.dev.Clear( Microsoft.DirectX.Direct3D.ClearFlags.Target,
System.Drawing.Color.get_Aqua(), 1.0f, 0);
// Presents the buffer.
dev.Present();
}
}
And here is a J# DirextX sound article I have written.
http://www.codeproject.com/dotnet/DirectSoundJsharp.asp
Regards,
Lars-Inge Tnessen