changed graphics device and renderers in preparation for a second device to render an images list, also added form and control for images list (TextureBrowserForm and ImageBrowser)

This commit is contained in:
codeimp 2007-10-31 20:34:09 +00:00
parent da829ebc0a
commit efc1a88112
21 changed files with 687 additions and 62 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View file

@ -105,6 +105,12 @@
<Compile Include="Interface\DelayedForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Interface\ImageBrowser.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Interface\ImageBrowser.Designer.cs">
<DependentUpon>ImageBrowser.cs</DependentUpon>
</Compile>
<Compile Include="Interface\LinedefInfoPanel.cs">
<SubType>UserControl</SubType>
</Compile>
@ -153,6 +159,12 @@
<Compile Include="Interface\SectorInfoPanel.Designer.cs">
<DependentUpon>SectorInfoPanel.cs</DependentUpon>
</Compile>
<Compile Include="Interface\TextureBrowserForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Interface\TextureBrowserForm.Designer.cs">
<DependentUpon>TextureBrowserForm.cs</DependentUpon>
</Compile>
<Compile Include="Interface\ThingInfoPanel.cs">
<SubType>UserControl</SubType>
</Compile>
@ -201,7 +213,7 @@
<Compile Include="Rendering\Display2DShader.cs" />
<Compile Include="Rendering\ColorCollection.cs" />
<Compile Include="Rendering\ColorSetting.cs" />
<Compile Include="Rendering\D3DGraphics.cs" />
<Compile Include="Rendering\D3DDevice.cs" />
<Compile Include="Data\ImageData.cs" />
<Compile Include="Rendering\D3DShader.cs" />
<Compile Include="Rendering\FlatVertex.cs" />
@ -281,6 +293,10 @@
<SubType>Designer</SubType>
<DependentUpon>DelayedForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Interface\ImageBrowser.resx">
<SubType>Designer</SubType>
<DependentUpon>ImageBrowser.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Interface\LinedefInfoPanel.resx">
<SubType>Designer</SubType>
<DependentUpon>LinedefInfoPanel.cs</DependentUpon>
@ -297,6 +313,10 @@
<SubType>Designer</SubType>
<DependentUpon>SectorInfoPanel.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Interface\TextureBrowserForm.resx">
<SubType>Designer</SubType>
<DependentUpon>TextureBrowserForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Interface\ThingInfoPanel.resx">
<SubType>Designer</SubType>
<DependentUpon>ThingInfoPanel.cs</DependentUpon>

View file

@ -51,6 +51,7 @@ namespace CodeImp.DoomBuilder.Controls
public const string LINEDEFSMODE = "linedefsmode";
public const string SECTORSMODE = "sectorsmode";
public const string THINGSMODE = "thingsmode";
public const string TESTACTION = "testaction";
#endregion

View file

@ -68,6 +68,8 @@ namespace CodeImp.DoomBuilder.Data
#region ================== Properties
public Playpal Palette { get { return palette; } }
public ICollection<ImageData> Textures { get { return textures.Values; } }
public ICollection<ImageData> Flats { get { return flats.Values; } }
public bool IsDisposed { get { return isdisposed; } }
public bool IsLoading { get { return (backgroundloader != null) && backgroundloader.IsAlive; } }

View file

@ -53,6 +53,8 @@ namespace CodeImp.DoomBuilder.Data
// Initialize
General.WriteLogLine("Opening PK3 resource '" + location.location + "'");
//TEST
/*
ZipInputStream z = new ZipInputStream(File.Open(dl.location, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
ZipEntry ze;
while((ze = z.GetNextEntry()) != null)
@ -61,6 +63,7 @@ namespace CodeImp.DoomBuilder.Data
}
z.Dispose();
*/
// We have no destructor
GC.SuppressFinalize(this);

View file

@ -68,7 +68,7 @@ namespace CodeImp.DoomBuilder.Editing
public ClassicMode()
{
// Initialize
this.renderer = General.Map.Graphics.Renderer2D;
this.renderer = General.Map.Renderer2D;
}
// Diposer

View file

@ -935,6 +935,14 @@ namespace CodeImp.DoomBuilder
}
#endregion
[Action(Action.TESTACTION)]
public static void TestAction()
{
TextureBrowserForm t = new TextureBrowserForm();
t.ShowDialog(mainwindow);
t.Dispose();
}
}
}

