/// <summary> /// Initializes a new instance of the <see cref="Gorgon2DStateRecall"/> class. /// </summary> /// <param name="renderer">The renderer that is creating this object.</param> internal Gorgon2DStateRecall(Gorgon2D renderer) { Gorgon2D = renderer; _graphics = renderer.Graphics; Save(); }
/// <summary> /// Initializes a new instance of the <see cref="GorgonRectangle"/> class. /// </summary> /// <param name="gorgon2D">Gorgon interface that owns this renderable.</param> /// <param name="name">The name of the rectangle.</param> /// <param name="filled">TRUE to draw a filled rectangle, FALSE to draw an outline.</param> internal GorgonRectangle(Gorgon2D gorgon2D, string name, bool filled) : base(gorgon2D, name) { _colors = new[] { GorgonColor.White, GorgonColor.White, GorgonColor.White, GorgonColor.White }; _corners = new[] { Vector2.Zero, Vector2.Zero, Vector2.Zero, Vector2.Zero }; IsFilled = filled; _filled = gorgon2D.Renderables.CreateSprite("Rectangle.Sprite", new Vector2(1), GorgonColor.White); _line = new GorgonLine(gorgon2D, "Rectangle.Line") { Color = GorgonColor.White, TextureEnd = new Vector2(1), StartPoint = Vector2.Zero, EndPoint = new Vector2(1) }; }
/// <summary> /// Initializes a new instance of the <see cref="GorgonPoint"/> class. /// </summary> /// <param name="gorgon2D">Gorgon interface that owns this renderable.</param> /// <param name="name">The name of the point.</param> internal GorgonPoint(Gorgon2D gorgon2D, string name) : base(name) { CullingMode = CullingMode.Back; Gorgon2D = gorgon2D; _depthState = new GorgonRenderable.DepthStencilStates(); _blendState = new GorgonRenderable.BlendState(); _samplerState = new GorgonRenderable.TextureSamplerState(); _vertices = new [] { new Gorgon2DVertex { Position = new Vector4(0, 0, 0, 1.0f) }, new Gorgon2DVertex { Position = new Vector4(0, 0, 0, 1.0f) }, new Gorgon2DVertex { Position = new Vector4(0, 0, 0, 1.0f) }, new Gorgon2DVertex { Position = new Vector4(0, 0, 0, 1.0f) } }; }
public void TestInitialize() { _form = new TestForm(); _graphics = new GorgonGraphics(); _renderer = _graphics.Output.Create2DRenderer(_form.panelDisplay); _screen = (GorgonSwapChain)_renderer.DefaultTarget; }
/// <summary> /// Initializes a new instance of the <see cref="Gorgon2DVertexCache"/> class. /// </summary> /// <param name="renderer">The renderer.</param> /// <param name="cacheSize">Size of the cache.</param> public Gorgon2DVertexCache(Gorgon2D renderer, int cacheSize) { _renderer = renderer; _vertices = new Gorgon2DVertex[cacheSize]; Enabled = true; CacheSize = cacheSize; }
/// <summary> /// Initializes a new instance of the <see cref="GorgonLine"/> class. /// </summary> /// <param name="gorgon2D">Gorgon interface that owns this renderable.</param> /// <param name="name">The name of the line.</param> internal GorgonLine(Gorgon2D gorgon2D, string name) : base(gorgon2D, name) { _corners = new float[4]; InitializeVertices(4); LineThickness = new Vector2(1); }
/// <summary> /// Initializes a new instance of the <see cref="GorgonMoveable"/> class. /// </summary> /// <param name="gorgon2D">The gorgon 2D interface that created this object.</param> /// <param name="name">The name of the renderable.</param> protected GorgonMoveable(Gorgon2D gorgon2D, string name) : base(gorgon2D, name) { Position = Vector2.Zero; Scale = new Vector2(1.0f); Angle = 0; Anchor = Vector2.Zero; }
/// <summary> /// Initializes a new instance of the <see cref="GorgonSprite" /> class. /// </summary> /// <param name="gorgon2D">The interface that owns this object.</param> /// <param name="name">Name of the sprite.</param> internal GorgonSprite(Gorgon2D gorgon2D, string name) : base(gorgon2D, name) { InitializeVertices(4); _offsets = new[] { Vector2.Zero, Vector2.Zero, Vector2.Zero, Vector2.Zero }; }
/// <summary> /// Initializes a new instance of the <see cref="GorgonTriangle"/> class. /// </summary> /// <param name="gorgon2D">The gorgon 2D interface that created this object.</param> /// <param name="name">The name of the triangle object.</param> internal GorgonTriangle(Gorgon2D gorgon2D, string name) : base(gorgon2D, name) { Scale = new Vector2(1); VertexCount = 3; BaseVertexCount = 3; IsFilled = true; _points = new GorgonPolygonPoint[3]; _line = new GorgonLine(gorgon2D, "Triangle.Line"); InitializeVertices(3); }
/// <summary> /// Initializes a new instance of the <see cref="GorgonRenderable"/> class. /// </summary> /// <param name="gorgon2D">Gorgon 2D interface.</param> /// <param name="name">The name.</param> /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="name"/> parameter is NULL (Nothing in VB.Net). /// <para>-or-</para> /// <para>Thrown when the <paramref name="gorgon2D"/> parameter is NULL.</para> /// </exception> /// <exception cref="System.ArgumentException">Thrown when the <paramref name="name"/> parameter is an empty string.</exception> protected GorgonRenderable(Gorgon2D gorgon2D, string name) : base(name) { GorgonDebug.AssertNull(gorgon2D, "gorgon2D"); Gorgon2D = gorgon2D; CullingMode = CullingMode.Back; AlphaTestValues = GorgonRangeF.Empty; DepthStencil = new DepthStencilStates(); Blending = new BlendState(); TextureSampler = new TextureSamplerState(); BaseVertexCount = 0; }
public void Initialize() { _graphics = new GorgonGraphics(); _testForm = new Form { Text = @"Test 2D" }; _testForm.StartPosition = FormStartPosition.CenterScreen; _testForm.ClientSize = new Size(1280, 800); _testForm.WindowState = FormWindowState.Minimized; _testForm.Show(); _2D = _graphics.Output.Create2DRenderer(_testForm); }
/// <summary> /// Initializes a new instance of the <see cref="Gorgon2DVertexShaderState"/> class. /// </summary> /// <param name="gorgon2D">The gorgon 2D interface that created this object.</param> internal Gorgon2DVertexShaderState(Gorgon2D gorgon2D) : base(gorgon2D.Graphics) { _gorgon2D = gorgon2D; if (DefaultVertexShader == null) { DefaultVertexShader = Graphics.ImmediateContext.Shaders.CreateShader <GorgonVertexShader>("Default_Basic_Vertex_Shader", "GorgonVertexShader", "#GorgonInclude \"Gorgon2DShaders\""); } TransformBuffer = Graphics.ImmediateContext.Buffers.CreateConstantBuffer("Gorgon2D Projection/View Matrix Constant Buffer", new GorgonConstantBufferSettings { SizeInBytes = Matrix.SizeInBytes, }); }
/// <summary> /// Initializes a new instance of the <see cref="Gorgon2DPixelShaderState"/> class. /// </summary> /// <param name="gorgon2D">The gorgon 2D interface that created this object.</param> internal Gorgon2DPixelShaderState(Gorgon2D gorgon2D) : base(gorgon2D.Graphics) { _gorgon2D = gorgon2D; DefaultPixelShaderDiffuse = Graphics.ImmediateContext.Shaders.CreateShader <GorgonPixelShader>("Default_Basic_Pixel_Shader_Diffuse", "GorgonPixelShaderDiffuse", "#GorgonInclude \"Gorgon2DShaders\""); DefaultPixelShaderTextured = Graphics.ImmediateContext.Shaders.CreateShader <GorgonPixelShader>("Default_Basic_Pixel_Shader_Texture", "GorgonPixelShaderTextured", "#GorgonInclude \"Gorgon2DShaders\""); DefaultPixelShaderDiffuseMaterial = Graphics.ImmediateContext.Shaders.CreateShader <GorgonPixelShader>( "Default_Basic_Pixel_Shader_Diffuse_Material", "GorgonPixelShaderDiffuseMaterial", "#GorgonInclude \"Gorgon2DShaders\""); DefaultPixelShaderTexturedMaterial = Graphics.ImmediateContext.Shaders.CreateShader <GorgonPixelShader>( "Default_Basic_Pixel_Shader_Texture_Material", "GorgonPixelShaderTexturedMaterial", "#GorgonInclude \"Gorgon2DShaders\""); var alphaTestValues = new Gorgon2DAlphaTest(gorgon2D.IsAlphaTestEnabled, GorgonRangeF.Empty); AlphaTestValuesBuffer = Graphics.ImmediateContext.Buffers.CreateConstantBuffer("Gorgon2D Alpha Test Constant Buffer", new GorgonConstantBufferSettings { SizeInBytes = DirectAccess.SizeOf <Gorgon2DAlphaTest>() }); // Initialize the alpha testing values. AlphaTestValuesBuffer.Update(ref alphaTestValues); MaterialBuffer = Graphics.ImmediateContext.Buffers.CreateConstantBuffer("Gorgon2D Material Constant Buffer", new GorgonConstantBufferSettings { SizeInBytes = 32, Usage = BufferUsage.Default }); }
/// <summary> /// Initializes a new instance of the <see cref="GorgonDrawing"/> class. /// </summary> /// <param name="gorgon2D">The gorgon 2D interface that owns this object.</param> internal GorgonDrawing(Gorgon2D gorgon2D) { _depthStencil = new GorgonRenderable.DepthStencilStates(); _sampler = new GorgonRenderable.TextureSamplerState(); _blend = new GorgonRenderable.BlendState(); // Default to modulated blending for drawing operations. BlendingMode = BlendingMode.Modulate; CullingMode = CullingMode.Back; _rect = new GorgonRectangle(gorgon2D, "Gorgon2D.Rectangle", false) { Position = Vector2.Zero, Size = Vector2.Zero }; _point = new GorgonPoint(gorgon2D, "Gorgon2D.Point") { Position = Vector2.Zero, Color = GorgonColor.White }; _line = new GorgonLine(gorgon2D, "Gorgon2D.Line") { Color = GorgonColor.White, StartPoint = Vector2.Zero, EndPoint = Vector2.Zero }; _ellipse = new GorgonEllipse(gorgon2D, "Gorgon2D.Ellipse") { Quality = 64, Color = GorgonColor.White }; _triangle = new GorgonTriangle(gorgon2D, "Gorgon2D.Triangle") { IsFilled = false }; _string = gorgon2D.Renderables.CreateText("Gorgon2D.String"); }
/// <summary> /// Initializes a new instance of the <see cref="Gorgon2DPerspectiveCamera"/> class. /// </summary> /// <param name="gorgon2D">The gorgon 2D interface that owns the camera.</param> /// <param name="name">The name of the camera.</param> /// <param name="viewDimensions">The view dimensions.</param> /// <param name="minDepth">The minimum depth value.</param> /// <param name="maximumDepth">The maximum depth of the projection.</param> internal Gorgon2DPerspectiveCamera(Gorgon2D gorgon2D, string name, RectangleF viewDimensions, float minDepth, float maximumDepth) : base(name) { Gorgon2D = gorgon2D; _maxDepth = maximumDepth; _minDepth = minDepth; _viewDimensions = viewDimensions; _cameraIcon = new GorgonSprite(gorgon2D, "GorgonCamera.PerspIcon") { Size = new Vector2(64, 50), Texture = gorgon2D.Graphics.GetTrackedObjectsOfType <GorgonTexture2D>() .FirstOrDefault(item => item.Name.Equals("Gorgon2D.Icons", StringComparison.OrdinalIgnoreCase)) ?? gorgon2D.Graphics.Textures.CreateTexture <GorgonTexture2D>("Gorgon2D.Icons", Resources.Icons), TextureRegion = new RectangleF(0, 0, 0.25f, 0.195313f), Anchor = new Vector2(32f, 25), Scale = new Vector2(1.0f), Color = Color.White }; }
public void CleanUp() { if (_renderer != null) { _renderer.Dispose(); _renderer = null; } if (_screen != null) { _screen.Dispose(); _screen = null; } if (_graphics != null) { _graphics.Dispose(); _graphics = null; } if (_form != null) { _form.Dispose(); _form = null; } }
/// <summary> /// Initializes a new instance of the <see cref="GorgonEllipse"/> class. /// </summary> /// <param name="gorgon2D">The gorgon 2D interface that created this object.</param> /// <param name="name">The name of the object.</param> internal GorgonEllipse(Gorgon2D gorgon2D, string name) : base(gorgon2D, name) { _line = new GorgonLine(gorgon2D, name + ".Line"); Quality = 64; }
/// <summary> /// Initializes a new instance of the <see cref="GorgonRenderables"/> class. /// </summary> /// <param name="gorgon2D">The gorgon 2D interface that owns this object.</param> /// <param name="cache">The vertex cache used by the renderer.</param> internal GorgonRenderables(Gorgon2D gorgon2D, Gorgon2DVertexCache cache) { _gorgon2D = gorgon2D; _cache = cache; }
/// <summary> /// Function to draw the object. /// </summary> /// <remarks>Please note that this doesn't draw the object to the target right away, but queues it up to be /// drawn when <see cref="GorgonLibrary.Renderers.Gorgon2D.Render">Render</see> is called. /// </remarks> public void Draw() { TransformVertices(); Gorgon2D.AddRenderable(this); }
/// <summary> /// Function called when the effect is being initialized. /// </summary> /// <remarks> /// Use this method to set up the effect upon its creation. For example, this method could be used to create the required shaders for the effect. /// <para>When creating a custom effect, use this method to initialize the effect. Do not put initialization code in the effect constructor.</para> /// </remarks> protected override void OnInitialize() { // Retrieve the Gorgon 2D instance for the effect. Gorgon2D = (Gorgon2D)Parameters["Gorgon2D"]; }