/// <summary> /// Initializes a new instance of the <see cref="PrimitiveQuad" /> class with a particular effect. /// </summary> /// <param name="graphicsDevice">The graphics device.</param> /// <param name="effect">The effect.</param> public PrimitiveQuad(GraphicsDevice graphicsDevice, Effect effect) { GraphicsDevice = graphicsDevice; simpleEffect = effect; simpleEffect.Parameters.Set(SpriteBaseKeys.MatrixTransform, Matrix.Identity); sharedData = GraphicsDevice.GetOrCreateSharedData(GraphicsDeviceSharedDataType.PerDevice, "PrimitiveQuad::VertexBuffer", () => new SharedData(GraphicsDevice, simpleEffect.InputSignature)); }
protected BatchBase(GraphicsDevice device, Shaders.EffectBytecode defaultEffectByteCode, ResourceBufferInfo resourceBufferInfo, VertexDeclaration vertexDeclaration, int indexSize = sizeof(short)) { if (resourceBufferInfo == null) { throw new ArgumentNullException("resourceBufferInfo"); } if (vertexDeclaration == null) { throw new ArgumentNullException("vertexDeclaration"); } GraphicsDevice = device; DefaultEffect = new Effect(device, defaultEffectByteCode) { Name = "BatchDefaultEffect" }; drawsQueue = new ElementInfo[resourceBufferInfo.BatchCapacity]; drawTextures = new DrawTextures[resourceBufferInfo.BatchCapacity]; TextureComparer = new TextureIdComparer(); BackToFrontComparer = new SpriteBackToFrontComparer(); FrontToBackComparer = new SpriteFrontToBackComparer(); // set the vertex layout and size indexStructSize = indexSize; this.vertexDeclaration = vertexDeclaration; vertexStructSize = vertexDeclaration.CalculateSize(); parameters = new ParameterCollection(); // Creates the vertex buffer (shared by within a device context). ResourceContext = GraphicsDevice.GetOrCreateSharedData(GraphicsDeviceSharedDataType.PerContext, resourceBufferInfo.ResourceKey, () => new DeviceResourceContext(GraphicsDevice, DefaultEffect, vertexDeclaration, resourceBufferInfo, indexStructSize)); }
/// <summary> /// Initializes a new instance of the <see cref="PrimitiveQuad" /> class with a particular effect. /// </summary> /// <param name="graphicsDevice">The graphics device.</param> /// <param name="effect">The effect.</param> public PrimitiveQuad(GraphicsDevice graphicsDevice, Effect effect) { GraphicsDevice = graphicsDevice; simpleEffect = effect; parameters = new ParameterCollection(); parameters.Set(SpriteBaseKeys.MatrixTransform, Matrix.Identity); parameterCollectionGroup = new EffectParameterCollectionGroup(graphicsDevice, simpleEffect, new[] { parameters }); sharedData = GraphicsDevice.GetOrCreateSharedData(GraphicsDeviceSharedDataType.PerDevice, "PrimitiveQuad::VertexBuffer", d => new SharedData(GraphicsDevice, simpleEffect.InputSignature)); }
/// <summary> /// Initializes a new instance of the <see cref="PrimitiveQuad" /> class with a particular effect. /// </summary> /// <param name="graphicsDevice">The graphics device.</param> /// <param name="effect">The effect.</param> public PrimitiveQuad(GraphicsDevice graphicsDevice, Effect effect) { GraphicsDevice = graphicsDevice; simpleEffect = effect; parameters = new ParameterCollection(); parameters.Set(SpriteBaseKeys.MatrixTransform, Matrix.Identity); parameterCollectionGroup = new EffectParameterCollectionGroup(graphicsDevice, simpleEffect, new[] { parameters }); sharedData = GraphicsDevice.GetOrCreateSharedData(GraphicsDeviceSharedDataType.PerDevice, "PrimitiveQuad::VertexBuffer", d => new SharedData(GraphicsDevice, simpleEffect.InputSignature)); }
public static Texture GetSharedWhiteTexture(this GraphicsDevice device) { return(device.GetOrCreateSharedData(GraphicsDeviceSharedDataType.PerDevice, "WhiteTexture", CreateWhiteTexture)); }
public static EffectProgram New(GraphicsDevice graphicsDevice, EffectBytecode bytecode) { var effectProgramLibrary = graphicsDevice.GetOrCreateSharedData(GraphicsDeviceSharedDataType.PerDevice, typeof(EffectProgram), d => new EffectProgramLibrary()); return(effectProgramLibrary.GetOrCreateShader(graphicsDevice, bytecode)); }
public static EffectProgram New(GraphicsDevice graphicsDevice, EffectBytecode bytecode) { var effectProgramLibrary = graphicsDevice.GetOrCreateSharedData(GraphicsDeviceSharedDataType.PerDevice, typeof(EffectProgram), d => new EffectProgramLibrary()); return effectProgramLibrary.GetOrCreateShader(graphicsDevice, bytecode); }