View file

@ -71,7 +71,9 @@ namespace CodeImp.DoomBuilder
private GameConfiguration config;
private DataManager data;
private EditMode mode;
private D3DGraphics graphics;
private D3DDevice graphics;
private Renderer2D renderer2d;
private Renderer3D renderer3d;
private WAD tempwad;
private MapSelection selection;
@ -91,7 +93,9 @@ namespace CodeImp.DoomBuilder
public DataManager Data { get { return data; } }
public bool IsChanged { get { return changed; } set { changed |= value; } }
public bool IsDisposed { get { return isdisposed; } }
public D3DGraphics Graphics { get { return graphics; } }
public D3DDevice Graphics { get { return graphics; } }
public Renderer2D Renderer2D { get { return renderer2d; } }
public Renderer3D Renderer3D { get { return renderer3d; } }
public GameConfiguration Config { get { return config; } }
public MapSelection Selection { get { return selection; } }
@ -129,6 +133,8 @@ namespace CodeImp.DoomBuilder
General.WriteLogLine("Unloading map data...");
map.Dispose();
General.WriteLogLine("Stopping graphics device...");
renderer2d.Dispose();
renderer3d.Dispose();
graphics.Dispose();
// Remove temp file
@ -174,9 +180,13 @@ namespace CodeImp.DoomBuilder
// Initiate graphics
General.WriteLogLine("Initializing graphics device...");
graphics = new D3DGraphics(General.MainWindow.Display);
graphics = new D3DDevice(General.MainWindow.Display);
if(!graphics.Initialize()) return false;
// Create renderers
renderer2d = new Renderer2D(graphics);
renderer3d = new Renderer3D(graphics);
// Load game configuration
General.WriteLogLine("Loading game configuration...");
configinfo = General.GetConfigurationInfo(options.ConfigFile);
@ -238,9 +248,13 @@ namespace CodeImp.DoomBuilder
// Initiate graphics
General.WriteLogLine("Initializing graphics device...");
graphics = new D3DGraphics(General.MainWindow.Display);
graphics = new D3DDevice(General.MainWindow.Display);
if(!graphics.Initialize()) return false;
// Create renderers
renderer2d = new Renderer2D(graphics);
renderer3d = new Renderer3D(graphics);
// Load game configuration
General.WriteLogLine("Loading game configuration...");
configinfo = General.GetConfigurationInfo(options.ConfigFile);

View file

@ -0,0 +1,88 @@
namespace CodeImp.DoomBuilder.Interface
{
partial class ImageBrowser
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if(disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.splitter = new System.Windows.Forms.SplitContainer();
this.rendertarget = new CodeImp.DoomBuilder.Interface.RenderTargetControl();
this.splitter.Panel1.SuspendLayout();
this.splitter.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.rendertarget)).BeginInit();
this.SuspendLayout();
//
// splitter
//
this.splitter.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitter.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
this.splitter.IsSplitterFixed = true;
this.splitter.Location = new System.Drawing.Point(0, 0);
this.splitter.Name = "splitter";
this.splitter.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitter.Panel1
//
this.splitter.Panel1.Controls.Add(this.rendertarget);
this.splitter.Size = new System.Drawing.Size(518, 346);
this.splitter.SplitterDistance = 310;
this.splitter.TabIndex = 0;
this.splitter.TabStop = false;
//
// rendertarget
//
this.rendertarget.BackColor = System.Drawing.SystemColors.Window;
this.rendertarget.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.rendertarget.Dock = System.Windows.Forms.DockStyle.Fill;
this.rendertarget.Location = new System.Drawing.Point(0, 0);
this.rendertarget.Name = "rendertarget";
this.rendertarget.Size = new System.Drawing.Size(518, 310);
this.rendertarget.TabIndex = 0;
this.rendertarget.TabStop = false;
//
// ImageBrowser
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 14F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.splitter);
this.DoubleBuffered = true;
this.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Name = "ImageBrowser";
this.Size = new System.Drawing.Size(518, 346);
this.splitter.Panel1.ResumeLayout(false);
this.splitter.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.rendertarget)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.SplitContainer splitter;
private RenderTargetControl rendertarget;
}
}

View file

