Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    97
  • comments
    112
  • views
    86699

About this blog

Ramblings of programmyness, tech, and other crap.

Entries in this blog

 

Framework should be good to go...

Well the D3DApp framework appears to be totally ported at this point. Font stretch bug is fixed. I just last night fixed a bug that was causing the timer to occasionally hang up temporarily on resizing. This was due to the fact that I was not properly handling window states. A few boolean flags latter and it appears as if the bug is squashed. I also went ahead and implemented IDisposable. This was a suggestion in one of the comments from a previous entry. I feel this is the better way to go and will make deriving from the class safer.

It definitely feels good to be away from C++. I still find my self trying to get out of the ruts the language put me in. When using C++ we all know there are certain things you do a certain way for a good reason. In C# things are done differently and take a whole new mind set. C# for sure seems to push better programming practices on the developer. With C++ it is always finding the right workaround in C# I only encountered one workaround I needed and that was to handle window states. C# does not expose a Restore event for the window. So you need to keep track of whether or not the window was previously minimized or maximized so you can properly Reset your DirectX Views and SwapChain to new sizes.

Even with my positive experience thus far I find my self wanting to fall back to C++. It grew on me almost like a child. I could write C++ code as fast as a lot of people can write C#, Python, or even Java. That comes with experience.

Overall I am very pleased with C# it is like a fresh breeze in the air. Will I go back to C++... Not sure lets give C# some time I am sure it will grow on me.

Before I forget CODE:

using System;
using System.Drawing;
using System.Windows.Forms;
using SlimDX;
using D3D10 = SlimDX.Direct3D10;
using DXGI = SlimDX.DXGI;
using SlimDX.Windows;
using System.Text;

namespace InitDirect3D
{
class D3DApp : IDisposable
{
protected RenderForm m_Window;
protected D3D10.Device m_D3DDevice;
protected DXGI.SwapChain m_SwapChain;
protected D3D10.RenderTargetView m_RenderTargetView;
protected D3D10.DepthStencilView m_DepthStencilView;
protected D3D10.Texture2D m_DepthStencilBuffer;
protected D3D10.Font m_Font;
protected int m_VSync;
protected bool m_AppPaused;

protected string m_FrameStats;

protected GameTimer m_Timer;

private int frameCnt;
private float t_base;
private bool minimized;
private bool maximized;

public D3DApp()
{
m_Window = null;
m_D3DDevice = null;
m_SwapChain = null;
m_RenderTargetView = null;
m_DepthStencilView = null;
m_DepthStencilBuffer = null;
m_Font = null;
m_VSync = 0;
m_FrameStats = "";
m_AppPaused = false;

minimized = false;
maximized = false;
frameCnt = 0;
t_base = 0.0f;
}

~D3DApp()
{
Dispose(false);
}

public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}

protected virtual void Dispose(bool disposing)
{
if (disposing)
{
// release managed resources
m_Window.Dispose();
}

// Release unmanaged resources
m_D3DDevice.ClearState();
m_RenderTargetView.Dispose();
m_DepthStencilView.Dispose();
m_DepthStencilBuffer.Dispose();
m_D3DDevice.Dispose();
m_SwapChain.Dispose();
m_Font.Dispose();
}

public virtual void Initialize(string windowCaption)
{
m_Window = new RenderForm(windowCaption);

m_Timer = new GameTimer();

// This sets up the SwapChain's Mode Description
DXGI.ModeDescription modeDesc = new DXGI.ModeDescription()
{
Width = m_Window.ClientSize.Width,
Height = m_Window.ClientSize.Height,
RefreshRate = new Rational(60, 1),
Format = DXGI.Format.R8G8B8A8_UNorm,
ScanlineOrdering = DXGI.DisplayModeScanlineOrdering.Unspecified,
Scaling = DXGI.DisplayModeScaling.Unspecified
};

// Setup the SwapChain and Device
DXGI.SwapChainDescription swapDesc = new DXGI.SwapChainDescription()
{
BufferCount = 1,
ModeDescription = modeDesc,
IsWindowed = true,
OutputHandle = m_Window.Handle,
SampleDescription = new DXGI.SampleDescription(1, 0),
Usage = DXGI.Usage.RenderTargetOutput,
Flags = DXGI.SwapChainFlags.None,
SwapEffect = DXGI.SwapEffect.Discard
};

D3D10.Device.CreateWithSwapChain(null, D3D10.DriverType.Hardware, D3D10.DeviceCreationFlags.Debug, swapDesc,
out m_D3DDevice, out m_SwapChain);

// Once the device is created we need to Call on resize to setup our buffers and resize our swapchain.
OnResize();

// Disable Alt+Enter FullScreen
DXGI.Factory factory = m_SwapChain.GetParent();
factory.SetWindowAssociation(m_Window.Handle, DXGI.WindowAssociationFlags.IgnoreAll);

// The font that will display our Performance information.
m_Font = new D3D10.Font(m_D3DDevice, 20, 0, D3D10.FontWeight.Normal, 1, false, D3D10.FontCharacterSet.Default, D3D10.FontPrecision.Default,
D3D10.FontQuality.Default, D3D10.FontPitchAndFamily.Default | D3D10.FontPitchAndFamily.DontCare, "Fixedsys");

// Hook to our window event handlers.
m_Window.ResizeBegin += new EventHandler(m_Window_ResizeBegin);
m_Window.ResizeEnd += new EventHandler(m_Window_ResizeEnd);
m_Window.Resize += new EventHandler(m_Window_Resize);
m_Window.KeyDown += new KeyEventHandler(m_Window_KeyDown);
}

private void m_Window_Resize(object sender, EventArgs e)
{
// Make sure we properly handle resizing and pausing through different window states.
// This will allow for proper freeing of CPU cycles and making sure our views and swapchain
// are the right dimensions.
if (m_Window.WindowState == FormWindowState.Minimized)
{
m_AppPaused = true;
m_Timer.Stop();
minimized = true;
}
else if (m_Window.WindowState == FormWindowState.Maximized)
{
if (minimized)
{
m_AppPaused = false;
m_Timer.Start();
OnResize();
maximized = true;
minimized = false;
}
else
{
m_AppPaused = false;
OnResize();
maximized = true;
}
}
else
{
if(minimized)
{
m_AppPaused = false;
m_Timer.Start();
OnResize();
minimized = false;
}

if(maximized)
{
m_AppPaused = false;
OnResize();
maximized = false;
}
}
}

private void m_Window_ResizeBegin(object sender, EventArgs e)
{
m_AppPaused = true;
m_Timer.Stop();
}

private void m_Window_ResizeEnd(object sender, EventArgs e)
{
m_AppPaused = false;
m_Timer.Start();
OnResize();
}

private void m_Window_KeyDown(object sender, KeyEventArgs e)
{
// When the V-Key is pressed we will force SwapChain to
// Present at the Vertical Refresh Rate of our monitor.
// Under most circumstances this will be 60 FPS.
if (e.KeyCode == Keys.V)
{
if (m_VSync == 0)
{
m_VSync = 1;
}
else
{
m_VSync = 0;
}
}
}

public virtual void Run()
{
m_Timer.Reset();

MessagePump.Run(m_Window, () =>
{
m_Timer.Tick();
if (!m_AppPaused)
{
UpdateScene(m_Timer.GetDeltaTime());
}
else
{
System.Threading.Thread.Sleep(50);
}

DrawScene();
m_SwapChain.Present(m_VSync, DXGI.PresentFlags.None);
});
}

public virtual void OnResize()
{
// Release our resources as long as we are not null. This will prevent
// Internal reference counts from accumulating. Put here to be on the safe side.
// Not 100% sure if neccessary.
if (m_RenderTargetView != null)
{
m_RenderTargetView.Dispose();
}

if (m_DepthStencilView != null)
{
m_DepthStencilView.Dispose();
}

if (m_DepthStencilBuffer != null)
{
m_DepthStencilBuffer.Dispose();
}

// Resize our SwapChain Buffers and then setup our new RenderTargetView and DepthStencilBuffer/View
m_SwapChain.ResizeBuffers(1, m_Window.ClientSize.Width, m_Window.ClientSize.Height, DXGI.Format.R8G8B8A8_UNorm, DXGI.SwapChainFlags.None);
D3D10.Texture2D backbuffer = D3D10.Texture2D.FromSwapChain3D10.Texture2D>(m_SwapChain, 0);
m_RenderTargetView = new D3D10.RenderTargetView(m_D3DDevice, backbuffer);
backbuffer.Dispose();

D3D10.Texture2DDescription depthStencilDesc = new D3D10.Texture2DDescription()
{
Width = m_Window.ClientSize.Width,
Height = m_Window.ClientSize.Height,
MipLevels = 1,
ArraySize = 1,
Format = DXGI.Format.D24_UNorm_S8_UInt,
SampleDescription = new DXGI.SampleDescription(1, 0),
Usage = D3D10.ResourceUsage.Default,
BindFlags = D3D10.BindFlags.DepthStencil,
CpuAccessFlags = D3D10.CpuAccessFlags.None,
OptionFlags = D3D10.ResourceOptionFlags.None
};

m_DepthStencilBuffer = new D3D10.Texture2D(m_D3DDevice, depthStencilDesc);
m_DepthStencilView = new D3D10.DepthStencilView(m_D3DDevice, m_DepthStencilBuffer);

// Bind views to OutputMerger stage of the rendering pipeline
m_D3DDevice.OutputMerger.SetTargets(m_DepthStencilView, m_RenderTargetView);

// Now we will recreate our viewport and bind it to the Raster stage.
D3D10.Viewport vp = new D3D10.Viewport(0, 0, m_Window.ClientSize.Width, m_Window.ClientSize.Height, 0.0f, 1.0f);
m_D3DDevice.Rasterizer.SetViewports(vp);
}

public virtual void UpdateScene(float dt)
{
frameCnt++;

if ((m_Timer.GetGameTime() - t_base) >= 1.0f)
{
float fps = (float)frameCnt;
float mspf = 1000.0f / fps;

StringBuilder output = new StringBuilder();
if (m_VSync == 0)
{
output.Append("VSync: Off \n");
}
else
{
output.Append("VSync: On \n");
}

output.AppendFormat("FPS: {0} \n", fps);
output.AppendFormat("Milliseconds Per Frame: {0:0.000000}", mspf);

m_FrameStats = output.ToString();

frameCnt = 0;
t_base += 1.0f;
}
}

public virtual void DrawScene()
{
// Clear our Views.
m_D3DDevice.ClearRenderTargetView(m_RenderTargetView, new Color4(1.0f, 0.0f, 0.0f, 1.0f));
m_D3DDevice.ClearDepthStencilView(m_DepthStencilView, D3D10.DepthStencilClearFlags.Depth | D3D10.DepthStencilClearFlags.Stencil, 1.0f, 0);

m_Font.Draw(null, m_FrameStats, new Rectangle(0,0,5,5), D3D10.FontDrawFlags.NoClip, 0xff000000);
}
}
}


