mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-26 22:01:45 +00:00
- updated to latest slimdx library (march 2008)
- added error dialog when missing DirectX
This commit is contained in:
parent
3fd1ce1e8d
commit
5ca3cd46cb
43 changed files with 3379 additions and 2511 deletions
BIN
Build/SlimDX.dll
BIN
Build/SlimDX.dll
Binary file not shown.
5617
Build/SlimDX.xml
5617
Build/SlimDX.xml
File diff suppressed because it is too large
Load diff
Binary file not shown.
BIN
Build/d3dx9_37.dll
Normal file
BIN
Build/d3dx9_37.dll
Normal file
Binary file not shown.
BIN
Build/dxwebsetup.exe
Normal file
BIN
Build/dxwebsetup.exe
Normal file
Binary file not shown.
|
@ -354,10 +354,7 @@
|
|||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Build\Sharpzip.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SlimDX, Version=1.0.2863.25597, Culture=neutral, PublicKeyToken=b1b0c32fd1ffe4f9, processorArchitecture=x86">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Build\SlimDX.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SlimDX, Version=2.0.3.37, Culture=neutral, PublicKeyToken=b1b0c32fd1ffe4f9, processorArchitecture=x86" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
|
||||
// Set cooperative level
|
||||
mouse.SetCooperativeLevel(source,
|
||||
CooperativeLevel.NonExclusive | CooperativeLevel.Foreground);
|
||||
CooperativeLevel.Nonexclusive | CooperativeLevel.Foreground);
|
||||
|
||||
// Aquire device
|
||||
try { mouse.Acquire(); }
|
||||
|
@ -112,11 +112,10 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
MouseState ms;
|
||||
float changex, changey;
|
||||
|
||||
try
|
||||
// Poll the device
|
||||
Result result = mouse.Poll();
|
||||
if(result.IsSuccess)
|
||||
{
|
||||
// Poll the device
|
||||
mouse.Poll();
|
||||
|
||||
// Get the changes since previous poll
|
||||
ms = mouse.GetCurrentState();
|
||||
|
||||
|
@ -127,16 +126,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
// Return changes
|
||||
return new Vector2D(changex, changey);
|
||||
}
|
||||
// Lost device?
|
||||
catch(InputLostException)
|
||||
{
|
||||
// Reaquire device
|
||||
try { mouse.Acquire(); }
|
||||
catch(Exception) { }
|
||||
return new Vector2D();
|
||||
}
|
||||
// Lost device?
|
||||
catch(DeviceNotAcquiredException)
|
||||
else
|
||||
{
|
||||
// Reaquire device
|
||||
try { mouse.Acquire(); }
|
||||
|
|
|
@ -395,6 +395,9 @@ namespace CodeImp.DoomBuilder
|
|||
// Enable OS visual styles
|
||||
Application.EnableVisualStyles();
|
||||
Application.DoEvents(); // This must be here to work around a .NET bug
|
||||
|
||||
// Hook to DLL loading failure event
|
||||
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
|
||||
|
||||
// Get a reference to this assembly
|
||||
thisasm = Assembly.GetExecutingAssembly();
|
||||
|
@ -452,7 +455,9 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
// Start Direct3D
|
||||
General.WriteLogLine("Starting Direct3D graphics driver...");
|
||||
Direct3D.Initialize();
|
||||
try { Direct3D.Initialize(); }
|
||||
catch(Direct3D9NotFoundException) { AskDownloadDirectX(); return; }
|
||||
catch(Direct3DX9NotFoundException) { AskDownloadDirectX(); return; }
|
||||
|
||||
// Load plugin manager
|
||||
General.WriteLogLine("Loading plugins...");
|
||||
|
@ -489,6 +494,33 @@ namespace CodeImp.DoomBuilder
|
|||
Terminate(false);
|
||||
}
|
||||
}
|
||||
|
||||
// This handles DLL linking errors
|
||||
private static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
|
||||
{
|
||||
// Check if SlimDX failed loading
|
||||
if(args.Name.Contains("SlimDX")) AskDownloadDirectX();
|
||||
|
||||
// Return null
|
||||
return null;
|
||||
}
|
||||
|
||||
// This asks the user to download DirectX
|
||||
private static void AskDownloadDirectX()
|
||||
{
|
||||
// Ask the user to download DirectX
|
||||
if(MessageBox.Show("This application requires the latest version of Microsoft DirectX installed on your computer." + Environment.NewLine +
|
||||
"Do you want to install and update Microsoft DirectX now?", "DirectX Error", System.Windows.Forms.MessageBoxButtons.YesNo,
|
||||
System.Windows.Forms.MessageBoxIcon.Exclamation) == System.Windows.Forms.DialogResult.Yes)
|
||||
{
|
||||
// Open DX web setup
|
||||
//System.Diagnostics.Process.Start("http://www.microsoft.com/downloads/details.aspx?FamilyId=2DA43D38-DB71-4C1B-BC6A-9B6652CD92A3").WaitForExit(1000);
|
||||
System.Diagnostics.Process.Start(Path.Combine(apppath, "dxwebsetup.exe")).WaitForExit(1000);
|
||||
}
|
||||
|
||||
// End program here
|
||||
Terminate(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -505,15 +537,6 @@ namespace CodeImp.DoomBuilder
|
|||
// Unbind static methods from actions
|
||||
General.Actions.UnbindMethods(typeof(General));
|
||||
|
||||
// Clean up
|
||||
if(map != null) map.Dispose();
|
||||
map = null;
|
||||
mainwindow.Dispose();
|
||||
actions.Dispose();
|
||||
clock.Dispose();
|
||||
plugins.Dispose();
|
||||
Direct3D.Terminate();
|
||||
|
||||
// Save colors
|
||||
colors.SaveColors(settings.Config);
|
||||
|
||||
|
@ -527,6 +550,14 @@ namespace CodeImp.DoomBuilder
|
|||
General.WriteLogLine("Saving program configuration...");
|
||||
settings.Save(Path.Combine(settingspath, SETTINGS_FILE));
|
||||
|
||||
// Clean up
|
||||
if(map != null) map.Dispose(); map = null;
|
||||
if(mainwindow != null) mainwindow.Dispose();
|
||||
if(actions != null) actions.Dispose();
|
||||
if(clock != null) clock.Dispose();
|
||||
if(plugins != null) plugins.Dispose();
|
||||
try { Direct3D.Terminate(); } catch(Exception) { }
|
||||
|
||||
// Application ends here and now
|
||||
General.WriteLogLine("Termination done");
|
||||
Application.Exit();
|
||||
|
|
|
@ -23,7 +23,7 @@ using System.Globalization;
|
|||
using System.Text;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using System.Drawing;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ using System.Globalization;
|
|||
using System.Text;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using System.Drawing;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ using System.Globalization;
|
|||
using System.Text;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using System.Drawing;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ using System.Globalization;
|
|||
using System.Text;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using System.Drawing;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ using System.Globalization;
|
|||
using System.Text;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using System.Drawing;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ using System.Globalization;
|
|||
using System.Text;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using System.Drawing;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ using System.Globalization;
|
|||
using System.Text;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using System.Drawing;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ using System.Globalization;
|
|||
using System.Text;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using System.Drawing;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ using System.Reflection;
|
|||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
|
|
|
@ -30,7 +30,8 @@ using CodeImp.DoomBuilder.Config;
|
|||
using CodeImp.DoomBuilder.Rendering;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Drawing.Drawing2D;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using SlimDX;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -172,7 +173,7 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
// This brightens or darkens a color
|
||||
private Color AdjustedColor(Color c, float amount)
|
||||
{
|
||||
ColorValue cc = ColorValue.FromColor(c);
|
||||
Color4 cc = new Color4(c);
|
||||
|
||||
// Adjust color
|
||||
cc.Red = Saturate((cc.Red * (1f + amount)) + (amount * 0.5f));
|
||||
|
|
|
@ -242,33 +242,36 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
{
|
||||
int windowstate;
|
||||
|
||||
General.WriteLogLine("Closing main interface window...");
|
||||
if(e.CloseReason != CloseReason.ApplicationExitCall)
|
||||
{
|
||||
General.WriteLogLine("Closing main interface window...");
|
||||
|
||||
// Stop exclusive mode, if any is active
|
||||
StopExclusiveMouseInput();
|
||||
SetProcessorState(false);
|
||||
|
||||
// Unbind methods
|
||||
General.Actions.UnbindMethods(this);
|
||||
|
||||
// Determine window state to save
|
||||
if(this.WindowState != FormWindowState.Minimized)
|
||||
windowstate = (int)this.WindowState;
|
||||
else
|
||||
windowstate = (int)FormWindowState.Normal;
|
||||
|
||||
// Save window settings
|
||||
General.Settings.WriteSetting("mainwindow.positionx", lastposition.X);
|
||||
General.Settings.WriteSetting("mainwindow.positiony", lastposition.Y);
|
||||
General.Settings.WriteSetting("mainwindow.sizewidth", lastsize.Width);
|
||||
General.Settings.WriteSetting("mainwindow.sizeheight", lastsize.Height);
|
||||
General.Settings.WriteSetting("mainwindow.windowstate", windowstate);
|
||||
// Stop exclusive mode, if any is active
|
||||
StopExclusiveMouseInput();
|
||||
SetProcessorState(false);
|
||||
|
||||
// Save recent files
|
||||
SaveRecentFiles();
|
||||
|
||||
// Terminate the program
|
||||
General.Terminate(true);
|
||||
// Unbind methods
|
||||
General.Actions.UnbindMethods(this);
|
||||
|
||||
// Determine window state to save
|
||||
if(this.WindowState != FormWindowState.Minimized)
|
||||
windowstate = (int)this.WindowState;
|
||||
else
|
||||
windowstate = (int)FormWindowState.Normal;
|
||||
|
||||
// Save window settings
|
||||
General.Settings.WriteSetting("mainwindow.positionx", lastposition.X);
|
||||
General.Settings.WriteSetting("mainwindow.positiony", lastposition.Y);
|
||||
General.Settings.WriteSetting("mainwindow.sizewidth", lastsize.Width);
|
||||
General.Settings.WriteSetting("mainwindow.sizeheight", lastsize.Height);
|
||||
General.Settings.WriteSetting("mainwindow.windowstate", windowstate);
|
||||
|
||||
// Save recent files
|
||||
SaveRecentFiles();
|
||||
|
||||
// Terminate the program
|
||||
General.Terminate(true);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -23,7 +23,7 @@ using System.Globalization;
|
|||
using System.Text;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using System.Drawing;
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -22,7 +22,7 @@ using System.Collections.Generic;
|
|||
using System.Globalization;
|
||||
using System.Text;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using SlimDX;
|
||||
using System.Drawing;
|
||||
|
|
|
@ -23,7 +23,7 @@ using System.Globalization;
|
|||
using System.Text;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using System.Drawing;
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -27,7 +27,6 @@ using System.Reflection;
|
|||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
|
|
|
@ -24,7 +24,10 @@ using System.Text;
|
|||
using System.Reflection;
|
||||
using System.Drawing;
|
||||
using CodeImp.DoomBuilder.IO;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using SlimDX;
|
||||
|
||||
using Configuration = CodeImp.DoomBuilder.IO.Configuration;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -207,8 +210,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
// This creates assist colors
|
||||
internal void CreateAssistColors()
|
||||
{
|
||||
ColorValue o;
|
||||
ColorValue c = new ColorValue(1f, 0f, 0f, 0f);
|
||||
Color4 o;
|
||||
Color4 c = new Color4(1f, 0f, 0f, 0f);
|
||||
|
||||
// Go for all colors
|
||||
for(int i = 0; i < NUM_COLORS; i++)
|
||||
|
|
|
@ -26,7 +26,6 @@ using System.IO;
|
|||
using System.Reflection;
|
||||
using System.Drawing;
|
||||
using SlimDX.Direct3D9;
|
||||
using SlimDX.Direct3D;
|
||||
using System.ComponentModel;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using SlimDX;
|
||||
|
@ -141,8 +140,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
device.SetRenderState(RenderState.ZWriteEnable, false);
|
||||
device.SetRenderState(RenderState.Clipping, true);
|
||||
device.SetRenderState(RenderState.CullMode, Cull.None);
|
||||
device.SetPixelShader(null);
|
||||
device.SetVertexShader(null);
|
||||
device.PixelShader = null;
|
||||
device.VertexShader = null;
|
||||
|
||||
// Sampler settings
|
||||
device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Linear);
|
||||
|
@ -187,9 +186,9 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
|
||||
// Setup material
|
||||
Material material = new Material();
|
||||
material.Ambient = ColorValue.FromColor(Color.White);
|
||||
material.Diffuse = ColorValue.FromColor(Color.White);
|
||||
material.Specular = ColorValue.FromColor(Color.White);
|
||||
material.Ambient = new Color4(Color.White);
|
||||
material.Diffuse = new Color4(Color.White);
|
||||
material.Specular = new Color4(Color.White);
|
||||
device.Material = material;
|
||||
}
|
||||
|
||||
|
@ -246,7 +245,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
|
||||
// Keep a reference to the original buffers
|
||||
backbuffer = device.GetBackBuffer(0, 0);
|
||||
depthbuffer = device.GetDepthStencilSurface();
|
||||
depthbuffer = device.DepthStencilSurface;
|
||||
|
||||
// Get the viewport
|
||||
viewport = device.Viewport;
|
||||
|
@ -341,7 +340,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
|
||||
// Keep a reference to the original buffers
|
||||
backbuffer = device.GetBackBuffer(0, 0);
|
||||
depthbuffer = device.GetDepthStencilSurface();
|
||||
depthbuffer = device.DepthStencilSurface;
|
||||
|
||||
// Get the viewport
|
||||
viewport = device.Viewport;
|
||||
|
@ -361,31 +360,24 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
#region ================== Rendering
|
||||
|
||||
// This begins a drawing session
|
||||
public bool StartRendering(bool clear, int backcolor, Surface target, Surface depthbuffer)
|
||||
public bool StartRendering(bool clear, Color4 backcolor, Surface target, Surface depthbuffer)
|
||||
{
|
||||
CooperativeLevel coopresult;
|
||||
|
||||
// When minimized, do not render anything
|
||||
if(General.MainWindow.WindowState != FormWindowState.Minimized)
|
||||
{
|
||||
// Test the cooperative level
|
||||
coopresult = device.CheckCooperativeLevel();
|
||||
Result coopresult = device.TestCooperativeLevel();
|
||||
|
||||
// Check if device must be reset
|
||||
if(coopresult == CooperativeLevel.DeviceNotReset)
|
||||
if(!coopresult.IsSuccess)
|
||||
{
|
||||
// Device is lost and must be reset now
|
||||
// TODO: Check result codes, device cannot always be reset
|
||||
return Reset();
|
||||
}
|
||||
// Check if device is lost
|
||||
else if(coopresult == CooperativeLevel.DeviceLost)
|
||||
{
|
||||
// Device is lost and cannot be reset now
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set rendertarget
|
||||
device.SetDepthStencilSurface(depthbuffer);
|
||||
device.DepthStencilSurface = depthbuffer;
|
||||
device.SetRenderTarget(0, target);
|
||||
|
||||
// Clear the screen
|
||||
|
|
|
@ -27,7 +27,6 @@ using System.Reflection;
|
|||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
|
|
|
@ -27,7 +27,6 @@ using System.Reflection;
|
|||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using SlimDX;
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ using System.Reflection;
|
|||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
|
|
|
@ -25,7 +25,7 @@ using System.Windows.Forms;
|
|||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Drawing;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using System.ComponentModel;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using SlimDX;
|
||||
|
|
|
@ -27,7 +27,6 @@ using System.Reflection;
|
|||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
|
|
|
@ -27,7 +27,6 @@ using System.Reflection;
|
|||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
|
|
|
@ -23,7 +23,8 @@ using System.Globalization;
|
|||
using System.Text;
|
||||
using System.Reflection;
|
||||
using System.Drawing;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using SlimDX;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -92,14 +93,14 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
}
|
||||
|
||||
// To ColorValue
|
||||
public ColorValue ToColorValue()
|
||||
public Color4 ToColorValue()
|
||||
{
|
||||
return new ColorValue((float)a * 0.00392156862745098f,
|
||||
(float)r * 0.00392156862745098f,
|
||||
(float)g * 0.00392156862745098f,
|
||||
(float)b * 0.00392156862745098f);
|
||||
return new Color4((float)a * 0.00392156862745098f,
|
||||
(float)r * 0.00392156862745098f,
|
||||
(float)g * 0.00392156862745098f,
|
||||
(float)b * 0.00392156862745098f);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
|
|
@ -23,7 +23,7 @@ using System.Globalization;
|
|||
using System.Text;
|
||||
using System.Reflection;
|
||||
using System.Drawing;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -27,7 +27,6 @@ using System.Reflection;
|
|||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
|
|
|
@ -27,7 +27,6 @@ using System.Reflection;
|
|||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
|
@ -88,7 +87,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
private Texture overlaytex;
|
||||
|
||||
// Locking data
|
||||
private LockedRect plotlocked;
|
||||
private DataRectangle plotlocked;
|
||||
private Surface targetsurface;
|
||||
|
||||
// Rendertarget sizes
|
||||
|
@ -196,7 +195,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
public void Present()
|
||||
{
|
||||
// Start drawing
|
||||
if(graphics.StartRendering(true, General.Colors.Background.ToInt(), graphics.BackBuffer, graphics.DepthBuffer))
|
||||
if(graphics.StartRendering(true, General.Colors.Background.ToColorValue(), graphics.BackBuffer, graphics.DepthBuffer))
|
||||
{
|
||||
// Renderstates that count for this whole sequence
|
||||
graphics.Device.SetRenderState(RenderState.CullMode, Cull.None);
|
||||
|
@ -244,7 +243,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.Device.SetRenderState(RenderState.AlphaBlendEnable, true);
|
||||
graphics.Device.SetRenderState(RenderState.AlphaTestEnable, false);
|
||||
graphics.Device.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha);
|
||||
graphics.Device.SetRenderState(RenderState.DestBlend, Blend.InvSourceAlpha);
|
||||
graphics.Device.SetRenderState(RenderState.DestinationBlend, Blend.InvSourceAlpha);
|
||||
graphics.Device.SetRenderState(RenderState.TextureFactor, -1);
|
||||
graphics.Device.SetTexture(0, plottertex);
|
||||
graphics.Shaders.Display2D.Texture1 = plottertex;
|
||||
|
@ -264,7 +263,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.Device.SetRenderState(RenderState.AlphaBlendEnable, true);
|
||||
graphics.Device.SetRenderState(RenderState.AlphaTestEnable, false);
|
||||
graphics.Device.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha);
|
||||
graphics.Device.SetRenderState(RenderState.DestBlend, Blend.InvSourceAlpha);
|
||||
graphics.Device.SetRenderState(RenderState.DestinationBlend, Blend.InvSourceAlpha);
|
||||
graphics.Device.SetRenderState(RenderState.TextureFactor, -1);
|
||||
graphics.Device.SetTexture(0, overlaytex);
|
||||
graphics.Shaders.Display2D.Texture1 = overlaytex;
|
||||
|
@ -296,8 +295,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.Device.SetRenderState(RenderState.AlphaBlendEnable, true);
|
||||
graphics.Device.SetRenderState(RenderState.AlphaTestEnable, false);
|
||||
graphics.Device.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha);
|
||||
graphics.Device.SetRenderState(RenderState.DestBlend, Blend.InvSourceAlpha);
|
||||
graphics.Device.SetRenderState(RenderState.TextureFactor, (new ColorValue(alpha, 1f, 1f, 1f)).ToArgb());
|
||||
graphics.Device.SetRenderState(RenderState.DestinationBlend, Blend.InvSourceAlpha);
|
||||
graphics.Device.SetRenderState(RenderState.TextureFactor, (new Color4(alpha, 1f, 1f, 1f)).ToArgb());
|
||||
graphics.Device.SetTexture(0, thingstex);
|
||||
graphics.Shaders.Display2D.Texture1 = thingstex;
|
||||
graphics.Shaders.Display2D.SetSettings(1f / thingssize.Width, 1f / thingssize.Height, FSAA_PLOTTER_BLEND_FACTOR, alpha);
|
||||
|
@ -404,7 +403,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
StartOverlay(true); Finish();
|
||||
|
||||
// Create font
|
||||
font = new SlimDX.Direct3D9.Font(graphics.Device, FONT_WIDTH, FONT_HEIGHT, FontWeight.Bold, 1, false, CharacterSet.Ansi, Precision.Default, FontQuality.AntiAliased, PitchAndFamily.Default, FONT_NAME);
|
||||
font = new SlimDX.Direct3D9.Font(graphics.Device, FONT_WIDTH, FONT_HEIGHT, FontWeight.Bold, 1, false, CharacterSet.Ansi, Precision.Default, FontQuality.Antialiased, PitchAndFamily.Default, FONT_NAME);
|
||||
|
||||
// Create vertex buffers
|
||||
screenverts = new VertexBuffer(graphics.Device, 4 * sizeof(FlatVertex), Usage.Dynamic | Usage.WriteOnly, VertexFormat.None, Pool.Default);
|
||||
|
@ -552,7 +551,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
// This begins a drawing session
|
||||
public unsafe bool StartPlotter(bool clear)
|
||||
{
|
||||
if(renderlayer != RenderLayers.None) throw new InvalidCallException("Renderer starting called before finished previous layer. Call Finish() first!");
|
||||
if(renderlayer != RenderLayers.None) throw new InvalidOperationException("Renderer starting called before finished previous layer. Call Finish() first!");
|
||||
renderlayer = RenderLayers.Plotter;
|
||||
|
||||
// Rendertargets available?
|
||||
|
@ -586,7 +585,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
// This begins a drawing session
|
||||
public unsafe bool StartThings(bool clear)
|
||||
{
|
||||
if(renderlayer != RenderLayers.None) throw new InvalidCallException("Renderer starting called before finished previous layer. Call Finish() first!");
|
||||
if(renderlayer != RenderLayers.None) throw new InvalidOperationException("Renderer starting called before finished previous layer. Call Finish() first!");
|
||||
renderlayer = RenderLayers.Things;
|
||||
|
||||
// Rendertargets available?
|
||||
|
@ -600,7 +599,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
|
||||
// Set the rendertarget to the things texture
|
||||
targetsurface = thingstex.GetSurfaceLevel(0);
|
||||
if(graphics.StartRendering(clear, 0, targetsurface, null))
|
||||
if(graphics.StartRendering(clear, new Color4(0), targetsurface, null))
|
||||
{
|
||||
// Ready for rendering
|
||||
return true;
|
||||
|
@ -623,7 +622,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
// This begins a drawing session
|
||||
public unsafe bool StartOverlay(bool clear)
|
||||
{
|
||||
if(renderlayer != RenderLayers.None) throw new InvalidCallException("Renderer starting called before finished previous layer. Call Finish() first!");
|
||||
if(renderlayer != RenderLayers.None) throw new InvalidOperationException("Renderer starting called before finished previous layer. Call Finish() first!");
|
||||
renderlayer = RenderLayers.Overlay;
|
||||
|
||||
// Rendertargets available?
|
||||
|
@ -631,7 +630,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
{
|
||||
// Set the rendertarget to the things texture
|
||||
targetsurface = overlaytex.GetSurfaceLevel(0);
|
||||
if(graphics.StartRendering(clear, 0, targetsurface, null))
|
||||
if(graphics.StartRendering(clear, new Color4(0), targetsurface, null))
|
||||
{
|
||||
// Ready for rendering
|
||||
return true;
|
||||
|
@ -671,7 +670,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
// Release rendertarget
|
||||
try
|
||||
{
|
||||
graphics.Device.SetDepthStencilSurface(graphics.DepthBuffer);
|
||||
graphics.Device.DepthStencilSurface = graphics.DepthBuffer;
|
||||
graphics.Device.SetRenderTarget(0, graphics.BackBuffer);
|
||||
}
|
||||
catch(Exception) { }
|
||||
|
@ -731,7 +730,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
private void RenderBackgroundGrid()
|
||||
{
|
||||
Plotter gridplotter;
|
||||
LockedRect lockedrect;
|
||||
DataRectangle lockedrect;
|
||||
|
||||
// Do we need to redraw grid?
|
||||
if((lastgridscale != scale) || (lastgridx != offsetx) || (lastgridy != offsety))
|
||||
|
@ -1065,7 +1064,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.Device.SetRenderState(RenderState.TextureFactor, -1);
|
||||
|
||||
// Draw
|
||||
if(font != null) font.DrawString(null, text, posr, DrawTextFormat.VCenter | DrawTextFormat.Left | DrawTextFormat.NoClip, c.ToInt());
|
||||
if(font != null) font.DrawString(null, text, posr, DrawTextFormat.VCenter | DrawTextFormat.Left | DrawTextFormat.NoClip, c.ToColorValue());
|
||||
}
|
||||
|
||||
// This renders text
|
||||
|
@ -1083,7 +1082,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.Device.SetRenderState(RenderState.TextureFactor, -1);
|
||||
|
||||
// Draw
|
||||
if(font != null) font.DrawString(null, text, posr, DrawTextFormat.VCenter | DrawTextFormat.Center | DrawTextFormat.NoClip, c.ToInt());
|
||||
if(font != null) font.DrawString(null, text, posr, DrawTextFormat.VCenter | DrawTextFormat.Center | DrawTextFormat.NoClip, c.ToColorValue());
|
||||
}
|
||||
|
||||
// This renders a rectangle with given border size and color
|
||||
|
|
|
@ -25,7 +25,6 @@ using System.Windows.Forms;
|
|||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Drawing;
|
||||
using SlimDX.Direct3D;
|
||||
using System.ComponentModel;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
|
@ -159,7 +158,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
public bool Start()
|
||||
{
|
||||
// Start drawing
|
||||
if(graphics.StartRendering(true, General.Colors.Background.ToInt(), graphics.BackBuffer, graphics.DepthBuffer))
|
||||
if(graphics.StartRendering(true, General.Colors.Background.ToColorValue(), graphics.BackBuffer, graphics.DepthBuffer))
|
||||
{
|
||||
// Beginning renderstates
|
||||
graphics.Device.SetRenderState(RenderState.CullMode, Cull.None);
|
||||
|
@ -167,7 +166,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.Device.SetRenderState(RenderState.AlphaBlendEnable, false);
|
||||
graphics.Device.SetRenderState(RenderState.AlphaTestEnable, false);
|
||||
graphics.Device.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha);
|
||||
graphics.Device.SetRenderState(RenderState.DestBlend, Blend.InvSourceAlpha);
|
||||
graphics.Device.SetRenderState(RenderState.DestinationBlend, Blend.InvSourceAlpha);
|
||||
graphics.Device.SetRenderState(RenderState.TextureFactor, -1);
|
||||
|
||||
// Ready
|
||||
|
@ -184,7 +183,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
public void StartGeometry()
|
||||
{
|
||||
// Renderstates
|
||||
graphics.Device.SetRenderState(RenderState.CullMode, Cull.CounterClockwise);
|
||||
graphics.Device.SetRenderState(RenderState.CullMode, Cull.Counterclockwise);
|
||||
graphics.Device.SetRenderState(RenderState.ZEnable, true);
|
||||
graphics.Device.SetRenderState(RenderState.ZWriteEnable, true);
|
||||
graphics.Device.SetRenderState(RenderState.AlphaBlendEnable, false);
|
||||
|
|
|
@ -27,7 +27,6 @@ using System.Reflection;
|
|||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
|
@ -130,7 +129,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
Capabilities caps;
|
||||
|
||||
// Check if we can use shaders
|
||||
caps = General.Map.Graphics.Device.GetDeviceCaps();
|
||||
caps = General.Map.Graphics.Device.Capabilities;
|
||||
useshaders = (caps.PixelShaderVersion.Major >= 2);
|
||||
shadertechnique = "SM20";
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ using System.Reflection;
|
|||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
|
|
|
@ -27,7 +27,6 @@ using System.Reflection;
|
|||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
|
|
|
@ -27,7 +27,6 @@ using System.Reflection;
|
|||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
|
|
|
@ -27,7 +27,6 @@ using System.Reflection;
|
|||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
|
|
|
@ -27,7 +27,6 @@ using System.Reflection;
|
|||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using SlimDX.Direct3D;
|
||||
using SlimDX.Direct3D9;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
|
|
Loading…
Reference in a new issue