示例#1
0
        protected override void OnInitialization(Graphics3DConfiguration config)
        {
            if (GraphicsDirect3D9.Device != null)
                throw new Graphics3DStateException("Cannot do device initialization: Device already initialized!");

            GraphicsDirect3D9.Device = new Device(new Direct3D(), 0, DeviceType.Hardware, config.Target, CreateFlags.HardwareVertexProcessing, Direct3DConverter9.ConvertToPresentParameters(config));
        }
示例#2
0
        protected override void OnInitialization(Graphics3DConfiguration config)
        {
            if (GraphicsDirect3D9.Device != null)
            {
                throw new Graphics3DStateException("Cannot do device initialization: Device already initialized!");
            }

            GraphicsDirect3D9.Device = new Device(new Direct3D(), 0, DeviceType.Hardware, config.Target, CreateFlags.HardwareVertexProcessing, Direct3DConverter9.ConvertToPresentParameters(config));
        }
示例#3
0
        /// <summary>
        /// Initialize a graphics 3d system from a plugin. <b>Do not call initialize on the returned Graphics3DDevice! Already called by this method!</b>
        /// </summary>
        /// <param name="config">Configuration for Graphics 3D Engine</param>
        /// <param name="systemName">Name of the low layer system (e. g. Direct3D9, ...)</param>
        /// <returns>A Graphics3DDevice object. Represent an instance of the graphics 3d engine</returns>
        /// <exception cref="Graphics3DSystemNotFoundException">Is thrown if no system with the given system name was found</exception>
        public static Graphics3DDevice InitializeSystem(Graphics3DConfiguration config, String systemName)
        {
            if (!layerList.ContainsKey(systemName))
                throw new Graphics3DSystemNotFoundException("Cannot find system: " + systemName);

            Configuration = config;

            Implementors = layerList[systemName].LayerImplementor;
            Graphics3DDevice device = layerList[systemName].Device;
            device.Initialize(config);

            CurrentDeviceType = systemName;

            return device;
        }
示例#4
0
        /// <summary>
        /// Initialize a graphics 3d system from a plugin. <b>Do not call initialize on the returned Graphics3DDevice! Already called by this method!</b>
        /// </summary>
        /// <param name="config">Configuration for Graphics 3D Engine</param>
        /// <param name="systemName">Name of the low layer system (e. g. Direct3D9, ...)</param>
        /// <returns>A Graphics3DDevice object. Represent an instance of the graphics 3d engine</returns>
        /// <exception cref="Graphics3DSystemNotFoundException">Is thrown if no system with the given system name was found</exception>
        public static Graphics3DDevice InitializeSystem(Graphics3DConfiguration config, String systemName)
        {
            if (!layerList.ContainsKey(systemName))
            {
                throw new Graphics3DSystemNotFoundException("Cannot find system: " + systemName);
            }

            Configuration = config;

            Implementors = layerList[systemName].LayerImplementor;
            Graphics3DDevice device = layerList[systemName].Device;

            device.Initialize(config);

            CurrentDeviceType = systemName;

            return(device);
        }
示例#5
0
        public static PresentParameters ConvertToPresentParameters(Graphics3DConfiguration configuration)
        {
            PresentParameters pp = new PresentParameters();
            pp.BackBufferCount = 1; //TODO
            pp.BackBufferFormat = ConvertToFormat(configuration.ScreenConfiguration.ColorMode);
            pp.BackBufferHeight = configuration.ScreenConfiguration.Height;
            pp.BackBufferWidth = configuration.ScreenConfiguration.Width;
            pp.EnableAutoDepthStencil = true;
            pp.FullScreenRefreshRateInHertz = 0; //TODO
            pp.Multisample = MultisampleType.None; //TODO
            pp.MultisampleQuality = 0;
            pp.PresentationInterval = PresentInterval.One; //TODO
            pp.SwapEffect = SwapEffect.Discard;
            pp.Windowed = !configuration.ScreenConfiguration.FullScreen;
            pp.DeviceWindowHandle = configuration.Target;
            pp.AutoDepthStencilFormat = Format.D24S8;

            return pp;
        }
示例#6
0
        static void Main()
        {
            Form win = new Form();
            win.KeyDown += ((sender, e) => { win.Close(); });
            win.Width = G3D_WIDTH;
            win.Height = G3D_HEIGHT;
            win.StartPosition = FormStartPosition.CenterScreen;
            win.Text = "Graphics 3D - Demo";

            Graphics3DConfiguration config = new Graphics3DConfiguration();
            config.Target = win.Handle;
            config.ScreenConfiguration.ColorMode = ColorMode.Bit32;
            config.ScreenConfiguration.FullScreen = true;
            config.ScreenConfiguration.Height = G3D_HEIGHT;
            config.ScreenConfiguration.Width = G3D_WIDTH;

            Graphics3DApplication.Initialize += new Action<Graphics3DDevice>(Graphics3DApplication_Initialize);
            Graphics3DApplication.Dispose += new Action<Graphics3DDevice>(Graphics3DApplication_Dispose);
            Graphics3DApplication.Run(win, Graphics3DSystem.InitializeSystem(config, "Direct3D9"));
        }
示例#7
0
        public static PresentParameters ConvertToPresentParameters(Graphics3DConfiguration configuration)
        {
            PresentParameters pp = new PresentParameters();

            pp.BackBufferCount              = 1; //TODO
            pp.BackBufferFormat             = ConvertToFormat(configuration.ScreenConfiguration.ColorMode);
            pp.BackBufferHeight             = configuration.ScreenConfiguration.Height;
            pp.BackBufferWidth              = configuration.ScreenConfiguration.Width;
            pp.EnableAutoDepthStencil       = true;
            pp.FullScreenRefreshRateInHertz = 0;              //TODO
            pp.Multisample            = MultisampleType.None; //TODO
            pp.MultisampleQuality     = 0;
            pp.PresentationInterval   = PresentInterval.One;  //TODO
            pp.SwapEffect             = SwapEffect.Discard;
            pp.Windowed               = !configuration.ScreenConfiguration.FullScreen;
            pp.DeviceWindowHandle     = configuration.Target;
            pp.AutoDepthStencilFormat = Format.D24S8;

            return(pp);
        }
 public static void Run(Graphics3DConfiguration config, String systemName)
 {
     Run(new Form(), config, systemName);
 }
 public static void Run(Form form, Graphics3DConfiguration config, String systemName)
 {
     Run(form, Graphics3DSystem.InitializeSystem(config, systemName));
 }
示例#10
0
 public static void Run(Graphics3DConfiguration config, String systemName)
 {
     Run(new Form(), config, systemName);
 }
示例#11
0
 public static void Run(Form form, Graphics3DConfiguration config, String systemName)
 {
     Run(form, Graphics3DSystem.InitializeSystem(config, systemName));
 }
示例#12
0
 protected abstract void OnInitialization(Graphics3DConfiguration config);
示例#13
0
 internal void Initialize(Graphics3DConfiguration config)
 {
     OnInitialization(config);
     Graphics3DSystem.Implementors.MaterialImplementor.SetMaterial(
         MaterialCreator.CreateDefaultMaterial().Create());
 }
示例#14
0
 protected abstract void OnInitialization(Graphics3DConfiguration config);
示例#15
0
 internal void Initialize(Graphics3DConfiguration config)
 {
     OnInitialization(config);
     Graphics3DSystem.Implementors.MaterialImplementor.SetMaterial(
         MaterialCreator.CreateDefaultMaterial().Create());
 }