blewisjr

blewisjr

 

More progress.

Ok so I got the entire framework implemented at this point. Timing is done, creating the window is done, and displaying performance information is done.

Got some more code this time around too. I am not exactly sure if I am handling my resizing events properly here but all seems to work properly. The only issue I notice is the fact that the font seems to stretch with the screen resizing. Not to mention the font is not nearly as crisp as it seemed in DX9. If anyone knows why it is doing this feel free to chime in. Also yell at me if I am handling my resize events wrong or something. I come from a heavy C++ use background and my C# event handling is very rusty.

First the GameTimer class. This uses System.Diagnostics.Stopwatch in a way that mimics the C++ QueryPerformanceCounter.


using System;
using System.Diagnostics;

namespace InitDirect3D
{
class GameTimer
{
private double m_SecondsPerCount;
private double m_DeltaTime;

private long m_BaseTime;
private long m_PausedTime;
private long m_StopTime;
private long m_PrevTime;
private long m_CurrTime;

private bool m_Stopped;

public GameTimer()
{
m_SecondsPerCount = 0.0;
m_DeltaTime = -1.0;
m_BaseTime = 0;
m_PausedTime = 0;
m_StopTime = 0;
m_PrevTime = 0;
m_CurrTime = 0;
m_Stopped = false;

long countsPerSecond = Stopwatch.Frequency;
m_SecondsPerCount = 1.0 / (double)countsPerSecond;
}

public float GetGameTime()
{
if (m_Stopped)
{
return (float)((m_StopTime - m_BaseTime) * m_SecondsPerCount);
}
else
{
return (float)(((m_CurrTime - m_PausedTime) - m_BaseTime) * m_SecondsPerCount);
}
}

public float GetDeltaTime()
{
return (float)m_DeltaTime;
}

public void Reset()
{
long currTime = Stopwatch.GetTimestamp();

m_BaseTime = currTime;
m_PrevTime = currTime;
m_StopTime = 0;
m_Stopped = false;
}

public void Start()
{
long startTime = Stopwatch.GetTimestamp();

if (m_Stopped)
{
m_PausedTime += (startTime - m_StopTime);

m_PrevTime = startTime;

m_StopTime = 0;
m_Stopped = false;
}
}

public void Stop()
{
if (!m_Stopped)
{
long currTime = Stopwatch.GetTimestamp();

m_StopTime = currTime;
m_Stopped = true;
}
}

public void Tick()
{
if (m_Stopped)
{
m_DeltaTime = 0.0;
return;
}

long currTime = Stopwatch.GetTimestamp();
m_CurrTime = currTime;

m_DeltaTime = (m_CurrTime - m_PrevTime) * m_SecondsPerCount;

m_PrevTime = m_CurrTime;

if (m_DeltaTime 0.0)
{
m_DeltaTime = 0.0;
}
}
}
}




