Jump to content

  • Log In with Google      Sign In   
  • Create Account

Lewis_1986

Member Since 06 May 2011
Offline Last Active Oct 06 2011 06:02 AM

Topics I've Started

OpenGL questions

27 August 2011 - 11:57 AM

Hi,

Currently I have been using glLoadMatrix and glGetFloatv to load and save the matricies, is there a better way to do this that is also compatible with OpenGL ES for the nvidia Tegra 2 hardware platform?

c# state management, need some opinions

06 May 2011 - 05:13 AM

Hi I have a basic application in C# designed to use states to manage application behaviour. Below is my code for the state stuff

Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace StateApp
{
	static class Program
	{
    	public static Form1 form1 = new Form1();
    	public static IState[] states = {new IntroState()};
    	public static IState curState;
    	public static KeyEventHandler activeKeyHandler;
    	public static MouseEventHandler activeMouseHandler;
    	public static int count = 0;
    	
    	/// <summary>
    	/// The main entry point for the application.
    	/// </summary>
    	[STAThread]
    	static void Main()
    	{
        	curState = states[0];
        	Application.EnableVisualStyles();
        	Application.Run(form1);
    	}
	}
}

IntroState.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StateApp
{
	public class IntroState : IState
	{
    	public IntroState()
    	{
        	this.Name = "IntroState";
        	Program.count = 0;
    	}
    	public void Update()
    	{
        	 Program.count++;
        	Program.form1.BackColor = System.Drawing.Color.Azure;
    	}
    	public void Cleanup()
    	{
        	Program.count = 0;
    	}
    	public void Pause()
    	{
    	
    	}
    	public void Resume()
    	{
    	
    	}

    	public string Name { get; set; }
	}
}

IState.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StateApp
{
	/// <summary>
	/// A State Object Abstract from drawing and eventhandling 
	/// by working only with data and external application settings
	/// </summary>
	public interface IState
	{
    	void Update();
    	void Cleanup();

    	void Pause();
		void Resume();
    	string Name { get; set; }
	}
}

the idea of the design is that using the Program class each state can select eventhandlers, methods etc and just work on the data aspect of the program selecting the eventhandlers to use, which also change data based upon events such as input.

PARTNERS