diff --git a/Documents/diagrams.ump b/Documents/diagrams.ump
index 7273d3d0..1504715e 100644
--- a/Documents/diagrams.ump
+++ b/Documents/diagrams.ump
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/Documents/rendering_classes.png b/Documents/rendering_classes.png
index d81aa783..12478dad 100644
Binary files a/Documents/rendering_classes.png and b/Documents/rendering_classes.png differ
diff --git a/Source/Builder.csproj b/Source/Builder.csproj
index 97fd1dc3..bef6761f 100644
--- a/Source/Builder.csproj
+++ b/Source/Builder.csproj
@@ -105,6 +105,12 @@
Form
+
+ UserControl
+
+
+ ImageBrowser.cs
+
UserControl
@@ -153,6 +159,12 @@
SectorInfoPanel.cs
+
+ Form
+
+
+ TextureBrowserForm.cs
+
UserControl
@@ -201,7 +213,7 @@
-
+
@@ -281,6 +293,10 @@
Designer
DelayedForm.cs
+
+ Designer
+ ImageBrowser.cs
+
Designer
LinedefInfoPanel.cs
@@ -297,6 +313,10 @@
Designer
SectorInfoPanel.cs
+
+ Designer
+ TextureBrowserForm.cs
+
Designer
ThingInfoPanel.cs
diff --git a/Source/Controls/Action.cs b/Source/Controls/Action.cs
index a3a2c177..f451c7ee 100644
--- a/Source/Controls/Action.cs
+++ b/Source/Controls/Action.cs
@@ -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
diff --git a/Source/Data/DataManager.cs b/Source/Data/DataManager.cs
index 68a4b921..7da81d22 100644
--- a/Source/Data/DataManager.cs
+++ b/Source/Data/DataManager.cs
@@ -68,6 +68,8 @@ namespace CodeImp.DoomBuilder.Data
#region ================== Properties
public Playpal Palette { get { return palette; } }
+ public ICollection Textures { get { return textures.Values; } }
+ public ICollection Flats { get { return flats.Values; } }
public bool IsDisposed { get { return isdisposed; } }
public bool IsLoading { get { return (backgroundloader != null) && backgroundloader.IsAlive; } }
diff --git a/Source/Data/PK3Reader.cs b/Source/Data/PK3Reader.cs
index 8c7ce6df..7cc03169 100644
--- a/Source/Data/PK3Reader.cs
+++ b/Source/Data/PK3Reader.cs
@@ -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);
diff --git a/Source/Editing/ClassicMode.cs b/Source/Editing/ClassicMode.cs
index 9eef01d2..c67375e6 100644
--- a/Source/Editing/ClassicMode.cs
+++ b/Source/Editing/ClassicMode.cs
@@ -68,7 +68,7 @@ namespace CodeImp.DoomBuilder.Editing
public ClassicMode()
{
// Initialize
- this.renderer = General.Map.Graphics.Renderer2D;
+ this.renderer = General.Map.Renderer2D;
}
// Diposer
diff --git a/Source/General/General.cs b/Source/General/General.cs
index 36fa2867..a3eb1c51 100644
--- a/Source/General/General.cs
+++ b/Source/General/General.cs
@@ -935,6 +935,14 @@ namespace CodeImp.DoomBuilder
}
#endregion
+
+ [Action(Action.TESTACTION)]
+ public static void TestAction()
+ {
+ TextureBrowserForm t = new TextureBrowserForm();
+ t.ShowDialog(mainwindow);
+ t.Dispose();
+ }
}
}
diff --git a/Source/General/MapManager.cs b/Source/General/MapManager.cs
index 5c99d11e..c9ec198a 100644
--- a/Source/General/MapManager.cs
+++ b/Source/General/MapManager.cs
@@ -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);
diff --git a/Source/Interface/ImageBrowser.Designer.cs b/Source/Interface/ImageBrowser.Designer.cs
new file mode 100644
index 00000000..d7f6cda1
--- /dev/null
+++ b/Source/Interface/ImageBrowser.Designer.cs
@@ -0,0 +1,88 @@
+namespace CodeImp.DoomBuilder.Interface
+{
+ partial class ImageBrowser
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if(disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ 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;
+
+ }
+}
diff --git a/Source/Interface/ImageBrowser.cs b/Source/Interface/ImageBrowser.cs
new file mode 100644
index 00000000..04518103
--- /dev/null
+++ b/Source/Interface/ImageBrowser.cs
@@ -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
+ }
+}
diff --git a/Source/Interface/ImageBrowser.resx b/Source/Interface/ImageBrowser.resx
new file mode 100644
index 00000000..a764f1c7
--- /dev/null
+++ b/Source/Interface/ImageBrowser.resx
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ True
+
+
\ No newline at end of file
diff --git a/Source/Interface/TextureBrowserForm.Designer.cs b/Source/Interface/TextureBrowserForm.Designer.cs
new file mode 100644
index 00000000..f650b964
--- /dev/null
+++ b/Source/Interface/TextureBrowserForm.Designer.cs
@@ -0,0 +1,65 @@
+namespace CodeImp.DoomBuilder.Interface
+{
+ partial class TextureBrowserForm
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if(disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ 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;
+ }
+}
\ No newline at end of file
diff --git a/Source/Interface/TextureBrowserForm.cs b/Source/Interface/TextureBrowserForm.cs
new file mode 100644
index 00000000..ddeed653
--- /dev/null
+++ b/Source/Interface/TextureBrowserForm.cs
@@ -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);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Source/Interface/TextureBrowserForm.resx b/Source/Interface/TextureBrowserForm.resx
new file mode 100644
index 00000000..ff31a6db
--- /dev/null
+++ b/Source/Interface/TextureBrowserForm.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Source/Rendering/D3DGraphics.cs b/Source/Rendering/D3DDevice.cs
similarity index 89%
rename from Source/Rendering/D3DGraphics.cs
rename to Source/Rendering/D3DDevice.cs
index 3f21c3cd..a42af030 100644
--- a/Source/Rendering/D3DGraphics.cs
+++ b/Source/Rendering/D3DDevice.cs
@@ -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 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
diff --git a/Source/Rendering/Renderer.cs b/Source/Rendering/Renderer.cs
index c6046b18..8cde6f38 100644
--- a/Source/Rendering/Renderer.cs
+++ b/Source/Rendering/Renderer.cs
@@ -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;
diff --git a/Source/Rendering/Renderer2D.cs b/Source/Rendering/Renderer2D.cs
index 280da4f6..4f07f195 100644
--- a/Source/Rendering/Renderer2D.cs
+++ b/Source/Rendering/Renderer2D.cs
@@ -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;
diff --git a/Source/Rendering/Renderer3D.cs b/Source/Rendering/Renderer3D.cs
index 4bc4fe61..df6ca437 100644
--- a/Source/Rendering/Renderer3D.cs
+++ b/Source/Rendering/Renderer3D.cs
@@ -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
diff --git a/Source/Rendering/ShaderManager.cs b/Source/Rendering/ShaderManager.cs
index 82f69a8e..d9c22697 100644
--- a/Source/Rendering/ShaderManager.cs
+++ b/Source/Rendering/ShaderManager.cs
@@ -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
}
}
diff --git a/Source/Resources/Actions.cfg b/Source/Resources/Actions.cfg
index df8a0707..f1920e52 100644
--- a/Source/Resources/Actions.cfg
+++ b/Source/Resources/Actions.cfg
@@ -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";