Next is the D3DApp class revised with the new features. Font code added and resize code modified.


using System;
using System.Drawing;
using System.Windows.Forms;
using SlimDX;
using D3D10 = SlimDX.Direct3D10;
using DXGI = SlimDX.DXGI;
using SlimDX.Windows;
using System.Text;

namespace InitDirect3D
{
class D3DApp
{
protected RenderForm m_Window;
protected D3D10.Device m_D3DDevice;
protected DXGI.SwapChain m_SwapChain;
protected D3D10.RenderTargetView m_RenderTargetView;
protected D3D10.DepthStencilView m_DepthStencilView;
protected D3D10.Texture2D m_DepthStencilBuffer;
protected D3D10.Font m_Font;
protected int m_VSync;
protected bool m_AppPaused;

protected string m_FrameStats;

protected GameTimer m_Timer;

private int frameCnt;
private float t_base;

public D3DApp()
{
m_Window = null;
m_D3DDevice = null;
m_SwapChain = null;
m_RenderTargetView = null;
m_DepthStencilView = null;
m_DepthStencilBuffer = null;
m_Font = null;
m_VSync = 0;
m_FrameStats = "";
m_AppPaused = false;

frameCnt = 0;
t_base = 0.0f;
}

~D3DApp()
{
m_RenderTargetView.Dispose();
m_DepthStencilView.Dispose();
m_DepthStencilBuffer.Dispose();
m_D3DDevice.Dispose();
m_SwapChain.Dispose();
m_Font.Dispose();
}

public void Initialize(string windowCaption)
{
m_Window = new RenderForm(windowCaption);

m_Timer = new GameTimer();

DXGI.ModeDescription modeDesc = new DXGI.ModeDescription()
{
Width = m_Window.ClientSize.Width,
Height = m_Window.ClientSize.Height,
RefreshRate = new Rational(60, 1),
Format = DXGI.Format.R8G8B8A8_UNorm,
ScanlineOrdering = DXGI.DisplayModeScanlineOrdering.Unspecified,
Scaling = DXGI.DisplayModeScaling.Unspecified
};

// Setup the SwapChain and Device
DXGI.SwapChainDescription swapDesc = new DXGI.SwapChainDescription()
{
BufferCount = 1,
ModeDescription = modeDesc,
IsWindowed = true,
OutputHandle = m_Window.Handle,
SampleDescription = new DXGI.SampleDescription(1, 0),
Usage = DXGI.Usage.RenderTargetOutput,
Flags = DXGI.SwapChainFlags.None,
SwapEffect = DXGI.SwapEffect.Discard
};

D3D10.Device.CreateWithSwapChain(null, D3D10.DriverType.Hardware, D3D10.DeviceCreationFlags.Debug, swapDesc,
out m_D3DDevice, out m_SwapChain);

OnResize();

// Disable Alt+Enter FullScreen
DXGI.Factory factory = m_SwapChain.GetParent();
factory.SetWindowAssociation(m_Window.Handle, DXGI.WindowAssociationFlags.IgnoreAll);

m_Font = new D3D10.Font(m_D3DDevice, 24, 0, D3D10.FontWeight.Normal, 1, false, D3D10.FontCharacterSet.Default, D3D10.FontPrecision.Default,
D3D10.FontQuality.Default, D3D10.FontPitchAndFamily.Default | D3D10.FontPitchAndFamily.DontCare, "Times New Roman");

m_Window.ResizeBegin += new EventHandler(m_Window_ResizeBegin);
m_Window.ResizeEnd += new EventHandler(m_Window_ResizeEnd);
m_Window.Resize += new EventHandler(m_Window_Resize);
m_Window.KeyDown += new KeyEventHandler(m_Window_KeyDown);
}

void m_Window_Resize(object sender, EventArgs e)
{
if (m_Window.WindowState == FormWindowState.Minimized)
{
m_AppPaused = true;
m_Timer.Stop();
}
else
{
m_AppPaused = false;
m_Timer.Start();
OnResize();
}
}

void m_Window_ResizeBegin(object sender, EventArgs e)
{
m_AppPaused = true;
m_Timer.Stop();
}

void m_Window_ResizeEnd(object sender, EventArgs e)
{
m_AppPaused = false;
m_Timer.Start();
OnResize();
}

void m_Window_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.V)
{
if (m_VSync == 0)
{
m_VSync = 1;
}
else
{
m_VSync = 0;
}
}
}

public void Run()
{
m_Timer.Reset();

MessagePump.Run(m_Window, () =>
{
m_Timer.Tick();
if (!m_AppPaused)
{
UpdateScene(m_Timer.GetDeltaTime());
}
else
{
System.Threading.Thread.Sleep(50);
}

DrawScene();
m_SwapChain.Present(m_VSync, DXGI.PresentFlags.None);
});
}

private void OnResize()
{
if (m_RenderTargetView != null)
{
m_RenderTargetView.Dispose();
}

if (m_DepthStencilView != null)
{
m_DepthStencilView.Dispose();
}

if (m_DepthStencilBuffer != null)
{
m_DepthStencilBuffer.Dispose();
}

// Setup the RenderTargetView and DepthStencilBuffer/View
m_SwapChain.ResizeBuffers(1, m_Window.ClientSize.Width, m_Window.ClientSize.Height, DXGI.Format.R8G8B8A8_UNorm, DXGI.SwapChainFlags.None);
D3D10.Texture2D backbuffer = D3D10.Texture2D.FromSwapChain3D10.Texture2D>(m_SwapChain, 0);
m_RenderTargetView = new D3D10.RenderTargetView(m_D3DDevice, backbuffer);
backbuffer.Dispose();

D3D10.Texture2DDescription depthStencilDesc = new D3D10.Texture2DDescription()
{
Width = m_Window.ClientSize.Width,
Height = m_Window.ClientSize.Height,
MipLevels = 1,
ArraySize = 1,
Format = DXGI.Format.D24_UNorm_S8_UInt,
SampleDescription = new DXGI.SampleDescription(1, 0),
Usage = D3D10.ResourceUsage.Default,
BindFlags = D3D10.BindFlags.DepthStencil,
CpuAccessFlags = D3D10.CpuAccessFlags.None,
OptionFlags = D3D10.ResourceOptionFlags.None
};

m_DepthStencilBuffer = new D3D10.Texture2D(m_D3DDevice, depthStencilDesc);
m_DepthStencilView = new D3D10.DepthStencilView(m_D3DDevice, m_DepthStencilBuffer);

// Bind views to pipeline
m_D3DDevice.OutputMerger.SetTargets(m_DepthStencilView, m_RenderTargetView);

// Set the viewport transform.
D3D10.Viewport vp = new D3D10.Viewport(0, 0, m_Window.ClientSize.Width, m_Window.ClientSize.Height, 0.0f, 1.0f);
m_D3DDevice.Rasterizer.SetViewports(vp);
}