@ -0,0 +1,97 @@
#region ================== Copyright (c) 2007 Pascal vd Heiden
/*
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#endregion
#region ================== Namespaces
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
using System.Diagnostics;
using CodeImp.DoomBuilder.Controls;
using CodeImp.DoomBuilder.Data;
using CodeImp.DoomBuilder.Config;
#endregion
namespace CodeImp.DoomBuilder.Interface
{
public partial class ImageBrowser : UserControl
{
#region ================== Constants
private const int ITEM_WIDTH = 80;
private const int ITEM_HEIGHT = 92;
#endregion
#region ================== Variables
// Number of items horizontally
private int numitemswidth;
#endregion
#region ================== Properties
#endregion
#region ================== Constructor / Disposer
// Constructor
public ImageBrowser()
{
// Make items list
// Initialize
InitializeComponent();
}
#endregion
#region ================== Events
// When resized
protected override void OnResize(EventArgs e)
{
// Call base
base.OnResize(e);
}
#endregion
#region ================== Controls
#endregion
#region ================== Methods
// This adds an item
public void Add(string name, ImageData image, object tag)
{
// Make new item
// Add item to list
}
#endregion
}
}

View file

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View file

@ -0,0 +1,65 @@
namespace CodeImp.DoomBuilder.Interface
{
partial class TextureBrowserForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if(disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textures = new CodeImp.DoomBuilder.Interface.ImageBrowser();
this.SuspendLayout();
//
// textures
//
this.textures.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textures.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.textures.Location = new System.Drawing.Point(12, 12);
this.textures.Name = "textures";
this.textures.Size = new System.Drawing.Size(523, 350);
this.textures.TabIndex = 0;
//
// TextureBrowserForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(547, 374);
this.Controls.Add(this.textures);
this.DoubleBuffered = true;
this.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.MinimizeBox = false;
this.Name = "TextureBrowserForm";
this.ShowIcon = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Browse Textures";
this.ResumeLayout(false);
}
#endregion
private ImageBrowser textures;
}
}

View file

@ -0,0 +1,50 @@
#region ================== Copyright (c) 2007 Pascal vd Heiden
/*
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#endregion
#region ================== Namespaces
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
using System.Diagnostics;
using CodeImp.DoomBuilder.Controls;
using CodeImp.DoomBuilder.Data;
using CodeImp.DoomBuilder.Config;
#endregion
namespace CodeImp.DoomBuilder.Interface
{
public partial class TextureBrowserForm : DelayedForm
{
// Constructor
public TextureBrowserForm()
{
// Initialize
InitializeComponent();
// Add all textures
foreach(ImageData img in General.Map.Data.Textures)
{
textures.Add(img.Name, img, img);
}
}
}
}

View file

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -36,7 +36,7 @@ using CodeImp.DoomBuilder.Interface;
namespace CodeImp.DoomBuilder.Rendering
{
public class D3DGraphics : IDisposable
public class D3DDevice : IDisposable
{
#region ================== Constants
@ -54,8 +54,6 @@ namespace CodeImp.DoomBuilder.Rendering
private RenderTargetControl rendertarget;
private Capabilities devicecaps;
private Device device;
private Renderer2D renderer2d;
private Renderer3D renderer3d;
private Viewport viewport;
private List<ID3DResource> resources;
private ShaderManager shaders;
@ -71,8 +69,6 @@ namespace CodeImp.DoomBuilder.Rendering
public Device Device { get { return device; } }
public bool IsDisposed { get { return isdisposed; } }
public Renderer2D Renderer2D { get { return renderer2d; } }
public Renderer3D Renderer3D { get { return renderer3d; } }
public RenderTargetControl RenderTarget { get { return rendertarget; } }
public Viewport Viewport { get { return viewport; } }
public ShaderManager Shaders { get { return shaders; } }
@ -84,7 +80,7 @@ namespace CodeImp.DoomBuilder.Rendering
#region ================== Constructor / Disposer
// Constructor
public D3DGraphics(RenderTargetControl rendertarget)
public D3DDevice(RenderTargetControl rendertarget)
{
// Set render target
this.rendertarget = rendertarget;
@ -105,8 +101,6 @@ namespace CodeImp.DoomBuilder.Rendering
// Clean up
foreach(ID3DResource res in resources) res.UnloadResource();
if(shaders != null) shaders.Dispose();
renderer2d.Dispose();
renderer3d.Dispose();
rendertarget = null;
if(backbuffer != null) backbuffer.Dispose();
if(depthbuffer != null) depthbuffer.Dispose();
@ -188,10 +182,6 @@ namespace CodeImp.DoomBuilder.Rendering
// Get the viewport
viewport = device.Viewport;
// Setup shaders
if(shaders != null) shaders.Dispose();
shaders = new ShaderManager();
}
#endregion
@ -247,10 +237,9 @@ namespace CodeImp.DoomBuilder.Rendering
// Add event to cancel resize event
//device.DeviceResizing += new CancelEventHandler(CancelResize);
// Create renderers
renderer2d = new Renderer2D(this);
renderer3d = new Renderer3D(this);
// Create shader manager
shaders = new ShaderManager();
// Initialize settings
SetupSettings();
@ -316,9 +305,6 @@ namespace CodeImp.DoomBuilder.Rendering
// Unload all Direct3D resources
foreach(ID3DResource res in resources) res.UnloadResource();
if(shaders != null) shaders.Dispose();
if(backbuffer != null) backbuffer.Dispose();
if(depthbuffer != null) depthbuffer.Dispose();
// Make present parameters
displaypp = CreatePresentParameters(adapter);
@ -349,7 +335,7 @@ namespace CodeImp.DoomBuilder.Rendering
#region ================== Rendering
// This begins a drawing session
public bool StartRendering(bool clear, int backcolor)
public bool StartRendering(bool clear, int backcolor, Surface target, Surface depthbuffer)
{
CooperativeLevel coopresult;
@ -372,8 +358,18 @@ namespace CodeImp.DoomBuilder.Rendering
return false;
}
// Set rendertarget
device.SetDepthStencilSurface(depthbuffer);
device.SetRenderTarget(0, target);
// Clear the screen
if(clear) device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, backcolor, 1f, 0);
if(clear)
{
if(depthbuffer != null)
device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, backcolor, 1f, 0);
else
device.Clear(ClearFlags.Target, backcolor, 1f, 0);
}
// Ready to render
device.BeginScene();
@ -387,20 +383,28 @@ namespace CodeImp.DoomBuilder.Rendering
}
// This ends a drawing session
public void FinishRendering(bool present)
public void FinishRendering()
{
try
{
// Done
device.EndScene();
// Display the scene
if(present) device.Present();
}
// Errors are not a problem here
catch(Exception) { }
}
// This presents what has been drawn
public void Present()
{
try
{
device.Present();
}
// Errors are not a problem here
catch(Exception) { }
}
#endregion
#region ================== Tools

View file

@ -35,7 +35,7 @@ namespace CodeImp.DoomBuilder.Rendering
#region ================== Variables
// Graphics
protected D3DGraphics graphics;
protected D3DDevice graphics;
// Disposing
protected bool isdisposed = false;
@ -52,7 +52,7 @@ namespace CodeImp.DoomBuilder.Rendering
#region ================== Constructor / Disposer
// Constructor
public Renderer(D3DGraphics g)
public Renderer(D3DDevice g)
{
// Initialize
this.graphics = g;

View file

@ -108,7 +108,7 @@ namespace CodeImp.DoomBuilder.Rendering
#region ================== Constructor / Disposer
// Constructor
public Renderer2D(D3DGraphics graphics) : base(graphics)
public Renderer2D(D3DDevice graphics) : base(graphics)
{
// Initialize
thingtexture = new ResourceImage("Thing2D.png");
@ -145,7 +145,7 @@ namespace CodeImp.DoomBuilder.Rendering
public void Present()
{
// Start drawing
if(graphics.StartRendering(true, General.Colors.Background.ToInt()))
if(graphics.StartRendering(true, General.Colors.Background.ToInt(), graphics.BackBuffer, graphics.DepthBuffer))
{
// Renderstates that count for this whole sequence
graphics.Device.SetRenderState(RenderState.CullMode, Cull.None);
@ -260,7 +260,7 @@ namespace CodeImp.DoomBuilder.Rendering
windowsize.Height = graphics.RenderTarget.ClientSize.Height;
// Create rendertargets textures
structtex = new Texture(graphics.Device, windowsize.Width, windowsize.Height, 1, Usage.Dynamic, Format.A8R8G8B8, Pool.Default);
structtex = new Texture(graphics.Device, windowsize.Width, windowsize.Height, 1, Usage.None, Format.A8R8G8B8, Pool.Managed);
thingstex = new Texture(graphics.Device, windowsize.Width, windowsize.Height, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default);
// Get the real surface sizes
@ -595,17 +595,11 @@ namespace CodeImp.DoomBuilder.Rendering
// This begins a drawing session
public unsafe bool StartRendering(bool clearstructs, bool clearthings)
{
LockFlags lockflags;
// Rendertargets available?
if((structtex != null) && (thingstex != null))
{
// Determine lock requirements
if(clearstructs) lockflags = LockFlags.Discard | LockFlags.NoSystemLock;
else lockflags = LockFlags.NoSystemLock;
// Lock structures rendertarget memory
structlocked = structtex.LockRectangle(0, lockflags);
structlocked = structtex.LockRectangle(0, LockFlags.NoSystemLock);
// Create structures plotter
plotter = new Plotter((PixelColor*)structlocked.Data.DataPointer.ToPointer(), structlocked.Pitch / sizeof(PixelColor), structsize.Height, structsize.Width, structsize.Height);
@ -619,10 +613,7 @@ namespace CodeImp.DoomBuilder.Rendering
// Set the rendertarget to the things texture
thingssurface = thingstex.GetSurfaceLevel(0);
graphics.Device.SetDepthStencilSurface(null);
graphics.Device.SetRenderTarget(0, thingssurface);
if(clearthings) graphics.Device.Clear(ClearFlags.Target, 0, 1f, 0);
if(graphics.StartRendering(false, 0))
if(graphics.StartRendering(clearthings, 0, thingssurface, null))
{
// Ready for rendering
return true;

View file

@ -49,7 +49,7 @@ namespace CodeImp.DoomBuilder.Rendering
#region ================== Constructor / Disposer
// Constructor
public Renderer3D(D3DGraphics graphics) : base(graphics)
public Renderer3D(D3DDevice graphics) : base(graphics)
{
// Initialize

View file

@ -37,7 +37,7 @@ using System.Drawing.Imaging;
namespace CodeImp.DoomBuilder.Rendering
{
public class ShaderManager : IDisposable
public class ShaderManager : IDisposable, ID3DResource
{
#region ================== Constants
@ -53,6 +53,9 @@ namespace CodeImp.DoomBuilder.Rendering
private Display2DShader display2dshader;
private Things2DShader things2dshader;
// Device
private D3DDevice device;
// Disposing
private bool isdisposed = false;
@ -71,18 +74,16 @@ namespace CodeImp.DoomBuilder.Rendering
#region ================== Constructor / Disposer
// Constructor
public ShaderManager()
public ShaderManager(D3DDevice device)
{
Capabilities caps;
// Check if we can use shaders
caps = General.Map.Graphics.Device.GetDeviceCaps();
useshaders = (caps.PixelShaderVersion.Major >= 2);
shadertechnique = "SM20";
// Initialize
this.device = device;
// Initialize effects
display2dshader = new Display2DShader(this);
things2dshader = new Things2DShader(this);
// Load
ReloadResource();
// Register as resource
device.RegisterResource(this);
// We have no destructor
GC.SuppressFinalize(this);
@ -95,14 +96,43 @@ namespace CodeImp.DoomBuilder.Rendering
if(!isdisposed)
{
// Clean up
display2dshader.Dispose();
things2dshader.Dispose();
UnloadResource();
// Unregister as resource
device.UnregisterResource(this);
// Done
device = null;
isdisposed = true;
}
}
#endregion
#region ================== Resources
// Clean up resources
public void UnloadResource()
{
display2dshader.Dispose();
things2dshader.Dispose();
}
// Load resources
public void ReloadResource()
{
Capabilities caps;
// Check if we can use shaders
caps = General.Map.Graphics.Device.GetDeviceCaps();
useshaders = (caps.PixelShaderVersion.Major >= 2);
shadertechnique = "SM20";
// Initialize effects
display2dshader = new Display2DShader(this);
things2dshader = new Things2DShader(this);
}
#endregion
}
}

View file

@ -5,6 +5,15 @@
// This just defines which actions there are and what description they have
// The source code will bind to these actions with delegates (function pointers)
testaction
{
title = "Developer: Test";
description = "Does whatever the developer wants to test.";
allowkeys = true;
allowmouse = true;
allowscroll = true;
}
newmap
{
title = "File: New Map";