Sign in to follow this  
Farry

New in Gaming

Recommended Posts

Hi, I am new to gaming but having a lots of experience with programing. I am using DirectX 9 and C# for Game Programing n i m unable to Draw a box into 3D space can any body help me that how can i draw. [I've initalized the graphics] using System; using System.Drawing; using System.Windows.Forms; using Microsoft.DirectX; using Microsoft.DirectX.Direct3D; namespace firstApplication { public partial class boxModeling : Form { Device device = null; public boxModeling() { //InitializeComponent(); this.ClientSize = new System.Drawing.Size(800, 600); this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.FormBorderstyle = System.Windows.Forms.FormBorderstyle.None; } public bool initializeGraphics() { try { PresentParameters presentParams = new PresentParameters(); presentParams.Windowed = true; presentParams.SwapEffect = SwapEffect.Discard; device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams); return true; } catch (DirectXException) { return false; } } private void Render() { if (device == null) return; device.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 0.1f, 0); device.BeginScene(); device.EndScene(); device.Present(); } protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { this.Render(); } protected override void OnKeyPress(System.Windows.Forms.KeyPressEventArgs e) { if ((int)(byte)e.KeyChar == (int)System.Windows.Forms.Keys.Escape) this.Close(); } static void Main() { using (boxModeling frm = new boxModeling()) { if (!frm.initializeGraphics()) { MessageBox.Show("Could't Initialize 3D Graphics"); return; } frm.Show(); while (frm.Created) { frm.Render(); Application.DoEvents(); } } } } } [Edited by - Farry on October 7, 2006 4:10:34 AM]

Share this post


Link to post
Share on other sites
Welcome to GameDev.net! I'm not very experienced with DX or D3D, but I can tell you that when you post code in the forum, if you do it between tags of [ source ][ /source ] (but without the extra spaces), it will be much neater like this:

using System;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;

namespace firstApplication
{
public partial class boxModeling : Form
{
Device device = null;

public boxModeling()
{
//InitializeComponent();
this.ClientSize = new System.Drawing.Size(800, 600);
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.FormBorderstyle = System.Windows.Forms.FormBorderstyle.None;
}

public bool initializeGraphics()
{
try
{
PresentParameters presentParams = new PresentParameters();
presentParams.Windowed = true;
presentParams.SwapEffect = SwapEffect.Discard;
device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams);

return true;
}
catch (DirectXException)
{
return false;
}
}

private void Render()
{
if (device == null)
return;

device.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 0.1f, 0);
device.BeginScene();
device.EndScene();
device.Present();
}

protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
this.Render();
}

protected override void OnKeyPress(System.Windows.Forms.KeyPressEventArgs e)
{
if ((int)(byte)e.KeyChar == (int)System.Windows.Forms.Keys.Escape)
this.Close();
}

static void Main()
{
using (boxModeling frm = new boxModeling())
{
if (!frm.initializeGraphics())
{
MessageBox.Show("Could't Initialize 3D Graphics");
return;
}
frm.Show();

while (frm.Created)
{
frm.Render();
Application.DoEvents();
}
}
}
}
}




If you click the "edit" button above your post, you can add those tags to make it easier for other people to read your code.

Good luck!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this