public virtual void UpdateScene(float dt)
{
frameCnt++;

if ((m_Timer.GetGameTime() - t_base) >= 1.0f)
{
float fps = (float)frameCnt;
float mspf = 1000.0f / fps;

StringBuilder output = new StringBuilder();
if (m_VSync == 0)
{
output.Append("VSync: Off \n");
}
else
{
output.Append("VSync: On \n");
}

output.AppendFormat("FPS: {0} \n", fps);
output.AppendFormat("Milliseconds Per Frame: {0:0.000000}", mspf);

m_FrameStats = output.ToString();

frameCnt = 0;
t_base += 1.0f;
}
}

public virtual void DrawScene()
{
m_D3DDevice.ClearRenderTargetView(m_RenderTargetView, new Color4(1.0f, 0.0f, 0.0f, 1.0f));
m_D3DDevice.ClearDepthStencilView(m_DepthStencilView, D3D10.DepthStencilClearFlags.Depth | D3D10.DepthStencilClearFlags.Stencil, 1.0f, 0);

m_Font.Draw(null, m_FrameStats, new Rectangle(0,0,5,5), D3D10.FontDrawFlags.NoClip, 0xff000000);
}
}
}



EDIT: There is no longer a issue with the Font stretching. See comment below as to why it was happening.

blewisjr

blewisjr

 

Some More Progress.

As I said in my last entry it has been a long time since I touched C#. So as I was doing the port of the D3DApp framework for the DirectX 10 Luna Book, I realized quite quickly that I was trying to write C++ in C#. Not going to work. So I took a dive into the SlimDX sample MiniTri to get a general quick refresher on how a C# programmer does things. This sample + the MSDN helped a lot on giving me a nice refresher.

The code is not fully finished yet. I still need to get the font display coded and the GameTimer coded, but none the less I got a fully functional Direct3D 10 window running. The window is cleared to blue and I tacked in the functionality to turn on and off VSync. I hate when the video card transistors scream at high frame rates.

There are two things I learned from sitting down to do this. One it is really a excellent way to reinforce the learning curve of the massive DirectX API. You can't just sit there and copy the code or look at the code and port it. The best way I found to go about things is the read the chapter then implement it on my own in a C# way. The advantage is you actually learn the API not how to copy code and you can get a nice clean framework to use compared to what the author provides.
The second thing I learned is probably the biggest one. Why was a torturing my self with C++ all these years. C# is a very clean and powerful language and just looking at the code you can tell what it does. I will say the code I put together is not perfect yet or finalized in anyway but it is indeed a lot cleaner then the authors C++ code. The main reason I can see that this is so would be the removal of Macros and Preprocessor directives. Not to mention the exclusion of header files.

Now again keep in mind this is not finalized yet still needs some tweaking. Plus some more implementation but here is what I got so far.


using System;
using System.Drawing;
using System.Windows.Forms;
using SlimDX;
using D3D10 = SlimDX.Direct3D10;
using DXGI = SlimDX.DXGI;
using SlimDX.Windows;

namespace InitDirect3D
{
class D3DApp
{
private RenderForm m_Window;
private D3D10.Device m_D3DDevice;
private DXGI.SwapChain m_SwapChain;
private D3D10.RenderTargetView m_RenderTargetView;
private D3D10.DepthStencilView m_DepthStencilView;
private D3D10.Texture2D m_DepthStencilBuffer;
private int m_VSync;

public D3DApp()
{
m_Window = null;
m_D3DDevice = null;
m_SwapChain = null;
m_RenderTargetView = null;
m_DepthStencilView = null;
m_DepthStencilBuffer = null;
m_VSync = 0;
}

~D3DApp()
{
m_RenderTargetView.Dispose();
m_DepthStencilView.Dispose();
m_DepthStencilBuffer.Dispose();
m_D3DDevice.Dispose();
m_SwapChain.Dispose();
}

public void Initialize(string windowCaption)
{
m_Window = new RenderForm(windowCaption);

// Setup the SwapChain and Device
DXGI.SwapChainDescription swapDesc = new DXGI.SwapChainDescription()
{
BufferCount = 1,
ModeDescription = new DXGI.ModeDescription(m_Window.ClientSize.Width, m_Window.ClientSize.Height,
new Rational(60, 1), DXGI.Format.R8G8B8A8_UNorm),
IsWindowed = true,
OutputHandle = m_Window.Handle,
SampleDescription = new DXGI.SampleDescription(1, 0),
Usage = DXGI.Usage.RenderTargetOutput,
Flags = DXGI.SwapChainFlags.None,
SwapEffect = DXGI.SwapEffect.Discard
};

D3D10.Device.CreateWithSwapChain(null, D3D10.DriverType.Hardware, D3D10.DeviceCreationFlags.Debug,
swapDesc, out m_D3DDevice, out m_SwapChain);

this.OnResize();

// Disable Alt+Enter FullScreen
DXGI.Factory factory = m_SwapChain.GetParent();
factory.SetWindowAssociation(m_Window.Handle, DXGI.WindowAssociationFlags.IgnoreAll);

m_Window.Resize += new EventHandler(m_Window_Resize);
m_Window.KeyDown += new KeyEventHandler(m_Window_KeyDown);
}

void m_Window_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.V)
{
if (m_VSync == 0)
{
m_VSync = 1;
}
else
{
m_VSync = 0;
}
}
}

void m_Window_Resize(object sender, EventArgs e)
{
this.OnResize();
}

public void Run()
{
MessagePump.Run(m_Window, () =>
{
DrawScene();
m_SwapChain.Present(m_VSync, DXGI.PresentFlags.None);
});
}

