/// <summary>
 /// Creates the CullNone rasterizer state.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 /// <returns>The rasterizer state that was created.</returns>
 public static OpenGLRasterizerState CreateCullNone(UltravioletContext uv)
 {
     var state = new OpenGLRasterizerState(uv);
     state.CullMode = CullMode.None;
     state.MakeImmutable();
     return state;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AdornerLayer"/> class.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 /// <param name="name">The element's identifying name within its namescope.</param>
 public AdornerLayer(UltravioletContext uv, String name)
     : base(uv, name)
 {
     adorners = new VisualCollection(this);
     adornersStates = new List<AdornerState>();
     adornersTemp = new List<Adorner>();
 }
        /// <summary>
        /// Initializes a new instance of the OpenGLRenderTarget2D class.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        /// <param name="width">The render target's width in pixels.</param>
        /// <param name="height">The render target's height in pixels.</param>
        /// <param name="usage">A <see cref="RenderTargetUsage"/> value specifying whether the 
        /// render target's data is discarded or preserved when it is bound to the graphics device.</param>
        /// <param name="buffers">The collection of render buffers to attach to the target.</param>
        public OpenGLRenderTarget2D(UltravioletContext uv, Int32 width, Int32 height, RenderTargetUsage usage, IEnumerable<RenderBuffer2D> buffers = null)
            : base(uv)
        {
            Contract.EnsureRange(width > 0, nameof(width));
            Contract.EnsureRange(height > 0, nameof(height));

            // NOTE: If we're in an older version of GLES, we need to use glFramebufferTexture2D()
            glFramebufferTextureIsSupported = !gl.IsGLES || gl.IsVersionAtLeast(3, 2);

            glDrawBuffersIsSupported = !gl.IsGLES2 || gl.IsExtensionSupported("GL_ARB_draw_buffers");
            glDrawBufferIsSupported = !gl.IsGLES;

            var framebuffer = 0u;

            uv.QueueWorkItemAndWait(() =>
            {
                using (OpenGLState.ScopedCreateFramebuffer(out framebuffer))
                {
                    if (buffers != null)
                    {
                        foreach (OpenGLRenderBuffer2D buffer in buffers)
                        {
                            AttachRenderBuffer(buffer);
                        }
                    }
                }
            });

            this.width = width;
            this.height = height;
            this.framebuffer = framebuffer;
            this.renderTargetUsage = usage;
        }
 /// <summary>
 /// Initializes a new instance of the OpenGLUltravioletPlatform class.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 /// <param name="configuration">The Ultraviolet Framework configuration settings for the current context.</param>
 public OpenGLUltravioletPlatform(UltravioletContext uv, OpenGLUltravioletConfiguration configuration)
     : base(uv)
 {
     this.clipboard = new OpenGLUltravioletClipboardInfo();
     this.windows   = new OpenGLUltravioletWindowInfo(uv, configuration);
     this.displays  = new OpenGLUltravioletDisplayInfo();
 }
        /// <inheritdoc/>
        public override void Initialize(UltravioletContext uv, Object configuration)
        {
            var config = (PresentationFoundationConfiguration)configuration ?? new PresentationFoundationConfiguration();

            var upf = uv.GetUI().GetPresentationFoundation();
            upf.BindingExpressionCompilerAssemblyName = config.BindingExpressionCompilerAssembly;
        }
        /// <inheritdoc/>
        public BindingExpressionCompilationResult CompileSingleView(UltravioletContext uv, BindingExpressionCompilerOptions options)
        {
            Contract.Require(options, "options");

            if (String.IsNullOrEmpty(options.Input))
                throw new ArgumentException(PresentationStrings.InvalidCompilerOptions);

            var definition = CreateDataSourceDefinitionFromXml(options.RequestedViewModelNamespace, options.RequestedViewModelName, options.Input);
            if (definition == null)
                return BindingExpressionCompilationResult.CreateSucceeded();

            var state = CreateCompilerState(uv, options);
            var dataSourceWrapperInfo = GetDataSourceWrapperInfo(state, definition.Value);
            var dataSourceWrapperInfos = new[] { dataSourceWrapperInfo };
            
            var result = CompileViewModels(state, dataSourceWrapperInfos, null);
            if (result.Succeeded)
            {
                options.Output = dataSourceWrapperInfos[0].DataSourceWrapperSourceCode;
            }
            else
            {
                DeleteWorkingDirectory(state);
            }

            return result;
        }
        /// <summary>
        /// Initializes a new instance of the OpenGLCursor class.
        /// </summary>
        /// <param name="uv">The UltravioletContext class.</param>
        /// <param name="surface">The surface that contains the cursor image.</param>
        /// <param name="hx">The x-coordinate of the cursor's hotspot.</param>
        /// <param name="hy">The y-coordinate of the cursor's hotspot.</param>
        public OpenGLCursor(UltravioletContext uv, Surface2D surface, Int32 hx, Int32 hy)
            : base(uv)
        {
            Contract.Require(surface, "surface");

            uv.ValidateResource(surface);

            if (AreCursorsSupported(uv))
            {
                this.cursor = SDL.CreateColorCursor(((OpenGLSurface2D)surface).Native, hx, hy);
                this.width  = surface.Width;
                this.height = surface.Height;

                if (this.cursor == null)
                {
                    this.width  = 0;
                    this.height = 0;
                }
            }
            else
            {
                this.cursor = null;
                this.width  = 0;
                this.height = 0;
            }
        }
 /// <summary>
 /// Applies the specified settings.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 public void Apply(UltravioletContext uv)
 {
     if (Window != null)
     {
         Window.Apply(uv);
     }
 }
        /// <inheritdoc/>
        public override void Deactivate(UltravioletContext uv, DependencyObject dobj)
        {
            var element = dobj as UIElement;
            if (element == null || element.View == null)
                return;

            if (selector == null)
            {
                var storyboard = element.View.FindStoryboard(storyboardName);
                if (storyboard == null)
                    return;

                storyboard.Stop(element);
            }
            else
            {
                var rooted = selector.PartCount == 0 ? false :
                    String.Equals(selector[0].PseudoClass, "trigger-root", StringComparison.InvariantCultureIgnoreCase);
                var target = rooted ? dobj as UIElement : null;

                element.View.Select(target, selector, this, (e, s) =>
                {
                    var action = (PlayStoryboardTriggerAction)s;

                    var storyboard = e.View.FindStoryboard(action.storyboardName);
                    if (storyboard != null)
                    {
                        storyboard.Stop(e);
                    }
                });
            }
            base.Deactivate(uv, dobj);
        }
Beispiel #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CustomCompositor"/> class.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        /// <param name="window">The window with which this compositor is associated.</param>
        public CustomCompositor(UltravioletContext uv, IUltravioletWindow window)
            : base(uv, window)
        {
            rtScene = RenderTarget2D.Create(BufferWidth, BufferHeight);

            rtSceneColor = RenderBuffer2D.Create(RenderBufferFormat.Color, BufferWidth, BufferHeight);
            rtScene.Attach(rtSceneColor);

            rtSceneDepthStencil = RenderBuffer2D.Create(RenderBufferFormat.Depth24Stencil8, BufferWidth, BufferHeight);
            rtScene.Attach(rtSceneDepthStencil);

            rtInterface = RenderTarget2D.Create(BufferWidth, BufferHeight);

            rtInterfaceColor = RenderBuffer2D.Create(RenderBufferFormat.Color, BufferWidth, BufferHeight);
            rtInterface.Attach(rtInterfaceColor);

            rtInterfaceDepthStencil = RenderBuffer2D.Create(RenderBufferFormat.Depth24Stencil8, BufferWidth, BufferHeight);
            rtInterface.Attach(rtInterfaceDepthStencil);

            rtComposition = RenderTarget2D.Create(BufferWidth, BufferHeight, RenderTargetUsage.PreserveContents);

            rtCompositionColor = RenderBuffer2D.Create(RenderBufferFormat.Color, BufferWidth, BufferHeight);
            rtComposition.Attach(rtCompositionColor);

            rtCompositionDepthStencil = RenderBuffer2D.Create(RenderBufferFormat.Depth24Stencil8, BufferWidth, BufferHeight);
            rtComposition.Attach(rtCompositionDepthStencil);

            spriteBatch = SpriteBatch.Create();
        }
Beispiel #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Compositor"/> class.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        /// <param name="window">The window with which this compositor is associated.</param>
        public Compositor(UltravioletContext uv, IUltravioletWindow window)
            : base(uv)
        {
            Contract.Require(window, nameof(window));

            this.window = window;
        }
 /// <summary>
 /// Activates the actions in the collection, with the specified dependency object as their implicit target.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 /// <param name="dobj">The dependency object which is the implicit target of the activated actions.</param>
 internal void Activate(UltravioletContext uv, DependencyObject dobj)
 {
     foreach (var action in actions)
     {
         action.Activate(uv, dobj);
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DummyUltravioletPlatform"/> class.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 public DummyUltravioletPlatform(UltravioletContext uv)
     : base(uv)
 {
     this.clipboard = new DummyUltravioletClipboardInfo();
     this.windows = new DummyUltravioletWindowInfo();
     this.displays = new DummyUltravioletDisplayInfo();
 }
        /// <inheritdoc/>
        public BindingExpressionCompilationResult Compile(UltravioletContext uv, BindingExpressionCompilerOptions options)
        {
            Contract.Require(uv, "uv");
            Contract.Require(options, "options");

            if (String.IsNullOrEmpty(options.Input) || String.IsNullOrEmpty(options.Output))
                throw new ArgumentException(PresentationStrings.InvalidCompilerOptions);

            var state = CreateCompilerState(uv, options);
            var dataSourceWrapperInfos = GetDataSourceWrapperInfos(state, uv, options.Input);
            
            var cacheFile = Path.ChangeExtension(options.Output, "cache");
            var cacheNew = CompilerCache.FromDataSourceWrappers(dataSourceWrapperInfos);
            if (File.Exists(options.Output))
            {
                var cacheOld = CompilerCache.TryFromFile(cacheFile);
                if (cacheOld != null && !options.IgnoreCache && !cacheOld.IsDifferentFrom(cacheNew))
                    return BindingExpressionCompilationResult.CreateSucceeded();
            }

            var result = CompileViewModels(state, dataSourceWrapperInfos, options.Output);
            if (result.Succeeded)
            {
                cacheNew.Save(cacheFile);

                if (!options.WriteCompiledFilesToWorkingDirectory && !options.WorkInTemporaryDirectory)
                    DeleteWorkingDirectory(state);
            }

            if (options.WriteCompiledFilesToWorkingDirectory && !options.WorkInTemporaryDirectory)
                WriteCompiledFilesToWorkingDirectory(state, dataSourceWrapperInfos);

            return result;
        }
        /// <summary>
        /// Retrieves DPI information when running on Windows 8.1 and higher.
        /// </summary>
        private Boolean InitWindows8_1(UltravioletContext uv, IUltravioletDisplay display)
        {
            if (uv.Platform != UltravioletPlatform.Windows || Environment.OSVersion.Version < new Version(6, 3))
                return false;

            var rect = new Win32.RECT
            {
                left   = display.Bounds.Left,
                top    = display.Bounds.Top,
                right  = display.Bounds.Right,
                bottom = display.Bounds.Bottom 
            };

            var hmonitor = IntPtr.Zero;

            Win32.EnumDisplayMonitors(IntPtr.Zero, &rect, (hdc, lprcClip, lprcMonitor, dwData) =>
            {
                hmonitor = hdc;
                return false;
            }, IntPtr.Zero);

            if (hmonitor == IntPtr.Zero)
                return false;

            UInt32 x, y;
            Win32.GetDpiForMonitor(hmonitor, 0, out x, out y);

            this.densityX      = x;
            this.densityY      = y;
            this.densityScale  = x / 96f;
            this.densityBucket = GuessBucketFromDensityScale(densityScale);

            return true;
        }
Beispiel #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OutOfBandRenderer"/> class.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        public OutOfBandRenderer(UltravioletContext uv)
            : base(uv)
        {
            this.spriteBatch = SpriteBatch.Create();

            this.drawingContext = new DrawingContext();
            this.drawingContext.SpriteBatch = spriteBatch;
        }
        /// <summary>
        /// Initializes a new instance of the OpenGLEffectPass class.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        /// <param name="name">The effect pass' name.</param>
        /// <param name="programs">The effect pass' collection of shader programs.</param>
        public OpenGLEffectPass(UltravioletContext uv, String name, ICollection<OpenGLShaderProgram> programs)
            : base(uv)
        {
            Contract.RequireNotEmpty(programs, "programs");

            this.name = name ?? String.Empty;
            this.programs = new OpenGLShaderProgramCollection(programs);
        }
Beispiel #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FrameworkElement"/> class.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        /// <param name="name">The identifying name of this element within its layout.</param>
        public FrameworkElement(UltravioletContext uv, String name)
            : base(uv)
        {
            this.name = name;

            this.visualStateGroups = new VisualStateGroupCollection(this);
            this.visualStateGroups.Create("focus", VSGFocus);
        }
        /// <summary>
        /// Registers <see cref="dotTraceProfiler"/> as the profiler for the current Ultraviolet context.
        /// </summary>
        /// <param name="owner">The Ultraviolet context with which to register the profiler.</param>
        /// <param name="factory">The Ultraviolet factory for the Ultraviolet context.</param>
        /// <remarks>This method must be called during the application's initialization phase, before any 
        /// of the static methods on <see cref="UltravioletProfiler"/> have been invoked.</remarks>
        public static void RegisterProfiler(UltravioletContext owner, UltravioletFactory factory)
        {
            Contract.Require(owner, "owner");
            Contract.Require(factory, "factory");

            factory.RemoveFactoryMethod<UltravioletProfilerFactory>();
            factory.SetFactoryMethod<UltravioletProfilerFactory>(uv => new dotTraceProfiler(uv));
        }
        /// <summary>
        /// Initializes a new instance of the OpenGLSurface2D class.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        /// <param name="width">The width of the surface in pixels.</param>
        /// <param name="height">The height of the surface in pixels.</param>
        public OpenGLSurface2D(UltravioletContext uv, Int32 width, Int32 height)
            : base(uv)
        {
            Contract.EnsureRange(width > 0, "width");
            Contract.EnsureRange(height > 0, "height");

            this.nativesurf = new SDL_Surface(width, height);
        }
        /// <summary>
        /// Initializes a new instance of the OpenGLSurface2D class.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        /// <param name="nativesurf">The native SDL surface that this object represents.</param>
        public OpenGLSurface2D(UltravioletContext uv, SDL_Surface nativesurf)
            : base(uv)
        {
            if (nativesurf == null)
                throw new ArgumentNullException("nativesurf");

            this.nativesurf = nativesurf;
        }
Beispiel #22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OpenGLBlurEffect"/> class.
        /// </summary>
        public OpenGLBlurEffect(UltravioletContext uv)
            : base(CreateEffectImplementation(uv))
        {
            epDirection = Parameters["Direction"];
            epResolution = Parameters["Resolution"];

            UpdateDirection();
        }
Beispiel #23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ComboBox"/> class.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        /// <param name="name">The element's identifying name within its namescope.</param>
        public ComboBox(UltravioletContext uv, String name)
            : base(uv, name)
        {
            visualClone = new VisualClone(uv);

            VisualStateGroups.Create("common", new[] { "normal", "hover", "disabled" });
            VisualStateGroups.Create("opened", new[] { "closed", "open" });
        }
 /// <summary>
 /// Creates the None depth/stencil state.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 /// <returns>The depth/stencil state that was created.</returns>
 public static OpenGLDepthStencilState CreateNone(UltravioletContext uv)
 {
     var state = new OpenGLDepthStencilState(uv);
     state.DepthBufferEnable = false;
     state.DepthBufferWriteEnable = false;
     state.MakeImmutable();
     return state;
 }
Beispiel #25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PopupRoot"/> class.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        /// <param name="resized">The action to perform when the popup content is resized.</param>
        public PopupRoot(UltravioletContext uv, Action resized)
            : base(uv, null)
        {
            this.resized = resized;

            this.nonLogicalAdornerDecorator = new NonLogicalAdornerDecorator(uv, null);
            this.nonLogicalAdornerDecorator.ChangeLogicalParent(this);
        }
        /// <summary>
        /// Initializes a new instance of the OpenGLEffectParameter class.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        /// <param name="name">The effect parameter's name.</param>
        /// <param name="type">The effect parameter's uniform type.</param>
        public OpenGLEffectParameter(UltravioletContext uv, String name, UInt32 type)
            : base(uv)
        {
            Contract.Require(name, nameof(name));

            this.name = name ?? String.Empty;
            this.type = type;
        }
        /// <summary>
        /// Creates a set of application settings from the current application state.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        /// <returns>The <see cref="UltravioletApplicationSettings"/> which was retrieved.</returns>
        public static UltravioletActivitySettings FromCurrentSettings(UltravioletContext uv)
        {
            Contract.Require(uv, "uv");

            var settings = new UltravioletActivitySettings();

            return settings;
        }
Beispiel #28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Control"/> class.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        /// <param name="name">The element's identifying name within its namescope.</param>
        public Control(UltravioletContext uv, String name)
            : base(uv, name)
        {
            var upf = uv.GetUI().GetPresentationFoundation();
            dataSourceWrapper = upf.CreateDataSourceWrapperForControl(this);

            LoadComponentRoot();
        }
            /// <summary>
            /// Initializes a new instance of the <see cref="InstantiationContext"/> class.
            /// </summary>
            /// <param name="uv">The Ultraviolet context.</param>
            /// <param name="dataSource">The data source for the current scope.</param>
            /// <param name="dataSourceType">The type of the data source for the current scope.</param>
            private InstantiationContext(UltravioletContext uv, Object dataSource, Type dataSourceType)
            {
                this.Ultraviolet = uv;
                this.Namescope = new Namescope();
                this.DataSource = dataSource;
                this.DataSourceType = dataSourceType;

                FindCompiledBindingExpressions();
            }
        /// <summary>
        /// Creates the effect implementation.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        /// <returns>The effect implementation.</returns>
        private static EffectImplementation CreateEffectImplementation(UltravioletContext uv)
        {
            Contract.Require(uv, "uv");

            var programs   = new[] { new OpenGLShaderProgram(uv, vertShader, fragShader, false) };
            var passes     = new[] { new OpenGLEffectPass(uv, null, programs) };
            var techniques = new[] { new OpenGLEffectTechnique(uv, null, passes) };
            return new OpenGLEffectImplementation(uv, techniques);
        }
Beispiel #31
0
        /// <summary>
        /// Initializes a new instance of the OpenGLRenderBuffer2D class.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        /// <param name="format">The render buffer's format.</param>
        /// <param name="width">The render buffer's width in pixels.</param>
        /// <param name="height">The render buffer's height in pixels.</param>
        /// <param name="options">The render buffer's configuration options.</param>
        public OpenGLRenderBuffer2D(UltravioletContext uv, RenderBufferFormat format, Int32 width, Int32 height, RenderBufferOptions options)
            : base(uv)
        {
            Contract.EnsureRange(width > 0, nameof(width));
            Contract.EnsureRange(height > 0, nameof(height));

            var isSrgb   = (options & RenderBufferOptions.SrgbColor) == RenderBufferOptions.SrgbColor;
            var isLinear = (options & RenderBufferOptions.LinearColor) == RenderBufferOptions.LinearColor;

            if (isSrgb && isLinear)
            {
                throw new ArgumentException(UltravioletStrings.BuffersCannotHaveMultipleEncodings);
            }

            if ((isSrgb || isLinear) && format != RenderBufferFormat.Color)
            {
                throw new ArgumentException(UltravioletStrings.EncodingSpecifiedForNonColorBuffer);
            }

            var caps        = uv.GetGraphics().Capabilities;
            var srgbEncoded = (isLinear ? false : (isSrgb ? true : uv.Properties.SrgbDefaultForRenderBuffer2D)) && caps.SrgbEncodingEnabled;

            this.format           = format;
            this.width            = width;
            this.height           = height;
            this.immutable        = (options & RenderBufferOptions.ImmutableStorage) == RenderBufferOptions.ImmutableStorage;
            this.willNotBeSampled = (options & RenderBufferOptions.WillNotBeSampled) == RenderBufferOptions.WillNotBeSampled;

            if (willNotBeSampled)
            {
                using (var state = OpenGLState.ScopedCreateRenderbuffer(out renderbuffer))
                {
                    AllocateRenderbufferStorage(width, height);
                }
            }
            else
            {
                switch (format)
                {
                case RenderBufferFormat.Color:
                {
                    var texformat         = OpenGLTextureUtil.GetFormatFromBytesPerPixel(4);
                    var texinternalformat = OpenGLTextureUtil.GetInternalFormatFromBytesPerPixel(4, srgbEncoded);
                    this.texture     = new OpenGLTexture2D(uv, texinternalformat, width, height, texformat, gl.GL_UNSIGNED_BYTE, IntPtr.Zero, immutable, true);
                    this.SrgbEncoded = this.texture.SrgbEncoded;
                }
                break;

                case RenderBufferFormat.Depth24Stencil8:
                    this.texture = new OpenGLTexture2D(uv, gl.GL_DEPTH24_STENCIL8, width, height, gl.GL_DEPTH_STENCIL, gl.GL_UNSIGNED_INT_24_8, IntPtr.Zero, immutable, true);
                    break;

                case RenderBufferFormat.Depth32:
                    this.texture = new OpenGLTexture2D(uv, gl.GL_DEPTH_COMPONENT32, width, height, gl.GL_DEPTH_COMPONENT, gl.GL_UNSIGNED_INT, IntPtr.Zero, immutable, true);
                    break;

                case RenderBufferFormat.Depth16:
                    this.texture = new OpenGLTexture2D(uv, gl.GL_DEPTH_COMPONENT16, width, height, gl.GL_DEPTH_COMPONENT, gl.GL_UNSIGNED_SHORT, IntPtr.Zero, immutable, true);
                    break;

                case RenderBufferFormat.Stencil8:
                    this.texture = new OpenGLTexture2D(uv, gl.GL_STENCIL_INDEX8, width, height, gl.GL_STENCIL, gl.GL_UNSIGNED_INT, IntPtr.Zero, immutable, true);
                    break;

                default:
                    throw new NotSupportedException(nameof(format));
                }
            }
        }
Beispiel #32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GamePadDevice"/> class.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 public GamePadDevice(UltravioletContext uv)
     : base(uv)
 {
     AxisDownThreshold = 0.9f;
 }
Beispiel #33
0
 /// <summary>
 /// Initializes a new instance of the OpenGLSpriteBatchEffect class.
 /// </summary>
 public OpenGLSpriteBatchEffect(UltravioletContext uv)
     : base(CreateEffectImplementation(uv))
 {
 }
Beispiel #34
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ListBox"/> class.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 /// <param name="name">The element's identifying name within its namescope.</param>
 public ListBox(UltravioletContext uv, String name)
     : base(uv, name)
 {
     SetValue(SelectedItemsPropertyKey, selectedItems);
 }
 /// <inheritdoc/>
 public void Initialize(UltravioletContext owner, UltravioletFactory factory)
 {
     factory.SetFactoryMethod <SongPlayerFactory>((uv) => new BASSSongPlayer(uv));
     factory.SetFactoryMethod <SoundEffectPlayerFactory>((uv) => new BASSSoundEffectPlayer(uv));
 }
        /// <summary>
        /// Creates the underlying native OpenGL texture with the specified format and data.
        /// </summary>
        private void CreateNativeTexture(UltravioletContext uv, UInt32 internalformat, Int32 width, Int32 height, Int32 depth,
                                         UInt32 format, UInt32 type, void *pixels, Boolean immutable)
        {
            if (uv.IsRunningInServiceMode)
            {
                throw new NotSupportedException(UltravioletStrings.NotSupportedInServiceMode);
            }

            this.width          = width;
            this.height         = height;
            this.depth          = depth;
            this.internalformat = internalformat;
            this.format         = format;
            this.type           = type;
            this.immutable      = immutable;
            this.srgbEncoded    =
                internalformat == gl.GL_SRGB ||
                internalformat == gl.GL_SRGB_ALPHA ||
                internalformat == gl.GL_SRGB8 ||
                internalformat == gl.GL_SRGB8_ALPHA8;

            this.texture = uv.QueueWorkItem(state =>
            {
                uint glname;

                using (OpenGLState.ScopedCreateTexture3D(out glname))
                {
                    if (gl.IsTextureMaxLevelSupported)
                    {
                        gl.TextureParameteri(glname, gl.GL_TEXTURE_3D, gl.GL_TEXTURE_MAX_LEVEL, 0);
                        gl.ThrowIfError();
                    }

                    gl.TextureParameteri(glname, gl.GL_TEXTURE_3D, gl.GL_TEXTURE_MIN_FILTER, (int)gl.GL_LINEAR);
                    gl.ThrowIfError();

                    gl.TextureParameteri(glname, gl.GL_TEXTURE_3D, gl.GL_TEXTURE_MAG_FILTER, (int)gl.GL_LINEAR);
                    gl.ThrowIfError();

                    gl.TextureParameteri(glname, gl.GL_TEXTURE_3D, gl.GL_TEXTURE_WRAP_R, (int)gl.GL_CLAMP_TO_EDGE);
                    gl.ThrowIfError();

                    gl.TextureParameteri(glname, gl.GL_TEXTURE_3D, gl.GL_TEXTURE_WRAP_S, (int)gl.GL_CLAMP_TO_EDGE);
                    gl.ThrowIfError();

                    gl.TextureParameteri(glname, gl.GL_TEXTURE_3D, gl.GL_TEXTURE_WRAP_T, (int)gl.GL_CLAMP_TO_EDGE);
                    gl.ThrowIfError();

                    if (immutable)
                    {
                        if (gl.IsTextureStorageAvailable)
                        {
                            gl.TextureStorage3D(glname, gl.GL_TEXTURE_3D, 1, internalformat, width, height, depth);
                            gl.ThrowIfError();

                            if (pixels != null)
                            {
                                gl.TextureSubImage3D(glname, gl.GL_TEXTURE_3D, 0, 0, 0, 0, width, height, depth, format, type, pixels);
                                gl.ThrowIfError();
                            }
                        }
                        else
                        {
                            gl.TextureImage3D(glname, gl.GL_TEXTURE_3D, 0, (int)internalformat, width, height, depth, 0, format, type, pixels);
                            gl.ThrowIfError();
                        }
                    }
                }

                if (!immutable)
                {
                    using (OpenGLState.ScopedBindTexture3D(glname, true))
                    {
                        gl.TexImage3D(gl.GL_TEXTURE_3D, 0, (int)internalformat, width, height, depth, 0, format, type, pixels);
                        gl.ThrowIfError();
                    }
                }

                return(glname);
            }).Result;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="TouchState"/> class.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 public TouchState(UltravioletContext uv)
     : base(uv)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DynamicVertexBuffer"/> class.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 /// <param name="vdecl">The vertex declaration for the buffer.</param>
 /// <param name="vcount">The number of vertices in the buffer.</param>
 public DynamicVertexBuffer(UltravioletContext uv, VertexDeclaration vdecl, Int32 vcount)
     : base(uv, vdecl, vcount)
 {
 }
Beispiel #39
0
 /// <summary>
 /// Handles the Ultraviolet context's Updating event.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 /// <param name="time">Time elapsed since the last call to Update.</param>
 private void uv_Updating(UltravioletContext uv, UltravioletTime time)
 {
     OnUpdating(time);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="WeakReferencePool"/> class.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 public WeakReferencePool(UltravioletContext uv)
     : base(uv)
 {
 }
Beispiel #41
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Image"/> class.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 /// <param name="name">The element's identifying name within its namescope.</param>
 public Image(UltravioletContext uv, String name)
     : base(uv, name)
 {
 }
Beispiel #42
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Decorator"/> class.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 /// <param name="name">The element's identifying name within its namescope.</param>
 public Decorator(UltravioletContext uv, String name)
     : base(uv, name)
 {
 }
Beispiel #43
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SpriteFont"/> class.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 /// <param name="face">The <see cref="SpriteFontFace"/> that constitutes the font.</param>
 public SpriteFont(UltravioletContext uv, SpriteFontFace face)
     : this(uv, face, face, face, face)
 {
 }
 /// <summary>
 /// Initializes a new instance of the GameInputActions class.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 public GameInputActions(UltravioletContext uv)
     : base(uv)
 {
 }
Beispiel #45
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Rectangle"/> class.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 /// <param name="name">The element's identifying name within its namescope.</param>
 public Rectangle(UltravioletContext uv, String name)
     : base(uv, name)
 {
 }
Beispiel #46
0
 /// <summary>
 /// Called when the application is being shut down.
 /// </summary>
 private void uv_Shutdown(UltravioletContext uv)
 {
     OnShutdown();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="OpenGLTexture3D"/> class.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 /// <param name="internalformat">The texture's internal format.</param>
 /// <param name="width">The texture's width in pixels.</param>
 /// <param name="height">The texture's height in pixels.</param>
 /// <param name="format">The texture's texel format.</param>
 /// <param name="type">The texture's texel type.</param>
 /// <param name="data">A list of pointers to the raw pixel data for each of the texture's layers.</param>
 /// <param name="immutable">A value indicating whether to use immutable texture storage.</param>
 public OpenGLTexture3D(UltravioletContext uv, UInt32 internalformat, Int32 width, Int32 height, UInt32 format, UInt32 type, IList <IntPtr> data, Boolean immutable)
     : this(uv, internalformat, width, height, format, type, data, immutable, false)
 {
 }
Beispiel #48
0
 /// <inheritdoc/>
 public override Object InstantiateValue(UltravioletContext uv, Object instance, UvmlInstantiationContext context)
 {
     return(eventHandler.Instantiate(uv, context));
 }
Beispiel #49
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DiagnosticsPanel"/> class.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 public DiagnosticsPanel(UltravioletContext uv)
     : base(uv)
 {
 }
Beispiel #50
0
        /// <inheritdoc/>
        public override void Mutate(UltravioletContext uv, Object instance, UvmlInstantiationContext context)
        {
            var value = InstantiateValue(uv, instance, context);

            Mutate(uv, instance, value, context);
        }
Beispiel #51
0
 public Actions(UltravioletContext uv)
     : base(uv)
 {
 }
Beispiel #52
0
 /// <summary>
 /// Initializes a new instance of the OpenGLTexture2D class.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 /// <param name="width">The texture's width in pixels.</param>
 /// <param name="height">The texture's height in pixels.</param>
 /// <param name="options">The texture's configuration options.</param>
 /// <returns>The instance of Texture2D that was created.</returns>
 public OpenGLTexture2D(UltravioletContext uv, Int32 width, Int32 height, TextureOptions options)
     : this(uv, IntPtr.Zero, width, height, 4, options)
 {
 }
Beispiel #53
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TabControl"/> class.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 /// <param name="name">The element's identifying name within its namescope.</param>
 public TabControl(UltravioletContext uv, String name)
     : base(uv, name)
 {
     Classes.Add("top");
 }
Beispiel #54
0
 /// <summary>
 /// Initializes a new instance of the OpenGLTexture2D class.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 /// <param name="internalformat">The texture's internal format.</param>
 /// <param name="width">The texture's width in pixels.</param>
 /// <param name="height">The texture's height in pixels.</param>
 /// <param name="format">The texture's texel format.</param>
 /// <param name="type">The texture's texel type.</param>
 /// <param name="data">The texture's data.</param>
 /// <param name="immutable">A value indicating whether to use immutable texture storage.</param>
 /// <param name="rbuffer">A value indicating whether this texture is being used as a render buffer.</param>
 /// <returns>The instance of Texture2D that was created.</returns>
 internal OpenGLTexture2D(UltravioletContext uv, UInt32 internalformat, Int32 width, Int32 height, UInt32 format, UInt32 type, IntPtr data, Boolean immutable, Boolean rbuffer)
     : base(uv)
 {
     this.rbuffer = rbuffer;
     CreateNativeTexture(uv, internalformat, width, height, format, type, (void *)data, immutable);
 }
Beispiel #55
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PoolImpl"/> class.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 /// <param name="capacity">The pool's initial capacity.</param>
 /// <param name="watermark">The pool's high watermark value.</param>
 /// <param name="allocator">The pool's allocator function.</param>
 public PoolImpl(UltravioletContext uv, Int32 capacity, Int32 watermark, Func <StoryboardInstance> allocator)
     : base(uv, capacity, watermark, allocator)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="InputDevice"/> class.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 internal InputDevice(UltravioletContext uv)
     : base(uv)
 {
 }
 /// <summary>
 /// Initializes a new instance of the OpenGLDepthStencilState class.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 public OpenGLDepthStencilState(UltravioletContext uv)
     : base(uv)
 {
 }
Beispiel #58
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Thumb"/> class.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 /// <param name="name">The element's identifying name within its namescope.</param>
 public Thumb(UltravioletContext uv, String name)
     : base(uv, name)
 {
     VisualStateGroups.Create("common", new[] { "normal", "hover", "pressed", "disabled" });
 }
Beispiel #59
0
        /// <summary>
        /// Creates a new instance of the <see cref="DefaultCompositor"/> class.
        /// </summary>
        /// <param name="window">The window with which the created compositor is associated.</param>
        /// <returns>The instance of <see cref="DefaultCompositor"/> that was created.</returns>
        public static DefaultCompositor Create(IUltravioletWindow window)
        {
            var uv = UltravioletContext.DemandCurrent();

            return(new DefaultCompositor(uv, window));
        }
Beispiel #60
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultCompositor"/> class.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 /// <param name="window">The window with which this compositor is associated.</param>
 public DefaultCompositor(UltravioletContext uv, IUltravioletWindow window)
     : base(uv, window)
 {
 }