Click here to Skip to main content
15,898,134 members
Articles / Desktop Programming / WPF

Blend the OGRE Graphics Engine into your WPF projects

Rate me:
Please Sign up or sign in to vote.
4.85/5 (30 votes)
9 Sep 2008CPOL8 min read 186K   19.6K   68  
Blend a First Class Gaming Graphics Engine into your WPF application
using System;
using System.Windows;

namespace OgreLib
{
    public partial class OgreImage
    {
        #region ViewportSize Property

        public static readonly DependencyProperty ViewportSizeProperty =
            DependencyProperty.Register("ViewportSize", typeof(Size), typeof(OgreImage),
                                        new PropertyMetadata(new Size(100, 100), OnViewportProperyChanged)
                );

        private static void OnViewportProperyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var imageSource = (OgreImage)d;

            imageSource._reloadRenderTargetTime = Environment.TickCount;
        }

        public Size ViewportSize
        {
            get { return (Size)GetValue(ViewportSizeProperty); }
            set { SetValue(ViewportSizeProperty, value); }
        }

        #endregion

        #region AutoInitialise Property

        public static readonly DependencyProperty AutoInitialiseProperty =
            DependencyProperty.Register("AutoInitialise", typeof(bool), typeof(OgreImage),
                                        new PropertyMetadata(false));

        public bool AutoInitialise
        {
            get { return (bool)GetValue(AutoInitialiseProperty); }
            set { SetValue(AutoInitialiseProperty, value); }
        }

        #endregion

        #region CreateDefaultScene Property

        public static readonly DependencyProperty CreateDefaultSceneProperty =
            DependencyProperty.Register("CreateDefaultScene", typeof(bool), typeof(OgreImage),
                                        new PropertyMetadata(true));

        public bool CreateDefaultScene
        {
            get { return (bool)GetValue(CreateDefaultSceneProperty); }
            set { SetValue(CreateDefaultSceneProperty, value); }
        }

        #endregion

        #region ResizeRenderTargetDelay Property

        public static readonly DependencyProperty ResizeRenderTargetDelayProperty =
            DependencyProperty.Register("ResizeRenderTargetDelay", typeof(Duration), typeof(OgreImage), 
            new PropertyMetadata(new Duration(new TimeSpan(200))));

        public Duration ResizeRenderTargetDelay
        {
            get { return (Duration)GetValue(ResizeRenderTargetDelayProperty); }
            set { SetValue(ResizeRenderTargetDelayProperty, value); }
        }

        #endregion

        #region FrameRate Property

        public static readonly DependencyProperty FrameRateProperty =
            DependencyProperty.Register("FrameRate", typeof(int?), typeof(OgreImage),
            new PropertyMetadata(FrameRate_Changed));

        private static void FrameRate_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ((OgreImage)d).OnFrameRateChanged((int?)e.NewValue);
        }

        public int? FrameRate
        {
            get { return (int?)GetValue(FrameRateProperty); }
            set { SetValue(FrameRateProperty, value); }
        }

        #endregion

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Lead FNB Connect
South Africa South Africa
iOS Technical Lead at FNB
-

Computers are really sweet. Aren't they?
Yup they are...

I've always loved writing tools and components...never been very interested in playing games....always wanted to be able to write them though.

And, yes. I'm still pretty annoyed they discontinued the Amiga computer.

Comments and Discussions