private void OnResize()
{
if (m_RenderTargetView != null)
{
m_RenderTargetView.Dispose();
}

if (m_DepthStencilView != null)
{
m_DepthStencilView.Dispose();
}

if (m_DepthStencilBuffer != null)
{
m_DepthStencilBuffer.Dispose();
}

// Setup the RenderTargetView and DepthStencilBuffer/View
D3D10.Texture2D backbuffer = D3D10.Texture2D.FromSwapChain3D10.Texture2D>(m_SwapChain, 0);
m_RenderTargetView = new D3D10.RenderTargetView(m_D3DDevice, backbuffer);
backbuffer.Dispose();

D3D10.Texture2DDescription depthStencilDesc = new D3D10.Texture2DDescription()
{
Width = m_Window.ClientSize.Width,
Height = m_Window.ClientSize.Height,
MipLevels = 1,
ArraySize = 1,
Format = DXGI.Format.D24_UNorm_S8_UInt,
SampleDescription = new DXGI.SampleDescription(1, 0),
Usage = D3D10.ResourceUsage.Default,
BindFlags = D3D10.BindFlags.DepthStencil,
CpuAccessFlags = D3D10.CpuAccessFlags.None,
OptionFlags = D3D10.ResourceOptionFlags.None
};

m_DepthStencilBuffer = new D3D10.Texture2D(m_D3DDevice, depthStencilDesc);
m_DepthStencilView = new D3D10.DepthStencilView(m_D3DDevice, m_DepthStencilBuffer);

// Bind views to pipeline
m_D3DDevice.OutputMerger.SetTargets(m_DepthStencilView, m_RenderTargetView);

// Set the viewport transform.
D3D10.Viewport vp = new D3D10.Viewport(0, 0, m_Window.ClientSize.Width, m_Window.ClientSize.Height, 0.0f, 1.0f);
m_D3DDevice.Rasterizer.SetViewports(vp);
}

public virtual void UpdateScene(float dt)
{
}

public virtual void DrawScene()
{
m_D3DDevice.ClearRenderTargetView(m_RenderTargetView, new Color4(1.0f, 0.0f, 0.0f, 1.0f));
m_D3DDevice.ClearDepthStencilView(m_DepthStencilView, D3D10.DepthStencilClearFlags.Depth | D3D10.DepthStencilClearFlags.Stencil, 1.0f, 0);
}
}
}


blewisjr

blewisjr

 

Some Minor Progress

I recently just picked up the newest luna book on DirectX 10. Just when I thought DX9 was very clean DX10 takes it to a much higher level. The logical flow of the API is much better.

It is going to take me some time to get into this however. I have made the choice to step back from C++ somewhat. I love C++ don't get me wrong but I can't help but be intrigued by SlimDX. If I did not at least check it out I would not be content with myself. I am always enthusiastic about new ways to do things. For this I must shift to C#.

I have not used C# in quite a few years so it is going to be a decent shift in mindset. Going from a native way of thinking to a managed way of thinking so far has been awkward. I am going to be porting the code to C# as I go so I will make sure to post up lots of code as I move along.

This will not be a port purse because I don't think a direct port is going to be pretty. After all the code should look and feel like C#. So it will be more of a redesign. Sharp Develop is up and running SlimDX installed. Luna book is in hand lets see what I can do.

blewisjr

blewisjr

 

Some early opinions.

Well I have been tinkering around with OpenGL as of late. Just basic fixed function pipeline stuff via the 4th edition of the OpenGL SuperBible. I will say OpenGL initially seems as if it is easier to remember functions due to the naming conventions compaired to D3D. But the OpenGL SuperBible is rather lack luster IMHO. The author seems to skim over a lot of things that the Luna Book covers in depth for D3D. Thankfully the Luna book covered the topics so I really don't have any issues. The other issue with the book I find is the code samples. First the book uses FreeGlut. I had to go and compile the library. Would have been better if the author used SDL I think. Next some of the pre-compiled Code samples don't even work. I am running a HD 4850 that supports every feature of OGL up to current standards. There are 2 or 3 FBO code samples that don't work at all but the rest do. I have a feeling it is a error on the authors part and there is no Errata for the book stating so.

So the low down:

OpenGL seems easier to remember but the books teaching the api out there are lack luster. I might be better off with copies of the Red/Orange book. The structure of OpenGL code can be a little harder to follow due to its C Nature. This leads to things being broken up into a lot of small function calls to achieve what you want.

D3D seems like it is put together a little better but harder to remember because of unintuitive naming conventions. Things in the D3D api seem to logically flow together. Mostly because it is more object oriented. Resources for learning it are a lot more structured and detailed.

Each has the pros and each has the cons. Not sure which path I will take yet going to continue to tinker around with this OpenGL book a little longer so I can at least compare code that does things the same way. Hopefully I will get to VBO's soon and away from this glVertex crap. Might just have to skip ahead.

blewisjr

blewisjr

 

Time to take a small switch

Well I have been learning DirectX as my last entry stated. After 8 chapters of the Luna shader approach book and a few days of self experimentation I can say I am comfortable with what I learned.

Now I want to take a look back at OpenGL. Quite a few years back I started messing about with OpenGL. I think at this point it is time to revisit for a few reasons. First a foremost I am a much better developer then I was back when I first started experimenting with it. Secondly I have a much better math background. When I first started dabbling with graphics programming in 2D/3D I found a passion for math. I use to hate it. But now I have a practical reason for using it making me find it much more interesting.

So I will start to screw around with OpenGL. I don't have a OpenGL book the quality of the luna book but I understand how to set up Win32 and OpenGL Devices already. It will just more or less be lets convert one of the luna book examples to OpenGL and see which API I like better.

I will make sure I post a update with my findings.

blewisjr

blewisjr

 

DirectX and C++

For the last 2 weeks or so I have been working through the Luna DX9 Shader approach book. I have currently traversed 8 chapters in this book. The Luna book is phenomenal for one. All the source code is very well documented and everything is explained really well. The only thing slowing me down is the vastness of the DirectX API. It is huge. I dabbled with OpenGL in the past but by far I would say DirectX has the steeper learning curve by far. But at the same time it seems a lot more rewarding near the end. The API is very clean and well thought out.

But as I said the API is large making it hard to remember a lot of the concepts. Almost like a giant overload. So I think the best thing for me to do at this point is to take a break from progress in the book. This will allow me to drill all the concepts that I have went over thus far home. I will take what I learned and apply it to my own little demos, hopefully this will make it easier to remember.

blewisjr

blewisjr

 

Some internal insite

This entry was sparked by me remembering about this discussion while replying to one of those I am a beginner and want to learn C++ threads.

As of late I have been having some debates with friends of mine about games/game development in general. One things that always comes up in these kinds of debates with my friends is how I am a masochist. They say I am a masochist for using C++ and enjoying looking at things from the system level.

I always tell them ever since I was little I have had a hunger for knowing how things work internally at that level.

That above statement has really got me doing some self reflection. I don't really post on here much about progress on games and what not for one reason. I never really make much progress. It is not because I don't do anything or don't understand how to make a game. Instead I always get tied up in my main interest. The underlying subsystems. I will say ok here is my game idea. Net you know it the game idea is thrown out the window and I am using it as a test bed for new rendering theories and component structures, physics tests and the like. Overall I would have to state I really don't care about making the next greatest game. I enjoy tinkering down at the low level game subsystem level.

You know all those little components that game programmers use to make their games. Render systems, physics systems, ai systems. These low level details are really what I enjoy about game programming.

I would consider myself one of the few people who would enjoy myself more if I was writing graphics engines, and physics engines. Maybe even scripting systems. The stuff that people are always looking into some game engine to do for them because they want to get their game done and could care less about how things work internally.

So I have come to a conclusion maybe I should focus my time on these things I enjoy rather then forcing myself into writing a game. Instead maybe my purpose is to make it easier for others to write games.

I would love to hear peoples opinions on this.

blewisjr

blewisjr

 

More on VC++ Express 2010 Beta 2

No updates on the game today however, I have been working with 2010 Beta 2. My first test revolved around the ease of setting up Boost and Boost Test. In the past Boost was notorious for breaking intellisense. It was to the point where it was almost guaranteed to break it. This is the first change microsoft made. .ncb file are gone completely and intellisense is now driven by a database of sorts using a .sbf file.

The one thing I noticed about this is that Visual Studio now must parse the project and all its includes etc... and do so on the fly quickly as you make changes. This works phenomenally. There are a few bugs and quirks I noticed where there may be a slightly lengthy pause occasionally after typing a . but that could be related to a issue I was having that I will get into. The best thing is though it works with boost flawlessly. When you frist create your project it takes a few secs to parse the entire boost lib. Does not break intellisense and even gives you a tooltip showing the arguments functions take. Also it is guaranteed to resolve after use press a . which is even better yet.

This issue I talk about was originally in prior VS versions to do boost unit testing you needed to link to the lib of the project you are testing. This was done with a right click option called Project Dependencies. This option still exists but I was having a lot of issues with it. This is because microsoft changed the build engine for C++ from vcbuild to msbuild.

With a simple question MS came to the rescue and told me about a new feature called project to project references. I was told all old vs solutions that are coverted are auto converted to use project to project references where they were using project dependencies to ensure proper linking. They told me to switch to using project to project references. So I did and it is very easy. Right click on the project that needs the reference. Go to properties then common config. From there you go to references and add. Your projects auto pop up to select from then you select and hit ok and bamb good to go. Yes you still need to tell the referencing project where to find the header files.

Once I did all that surprisingly it seems intellisense is even faster did not notice any slowdowns at all. Most of all I did not have to do my workaround to get the lib to link.

I must say I am very impressed with this release. I think it will make life better for all.

blewisjr

blewisjr

 

Visual C++ 2010 Express Beta 2

I just installed Express 2010 beta 2. One thing I can say it is very fast. In the coming days we will see how it works out. So far I was able to build SFML and Boost with it. I did stumble into some issues with SFML but resolved them. Turns out the /INCREMENTAL option was turned off in one of the Build Configs. Once I flipped the switch it seems to build alright. We will see if it actually works at a later date.

blewisjr

blewisjr

 

Cross Platform C++ Tool Chain

Well I am currently working on putting together a cross platform C++ development tool chain. I want to use Boost Build and Boost Test for sure. Both are very amazing. Currently I feel the best route would be to use the compilers meant for each OS and Boost Build will greatly aid in this. It will allow for the MSVC compiler on windows and GCC for linux. The only stumbling blocks right now are editors / Debuggers. It would be nice to not have to learn cmd line for 2 different debuggers but that might be the only case. Editor wise I can go with anything really even Non IDE. Or I might just be able to use VC++ Express and use boost build on linux only. Suggestions are welcome I am very open minded. Sometimes I wish there was a compiler that was shared between all Operating Systems.


EDIT: After many gripes with this today I have decided to screw it. The headaches of worrying about cross platform are not worth it time to get visual studio set up and work on my damn game.

blewisjr

blewisjr

 

The Results are out.

I am not going to bother with posting the code I used. I am going to try to keep this as short and sweet as possible because we all know benchmarks are to be taken with a grain of salt. The main conclusion I came up with is beware of for loops they can really bog down code so use them sparingly. So here are the results which are not surprising that java is faster. So here are the results.

First results are with a for loop that reruns the code 1000 times. By resetting positional values. This shows that Java with a for loop is about 2.3x as fast as Python mathematically.

Python average after 5 runs 17.7692 Seconds
Java average after 5 runs 7.6814 Seconds

These second results are without the for loop and just running the math through one iteration showing that Java is 5.1x as fast as python without a for loop.

Python average without for loop after 5 runs 0.041
Java average without for loop after 5 runs 0.008

Now these numbers seem insignificant, however, from my experience once you add in collision detection, with the physics and the rendering these numbers can become exponential and cause some bottle necks in your game.

Based off experience and the fact I have many languages under my belt and knowledge of core programming and game programming data structures and practices I am going to be looking into either going back to C++ or Java for my game coding. Because I know somewhere in my newest game with python I will have to optimize a lot of code by moving it to C++ anyway.

blewisjr

blewisjr

 

And So it Begins

Not too much of a update here. I settled on Subversion for source control once I got it set up on my External HD it is very easy to utilize once that was all done. On another note I may be switching langs. I started to notice a few issues through some prototypes that are a sign of python's horrible mathematical performance. So I am in the process of doing some profiling. I don't like having to drop down to C++ from python if that is the case I might as well use C++ and embed python on top of it for basic logic. This can even get ugly. So what I am going to do is run some bare bones profiling. Basically I am going to ignore graphics and collision detection and write some test physics code to profile. I am going to do my best to keep it objective. Going to test both Python and Java for now and see what I get.

blewisjr

blewisjr

 

Addressing Comments, and what I been up to

|Warning Wall of Text Incoming if you want to skip the rant read below the divider.|

First and foremost lets address some comments and clarify a few things. My last entry drew a comment that brought out a particular opinion I have that I have not really stated in quite a long time to anyone. The comment basically went about how if I don't have any games under my belt I am going about things the wrong way. I have to outright disagree. I am a very open person and listen to lots of suggestions but this is one I just can't.

For one I do have a few games under my belt. Granted they are not original games but they are clones of some old time favorites ranging from pong to space invaders. I don't have a degree but am very close to one I have 3 years of a BAS completed that I did not get to finish as of yet due to personal reasons but I will get back there, however I do have a solid background in data structures, algorithms, mathematics, and fluent in about 5 programming languages. After all once you understand the core concepts of programming it is just syntax.

The fact that I want to start up my own small time indie game company seems like a common mistake that a lot of people out there make. From my life experience this is not actually a mistake and highly miss suggested as one. People have to realize that big companies like ID did not come from sitting around and doing nothing. They started as small time indie studios who had the "balls" to take the risk. They had a passion and they went for it.

One quote I will always remember is from my late grandfather. He told me if I have a passion to go out and get it no matter what the risk. He said if you don't take the risk you will never be successful. If you fail so be it but don't let that stop you get up and try again. Do whatever it takes to achieve that passion.

If you don't go out there and try you will never make mistakes to learn from and you will certainly never achieve a goal.

================================================================================

So now away from the rant and more on to what I have been up to.

I have been through quite a few web designs as of late. For me web design is more trial and error and I don't care how long it takes as it is only a side project and my game comes first. The more I delve into it more more I simplify it so it can run easily across all mediums. I say within the next few days I should have it in a solid state of simple and effective but nice looking.

Now on to the real project my game. Currently the project is named but I am not going to release that just yes lets just say it is a 2D Platform game. Lots of feature brainstorming sessions going on for now. But while that is going on I am in the process of putting together a package structure for it so i can start developing the core systems needed so I can lay out some feature prototypes and start forming it into the actual game.

For python the package structure is very important as it dictates where the interpreter finds you imports and such. The main goal is to develop the game in such a way that I put together a reusable library of systems that are well tested and reliable. For the testing and reliability unit testing will play a big factor. When putting together a package for python you use a file name __init.py__. This allows python to dynamically put together the import lookup table for your code. I have been going through many different layouts and I think I might have narrowed it down to 2 possibilities. The main difference of the two is that the latter does not subdirectory the Libs folder.

This is where other python user suggestions will be really helpful. Swiftcoder I need your input :D

Main Folder
..Images
..Config
..UnitTests
..Libs
....__init__.py
....Math
......__init__.py
....Physics
......__init__.py
etc......

Main Folder
..Images
..Config
..UnitTests
..Libs
....__init__.py

blewisjr

blewisjr

 

Web site mock up complete.

So I am in the process of starting up a small indy game company. It will start as a one man operation pritty much and the plan is to release the games for free. Just a little something to occupy some time really. Who knows maybe it will take off and get bigger. But not worried about that. So through some research I realized that now a days a lot more goes into a website then XHTML/CSS and PHP. So I broke out the rusty Gimp skills and put together a entire web site mock up. This is the result of many hours of work I would estimate about 7 hours of work with research time included. I wanted to get this layout just right so I was tweaking stuff constantly. The next step will be to splice up the site into small images and then use those with XHTML/CSS via image replacement to build the functional site. I will also be using PHP to deliver database driven news.

I would like to know your opinions on the mock up. I am a big fan of constructive criticism. Click the thumbnail to make the mock up bigger.


blewisjr

blewisjr

 

2 in one day ZOMG

Well my Python Dev environment is almost complete.

Currently I decided to go with Mercurial seems SVN is not content with putting a repo on my external HD. That was the biggest decision factor right there.
If somone knows how to get svn to work on a external HD let me know. I really don't want to have to go through the trouble and get a source control host when it is not really needed.

As for editors I decided to go with Programmer's Notepad 2.0.10. The reason for this is that it is a non bloated very configurable editor. Currently I can run my python scripts, execute pylint, and run unitests all right from the editor after some configuration. Was not the easiest config but I got it to work non the less.

The hardest thing I had to setup today was Pylint. I started by getting it with easy_install. Then I ran into the issue where it kept closing my command prompt so I could not see the output. So with some diving I traced it back to the batch file that executes it on windows.

Originally the batch file looked like this...


@echo off
rem = """-*-Python-*- script
rem -------------------- DOS section --------------------
rem You could set PYTHONPATH or TK environment variables here
python -x "%~f0" %*
goto exit

"""
# -------------------- Python section --------------------
import sys
from pylint import lint
lint.Run(sys.argv[1:])


DosExitLabel = """
:exit
exit(ERRORLEVEL)
rem """


we can immediatly notice the issue is that after every pylint command it calls exit(ERRORLEVEL)

so I made a slight change by commenting that out and using a ECHO. to print a newline after it executes instead. I ended up with this.

@echo off
rem = """-*-Python-*- script
rem -------------------- DOS section --------------------
rem You could set PYTHONPATH or TK environment variables here
python -x "%~f0" %*
goto exit

"""
# -------------------- Python section --------------------
import sys
from pylint import lint
lint.Run(sys.argv[1:])


DosExitLabel = """
:exit
ECHO.
rem exit(ERRORLEVEL)
rem """


The next issue was to config Pylint to abide fully by pep8 and that meant changing a regular expression for global variables from all caps to all lowercase. So I used pylint to create a pylintrc.conf file and I tweaked it and added that conf file to my PYLINTRC env variable.

Tada it works. Then I had to get it to work in pn2. Issues issues issues. Turns out pn2 does not execute these things through the regular command prompt. So after a few min I realized I had to give it a path to the bat file and not just the command you use in the prompt. Then I had the issue of it not using my env vars so it was not finding the config file. So I had to force specify the config file location before the file name param. Now all that is done I can happily code with only a mercurial prompt open and ipython open.

The full dev environment atm consists of the following:

Python 2.6.4
Programmer's Notepad 2.0.10
Pylint (for code metrics and code standards)
IPython (supper powered interactive python shell)
Python Built in PyUnit (for unittesting)
Mercurial (for source control)

blewisjr

blewisjr

 

Long time no speak

Hello everyone I am back after quite a long leave. Personally the only thing I can blame is WoW Raiding and Dragon Age Origins. Both have me all booked up most of the time.

So on to better things. First off I have a new project underway that is going though some brainstorming right now while I work on setting up a decent development environment for Python. Editors aside the biggest decisions I need to make is what source control I want to use and if I want to use unit testing or not.

I have never used unit testing before and this might be a good time to try and use it who knows maybe it can make me a better programmer or maybe it will just be a pain in my ass not exactly sure.

As far as source control goes the big debate goes between SVN and Mercurial. I am trying to decide based off of the way I like to work. Not easy because either can do what I want. This is where you guys come in maybe you can give some suggestions. First off I am very heavy in iterative development. When working on a game if I have a idea that I think will work I will iterate on it in the game see if it turns out and works well if not I tear it out and go back. This process is never ending and in the end I have a game. The more I think about it the more I can lean towards mercurial here is what the work flow for each would look like.

Mercurial:

Main Repo on External HD
Pull from Main Repo into Incoming
Clone Incoming For Feature 1
Clone Incoming For Bug fix 1
Clone Incomming For Feature 2
Merge complete issues into outgoing
Push Outgoing to External HD.

SVN:

Checkout From Repo
Branch for Feature 1
Branch for Feature 2
Work in trunk for non game breaking stuff
Merge complete branches with trunk

To me it seems mercurial makes it easier for branchy development. From a iterative standpoint each "trial feature" is easier to just toss out if it does not work. You simply delete that clone and all is well. It allows you to always clone of a pristine copy as well.

If any of you guys have experience with any of these give me some tips especially if you can point me to python exercises for unit testing.

blewisjr

blewisjr

 

Just got a Zune

Just picked up a Zune 8G yesterday. This is a very nice piece of hardware and I love it. Very nice music/video organization coupled with great battery life. Next step I think will be to write a small game for it with XNAGS. Looks like orbis is comming back in a rewritten state to make it battery friendly.

blewisjr

blewisjr

 

On the hunt

So I am on the hunt for some music and sound effects files. It is kind of tough to find the right stuff that is free. I could probably use some stuff from my CD collection but if I decide to let some people play Orbis that is a bad idea. The worst part is XACTS limitations for needing to use wav files only. Damn you XNAGS.

blewisjr

blewisjr

 

Off topic today

Well no updates on orbis today. I have been thinking a lot about game development tho. One thing I have been looking into is using SVN to make a repository on my external SimpleTech 1TB USB2.0 Hard Drive. I would use TortoiseSNV for this obviously. Another thing I have been thinking about as of recently is Unit Testing in games using NUnit or XUnit. I have never done unit testing before but it seems like it can be a lifesaver is some major code refactors and such.

On another note I have 2 more ideas for games however, they are both 3D. I really don't want to say much about them because I am hoping I can get atleast one of them done for XBLCG which is going into effect Q4 of this year. I really hope I can get orbis out of the way to work on one of my real projects I have been putting alot of effor into mentally. For me 2D is just a steping stone to learn game concepts. My ultimate goal is 3D. It kinda sucks because I am not putting much thought into orbis because of this. Instead I have been reading up alot on 3D development to get the concepts in my brain.

On another note I have been playing a lot of diablo 2 lately. It is quite interesting how a game 8 years old tickles my fancy more then crysis does or even oblivion. I have been playing D2 since launch and the element of suprize is totally gone. It is sad when you know what the item is before you UNID it. But on another note the game still has a lot of fun factor to it.

I know I know I can't give up on orbis. I won't give up on orbis. Next journal entry should have quite a bit done.

Remember life is like a box of chocolates. You never know what u'r gunna get.

blewisjr

blewisjr

 

Some Orbis Work

Well I did some work on orbis today. Not much a bit short on time. I got the initial backdrop of the title screen done. To do this I used the dreaded GameComponent feature of XNA. GameComponent derived objects can be quite handy and abstract the code nicely for reuse if they are coded properly. I however can see these GameComponent objects being quite a sloppy mess and hard to follow in larger projects. In my book I am learning XNA from they overuse game components I think. They litterally make everything a GameComponent. Not bad in principle but as I said as the projects get large I think they can be a burden. But anyway onto the code..... (note main game code missing just the components are shown.)

Scene.cs (this is the main scene component all scenes are derived from this)

using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.Content;

namespace Orbis
{
///
/// This is a game component that implements IUpdateable.
///
public class Scene : Microsoft.Xna.Framework.DrawableGameComponent
{
// components belonging to the scene
private readonly List components;

public Scene(Game game)
: base(game)
{
components = new List(); // initialize the component list

// set the state of the scene
Visible = false;
Enabled = false;
}

///
/// Allows the game component to perform any initialization it needs to before starting
/// to run. This is where it can query for any required services and load content.
///
public override void Initialize()
{
// TODO: Add your initialization code here

base.Initialize();
}

///
/// Allows the game component to update itself.
///
/// Provides a snapshot of timing values.
public override void Update(GameTime gameTime)
{
// makes sure the child components of this scene are updated when they are enabled(active)
for(int i = 0; i {
if(components.Enabled)
{
components.Update(gameTime);
}
}

base.Update(gameTime);
}

public override void Draw(GameTime gameTime)
{
// draw the drawable child components of this scene if they are visible
for (int i = 0; i {
GameComponent component = components;
if ((component is DrawableGameComponent) && ((DrawableGameComponent)component).Visible)
{
((DrawableGameComponent)component).Draw(gameTime);
}
}
base.Draw(gameTime);
}

///
/// returns the values in the components list belonging to this scene
///
public List Components
{
get { return components; }
}

///
/// Set the state of the scene to display it
///
public virtual void Show()
{
// set state of the scene
Visible = true;
Enabled = false;
}

///
/// Set the state of the scene to not display it
///
public virtual void Hide()
{
// set state of the scene
Visible = false;
Enabled = false;
}
}
}




StartupScene.cs (this is the main title scene of the game not fully complete)

using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.Content;

namespace Orbis
{
///
/// This is a game component that implements IUpdateable.
///
public class StartupScene : Scene
{
// sprite batch for drawing
private SpriteBatch spriteBatch = null;
// background texture
private Texture2D texture;
// background texture rect
private Rectangle backRect;
public StartupScene(Game game, Texture2D texture)
: base(game)
{
// initialize spriteBatch from a SpriteBatch in the game services
spriteBatch = (SpriteBatch)Game.Services.GetService(typeof(SpriteBatch));
// initialize background texture
this.texture = texture;

// initialize backRect
backRect = new Rectangle(0, 0, Game.Window.ClientBounds.Width, Game.Window.ClientBounds.Height);
}

///
/// Allows the game component to perform any initialization it needs to before starting
/// to run. This is where it can query for any required services and load content.
///
public override void Initialize()
{
// TODO: Add your initialization code here

base.Initialize();
}

///
/// Allows the game component to update itself.
///
/// Provides a snapshot of timing values.
public override void Update(GameTime gameTime)
{
// TODO: Add your update code here

base.Update(gameTime);
}

public override void Draw(GameTime gameTime)
{
// draw the background
spriteBatch.Begin();
spriteBatch.Draw(texture, backRect, Color.White);
spriteBatch.End();
base.Draw(gameTime);
}
}
}




now for the great and all mighty picture (note thumbnail click for full)




blewisjr

blewisjr

 

Ship done!!!

Here is the ship Sprite I will be using in orbis. Took about 2 mins to toss it together but it still looks rather nifty hopefully it will work as intended :P


blewisjr

blewisjr

 

Orbis Orbs done.

I settled for very simple here. This is the sprite sheet that contains the target orbs. Each orb here will have a point value. Tomarrow I will start working on the power up orbs they will be on this spritesheet as well. The players ship I decided to put the player ship in its own image file that will come soon as well. Here you go enjoy the simpleness of these orbs.



Woot mommy look I made M&M's :D

blewisjr

blewisjr

 

Back to orbis

Ok ok. That last post was a bad tangent. I am a programmer lol no way in hell will I get amazing at art. My art is my code. Back to XNA and Orbis and tossing together some sprites who cares what they look like if the game is fun.

blewisjr

blewisjr

 

New route based on experiences in the last few day

Over the last few days I learned something about myself. I always knew I was not bad at art in general. I can draw rather well, however, over my last few days of experimenting for hours using gimp and other such programs I found I really am not that bad at the computer art side of things. With some practice I noticed I keep getting better and better at making visuals in my head become a reality and I have alot of fun doing it. So I am taking a new direction to my learning and applying it to art. I see all the time how people on this site have a hard time with the art side of things with their games and finding artists for their projects. Maybe I can help fill that gap. So this is my new direction computer art and animation. Wish me some luck after all I am enjoying it more then I ever did programing.

blewisjr

blewisjr

Sign in to follow this  
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!