mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-31 04:40:55 +00:00
- add BuilderNative library that does the actual rendering
This commit is contained in:
parent
690a4d2e83
commit
37876f6d8a
25 changed files with 990 additions and 186 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -16,3 +16,9 @@ obj
|
|||
/Source/Plugins/VisplaneExplorer/Resources/*.pdb
|
||||
/Source/Plugins/vpo_dll/Debug
|
||||
/Source/Plugins/vpo_dll/*.user
|
||||
/Build/BuilderNative.dll
|
||||
/Build/BuilderNative.exp
|
||||
/Build/BuilderNative.ilk
|
||||
/Build/BuilderNative.lib
|
||||
/Build/BuilderNative.pdb
|
||||
/Source/Native/Debug
|
||||
|
|
25
Builder.sln
25
Builder.sln
|
@ -1,9 +1,12 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29201.188
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Builder", "Source\Core\Builder.csproj", "{818B3D10-F791-4C3F-9AF5-BB2D0079B63C}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{78938655-9807-485E-9D4B-46226DC7AD27} = {78938655-9807-485E-9D4B-46226DC7AD27}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuilderModes", "Source\Plugins\BuilderModes\BuilderModes.csproj", "{B42D5AA0-F9A6-4234-9C4B-A05B11A64851}"
|
||||
EndProject
|
||||
|
@ -35,6 +38,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutomapMode", "Source\Plugi
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vpo_dll", "Source\Plugins\vpo_dll\vpo_dll.vcxproj", "{29C8D76F-DE3D-482D-AD7D-B86BBD0824DE}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BuilderNative", "Source\Native\BuilderNative.vcxproj", "{78938655-9807-485E-9D4B-46226DC7AD27}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug + Profiler|x64 = Debug + Profiler|x64
|
||||
|
@ -255,6 +260,22 @@ Global
|
|||
{29C8D76F-DE3D-482D-AD7D-B86BBD0824DE}.Release|x64.Build.0 = Release|x64
|
||||
{29C8D76F-DE3D-482D-AD7D-B86BBD0824DE}.Release|x86.ActiveCfg = Release|Win32
|
||||
{29C8D76F-DE3D-482D-AD7D-B86BBD0824DE}.Release|x86.Build.0 = Release|Win32
|
||||
{78938655-9807-485E-9D4B-46226DC7AD27}.Debug + Profiler|x64.ActiveCfg = Debug|x64
|
||||
{78938655-9807-485E-9D4B-46226DC7AD27}.Debug + Profiler|x64.Build.0 = Debug|x64
|
||||
{78938655-9807-485E-9D4B-46226DC7AD27}.Debug + Profiler|x86.ActiveCfg = Debug|Win32
|
||||
{78938655-9807-485E-9D4B-46226DC7AD27}.Debug + Profiler|x86.Build.0 = Debug|Win32
|
||||
{78938655-9807-485E-9D4B-46226DC7AD27}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{78938655-9807-485E-9D4B-46226DC7AD27}.Debug|x64.Build.0 = Debug|x64
|
||||
{78938655-9807-485E-9D4B-46226DC7AD27}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{78938655-9807-485E-9D4B-46226DC7AD27}.Debug|x86.Build.0 = Debug|Win32
|
||||
{78938655-9807-485E-9D4B-46226DC7AD27}.Release + Profiler|x64.ActiveCfg = Release|Win32
|
||||
{78938655-9807-485E-9D4B-46226DC7AD27}.Release + Profiler|x64.Build.0 = Release|Win32
|
||||
{78938655-9807-485E-9D4B-46226DC7AD27}.Release + Profiler|x86.ActiveCfg = Release|Win32
|
||||
{78938655-9807-485E-9D4B-46226DC7AD27}.Release + Profiler|x86.Build.0 = Release|Win32
|
||||
{78938655-9807-485E-9D4B-46226DC7AD27}.Release|x64.ActiveCfg = Release|x64
|
||||
{78938655-9807-485E-9D4B-46226DC7AD27}.Release|x64.Build.0 = Release|x64
|
||||
{78938655-9807-485E-9D4B-46226DC7AD27}.Release|x86.ActiveCfg = Release|Win32
|
||||
{78938655-9807-485E-9D4B-46226DC7AD27}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -222,10 +222,16 @@
|
|||
</Compile>
|
||||
<Compile Include="Rendering\Color3.cs" />
|
||||
<Compile Include="Rendering\Color4.cs" />
|
||||
<Compile Include="Rendering\Effect.cs" />
|
||||
<Compile Include="Rendering\IndexBuffer.cs" />
|
||||
<Compile Include="Rendering\Matrix.cs" />
|
||||
<Compile Include="Rendering\Mesh.cs" />
|
||||
<Compile Include="Rendering\Texture.cs" />
|
||||
<Compile Include="Rendering\Vector2.cs" />
|
||||
<Compile Include="Rendering\Vector3.cs" />
|
||||
<Compile Include="Rendering\Vector4.cs" />
|
||||
<Compile Include="Rendering\VertexBuffer.cs" />
|
||||
<Compile Include="Rendering\VertexDeclaration.cs" />
|
||||
<Compile Include="Windows\ThingStatisticsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
|
|
@ -22,210 +22,133 @@ using System.Drawing;
|
|||
using System.Windows.Forms;
|
||||
using CodeImp.DoomBuilder.Controls;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Rendering
|
||||
{
|
||||
#region High level mesh rendering
|
||||
public class Mesh
|
||||
{
|
||||
public Mesh(VertexElement[] vertexDecl, Array vertexData, Array indexData) { }
|
||||
|
||||
public void DrawSubset(int index) { }
|
||||
|
||||
public void Dispose() { }
|
||||
}
|
||||
|
||||
public class Effect
|
||||
{
|
||||
public static Effect FromStream(System.IO.Stream stream, ShaderFlags flags, out string errors) { errors = ""; return null; }
|
||||
|
||||
public void SetTexture(EffectHandle handle, BaseTexture texture) { }
|
||||
public void SetValue<T>(EffectHandle handle, T value) where T : struct { }
|
||||
public EffectHandle GetParameter(EffectHandle parameter, string name) { return null; }
|
||||
public void CommitChanges() { }
|
||||
|
||||
public void Begin() { }
|
||||
public void BeginPass(int index) { }
|
||||
public void EndPass() { }
|
||||
public void End() { }
|
||||
|
||||
public void Dispose() { }
|
||||
}
|
||||
|
||||
public class EffectHandle
|
||||
{
|
||||
public void Dispose() { }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Vertex buffer format / Input assembly
|
||||
public class VertexDeclaration
|
||||
{
|
||||
public VertexDeclaration(VertexElement[] elements) { }
|
||||
public void Dispose() { }
|
||||
}
|
||||
|
||||
public struct VertexElement
|
||||
{
|
||||
public VertexElement(short stream, short offset, DeclarationType type, DeclarationUsage usage) { }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Buffer objects
|
||||
public class VertexBuffer
|
||||
{
|
||||
public VertexBuffer(int sizeInBytes) { }
|
||||
|
||||
public void SetBufferData(Array data) { }
|
||||
public void SetBufferSubdata(long destOffset, Array data) { }
|
||||
public void SetBufferSubdata(long destOffset, Array data, long offset, long size) { }
|
||||
|
||||
public bool Disposed { get; private set; }
|
||||
public void Dispose() { Disposed = true; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Textures
|
||||
public class BaseTexture
|
||||
{
|
||||
public bool Disposed { get; private set; }
|
||||
public void Dispose() { Disposed = true; }
|
||||
}
|
||||
|
||||
public class Texture : BaseTexture
|
||||
{
|
||||
public Texture(int width, int height, int levels, Format format) { }
|
||||
|
||||
public int Width { get; private set; }
|
||||
public int Height { get; private set; }
|
||||
|
||||
public object Tag { get; set; }
|
||||
|
||||
public void SetPixels(System.Drawing.Bitmap bitmap)
|
||||
{
|
||||
/*
|
||||
BitmapData bmpdata = bitmap.LockBits(new Rectangle(0, 0, bitmap.Size.Width, bitmap.Size.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
|
||||
|
||||
DataRectangle textureLock = texture.LockRectangle(0, LockFlags.None);
|
||||
textureLock.Data.WriteRange(bmlock.Scan0, bmlock.Height * bmlock.Stride);
|
||||
texture.UnlockRectangle(0);
|
||||
|
||||
bitmap.UnlockBits(bmpdata);
|
||||
*/
|
||||
}
|
||||
|
||||
internal Plotter LockPlotter(int visibleWidth, int visibleHeight)
|
||||
{
|
||||
//return new Plotter((PixelColor*)plotlocked.Data.DataPointer.ToPointer(), plotlocked.Pitch / sizeof(PixelColor), Height, visibleWidth, visibleHeight);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void UnlockPlotter() { }
|
||||
|
||||
public static Texture FromStream(System.IO.Stream stream) { return null; }
|
||||
public static Texture FromStream(System.IO.Stream stream, int length, int width, int height, int levels, Format format) { return null; }
|
||||
}
|
||||
|
||||
public class CubeTexture : BaseTexture
|
||||
{
|
||||
public CubeTexture(int size, int levels, Format format) { }
|
||||
|
||||
public void SetPixels(CubeMapFace face, System.Drawing.Bitmap bitmap) { }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Enumerations
|
||||
public enum RenderState
|
||||
{
|
||||
AlphaBlendEnable,
|
||||
AlphaRef,
|
||||
AlphaTestEnable,
|
||||
CullMode,
|
||||
BlendOperation,
|
||||
SourceBlend,
|
||||
DestinationBlend,
|
||||
FillMode,
|
||||
FogEnable,
|
||||
FogColor,
|
||||
FogStart,
|
||||
FogEnd,
|
||||
MultisampleAntialias,
|
||||
TextureFactor,
|
||||
ZEnable,
|
||||
ZWriteEnable
|
||||
}
|
||||
|
||||
public enum Cull { None, Counterclockwise }
|
||||
public enum Blend { InverseSourceAlpha, SourceAlpha, One, BlendFactor }
|
||||
public enum BlendOperation { Add, ReverseSubtract }
|
||||
public enum FillMode { Solid, Wireframe }
|
||||
public enum TransformState { World, View, Projection }
|
||||
public enum SamplerState { AddressU, AddressV, AddressW }
|
||||
public enum TextureAddress { Wrap, Clamp }
|
||||
public enum Format { Unknown, A8R8G8B8 }
|
||||
public enum ShaderFlags { None, Debug }
|
||||
public enum PrimitiveType { LineList, TriangleList, TriangleStrip }
|
||||
public enum CubeMapFace { PositiveX, PositiveY, PositiveZ, NegativeX, NegativeY, NegativeZ }
|
||||
public enum TextureFilter { None, Point, Linear, Anisotropic }
|
||||
public enum DeclarationType { Float2, Float3, Color }
|
||||
public enum DeclarationUsage { Position, Color, TextureCoordinate, Normal }
|
||||
#endregion
|
||||
|
||||
#region Device context
|
||||
internal class D3DDevice : IDisposable
|
||||
{
|
||||
internal D3DDevice(RenderTargetControl rendertarget)
|
||||
{
|
||||
RenderTarget = rendertarget;
|
||||
Handle = RenderDevice_New();
|
||||
if (Handle == IntPtr.Zero)
|
||||
throw new Exception("RenderDevice_New failed");
|
||||
|
||||
RenderTarget = rendertarget;
|
||||
Shaders = new ShaderManager(this);
|
||||
SetupSettings();
|
||||
}
|
||||
|
||||
public void SetStreamSource(int index, VertexBuffer buffer, long offset, long stride) { }
|
||||
public void SetRenderState(RenderState state, float v) { }
|
||||
public void SetRenderState(RenderState state, bool v) { }
|
||||
public void SetRenderState(RenderState state, int v) { }
|
||||
public void SetRenderState(RenderState state, Cull v) { }
|
||||
public void SetRenderState(RenderState state, Blend v) { }
|
||||
public void SetRenderState(RenderState state, BlendOperation v) { }
|
||||
public void SetRenderState(RenderState state, FillMode v) { }
|
||||
public Matrix GetTransform(TransformState state) { return Matrix.Identity; }
|
||||
public void SetTransform(TransformState state, Matrix matrix) { }
|
||||
public void SetSamplerState(int unit, SamplerState state, TextureAddress address) { }
|
||||
public void DrawPrimitives(PrimitiveType type, int startIndex, int primitiveCount) { }
|
||||
public void DrawUserPrimitives<T>(PrimitiveType type, int startIndex, int primitiveCount, T[] data) where T : struct { }
|
||||
public void SetVertexDeclaration(VertexDeclaration decl) { }
|
||||
~D3DDevice()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
public void Dispose() { }
|
||||
public bool Disposed { get { return Handle == IntPtr.Zero; } }
|
||||
|
||||
internal void RegisterResource(ID3DResource res) { }
|
||||
internal void UnregisterResource(ID3DResource res) { }
|
||||
public void Dispose()
|
||||
{
|
||||
if (!Disposed)
|
||||
{
|
||||
RenderDevice_Delete(Handle);
|
||||
Handle = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetStreamSource(int index, VertexBuffer buffer, long offset, long stride)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetRenderState(RenderState state, float v)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetRenderState(RenderState state, bool v)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetRenderState(RenderState state, int v)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetRenderState(RenderState state, Cull v)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetRenderState(RenderState state, Blend v)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetRenderState(RenderState state, BlendOperation v)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetRenderState(RenderState state, FillMode v)
|
||||
{
|
||||
}
|
||||
|
||||
public Matrix GetTransform(TransformState state)
|
||||
{
|
||||
return Matrix.Identity;
|
||||
}
|
||||
|
||||
public void SetTransform(TransformState state, Matrix matrix)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetSamplerState(int unit, SamplerState state, TextureAddress address)
|
||||
{
|
||||
}
|
||||
|
||||
public void DrawPrimitives(PrimitiveType type, int startIndex, int primitiveCount)
|
||||
{
|
||||
}
|
||||
|
||||
public void DrawUserPrimitives<T>(PrimitiveType type, int startIndex, int primitiveCount, T[] data) where T : struct
|
||||
{
|
||||
}
|
||||
|
||||
public void SetVertexDeclaration(VertexDeclaration decl)
|
||||
{
|
||||
}
|
||||
|
||||
internal void RegisterResource(ID3DResource res)
|
||||
{
|
||||
}
|
||||
|
||||
internal void UnregisterResource(ID3DResource res)
|
||||
{
|
||||
}
|
||||
|
||||
public void StartRendering(bool clear, Color4 backcolor)
|
||||
{
|
||||
//if (clear)
|
||||
// Clear(ClearFlags.Target | ClearFlags.ZBuffer, backcolor, 1f, 0);
|
||||
}
|
||||
|
||||
public void StartRendering(bool clear, Color4 backcolor, Texture target, bool usedepthbuffer)
|
||||
{
|
||||
//if (clear)
|
||||
// Clear(ClearFlags.Target, backcolor, 1f, 0);
|
||||
}
|
||||
public void FinishRendering() { }
|
||||
public void Present() { }
|
||||
public void ClearTexture(Color4 backcolor, Texture texture) { }
|
||||
public void CopyTexture(Texture src, CubeTexture dst, CubeMapFace face) { }
|
||||
|
||||
//mxd. Anisotropic filtering steps
|
||||
public static readonly List<float> AF_STEPS = new List<float> { 1.0f, 2.0f, 4.0f, 8.0f, 16.0f };
|
||||
|
||||
//mxd. Antialiasing steps
|
||||
public static readonly List<int> AA_STEPS = new List<int> { 0, 2, 4, 8 };
|
||||
public void FinishRendering()
|
||||
{
|
||||
}
|
||||
|
||||
internal RenderTargetControl RenderTarget { get; private set; }
|
||||
internal ShaderManager Shaders { get; private set; }
|
||||
public void Present()
|
||||
{
|
||||
}
|
||||
|
||||
public void ClearTexture(Color4 backcolor, Texture texture)
|
||||
{
|
||||
}
|
||||
|
||||
public void CopyTexture(Texture src, CubeTexture dst, CubeMapFace face)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetupSettings()
|
||||
{
|
||||
|
@ -260,8 +183,25 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
Presentation.Initialize();
|
||||
}
|
||||
|
||||
// Make a color from ARGB
|
||||
public static int ARGB(float a, float r, float g, float b)
|
||||
IntPtr Handle;
|
||||
|
||||
[DllImport("BuilderNative.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr RenderDevice_New();
|
||||
|
||||
[DllImport("BuilderNative.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void RenderDevice_Delete(IntPtr handle);
|
||||
|
||||
//mxd. Anisotropic filtering steps
|
||||
public static readonly List<float> AF_STEPS = new List<float> { 1.0f, 2.0f, 4.0f, 8.0f, 16.0f };
|
||||
|
||||
//mxd. Antialiasing steps
|
||||
public static readonly List<int> AA_STEPS = new List<int> { 0, 2, 4, 8 };
|
||||
|
||||
internal RenderTargetControl RenderTarget { get; private set; }
|
||||
internal ShaderManager Shaders { get; private set; }
|
||||
|
||||
// Make a color from ARGB
|
||||
public static int ARGB(float a, float r, float g, float b)
|
||||
{
|
||||
return Color.FromArgb((int)(a * 255f), (int)(r * 255f), (int)(g * 255f), (int)(b * 255f)).ToArgb();
|
||||
}
|
||||
|
@ -296,5 +236,36 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
return new Vector2D(v2.X, v2.Y);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public enum RenderState
|
||||
{
|
||||
AlphaBlendEnable,
|
||||
AlphaRef,
|
||||
AlphaTestEnable,
|
||||
CullMode,
|
||||
BlendOperation,
|
||||
SourceBlend,
|
||||
DestinationBlend,
|
||||
FillMode,
|
||||
FogEnable,
|
||||
FogColor,
|
||||
FogStart,
|
||||
FogEnd,
|
||||
MultisampleAntialias,
|
||||
TextureFactor,
|
||||
ZEnable,
|
||||
ZWriteEnable
|
||||
}
|
||||
|
||||
public enum Cull { None, Counterclockwise }
|
||||
public enum Blend { InverseSourceAlpha, SourceAlpha, One, BlendFactor }
|
||||
public enum BlendOperation { Add, ReverseSubtract }
|
||||
public enum FillMode { Solid, Wireframe }
|
||||
public enum TransformState { World, View, Projection }
|
||||
public enum SamplerState { AddressU, AddressV, AddressW }
|
||||
public enum TextureAddress { Wrap, Clamp }
|
||||
public enum Format { Unknown, A8R8G8B8 }
|
||||
public enum ShaderFlags { None, Debug }
|
||||
public enum PrimitiveType { LineList, TriangleList, TriangleStrip }
|
||||
public enum TextureFilter { None, Point, Linear, Anisotropic }
|
||||
}
|
||||
|
|
68
Source/Core/Rendering/Effect.cs
Normal file
68
Source/Core/Rendering/Effect.cs
Normal file
|
@ -0,0 +1,68 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
|
||||
namespace CodeImp.DoomBuilder.Rendering
|
||||
{
|
||||
public class Effect
|
||||
{
|
||||
public static Effect FromStream(Stream stream, ShaderFlags flags, out string errors)
|
||||
{
|
||||
errors = "";
|
||||
return new Effect();
|
||||
}
|
||||
|
||||
public void SetTexture(EffectHandle handle, BaseTexture texture)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetValue<T>(EffectHandle handle, T value) where T : struct
|
||||
{
|
||||
}
|
||||
|
||||
public EffectHandle GetParameter(EffectHandle parameter, string name)
|
||||
{
|
||||
if (!Parameters.ContainsKey(name))
|
||||
{
|
||||
Parameters[name] = new EffectHandle();
|
||||
}
|
||||
return Parameters[name];
|
||||
}
|
||||
|
||||
public void CommitChanges()
|
||||
{
|
||||
}
|
||||
|
||||
public void Begin()
|
||||
{
|
||||
}
|
||||
|
||||
public void BeginPass(int index)
|
||||
{
|
||||
}
|
||||
|
||||
public void EndPass()
|
||||
{
|
||||
}
|
||||
|
||||
public void End()
|
||||
{
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
Dictionary<string, EffectHandle> Parameters = new Dictionary<string, EffectHandle>();
|
||||
}
|
||||
|
||||
public class EffectHandle
|
||||
{
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,13 +15,14 @@
|
|||
#endregion
|
||||
|
||||
#region ================== Namespaces
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Rendering
|
||||
{
|
||||
// FlatVertex
|
||||
public struct FlatVertex
|
||||
// FlatVertex
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct FlatVertex
|
||||
{
|
||||
// Vertex format
|
||||
public const int Stride = 24; //6 * 4
|
||||
|
|
51
Source/Core/Rendering/IndexBuffer.cs
Normal file
51
Source/Core/Rendering/IndexBuffer.cs
Normal file
|
@ -0,0 +1,51 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace CodeImp.DoomBuilder.Rendering
|
||||
{
|
||||
public class IndexBuffer : IDisposable
|
||||
{
|
||||
public IndexBuffer(int sizeInBytes)
|
||||
{
|
||||
Handle = IndexBuffer_New(sizeInBytes);
|
||||
if (Handle == IntPtr.Zero)
|
||||
throw new Exception("IndexBuffer_New failed");
|
||||
}
|
||||
|
||||
~IndexBuffer()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
public void SetBufferData(int[] data)
|
||||
{
|
||||
IndexBuffer_SetBufferData(Handle, data, data.Length * Marshal.SizeOf<int>());
|
||||
}
|
||||
|
||||
public bool Disposed { get { return Handle == IntPtr.Zero; } }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (!Disposed)
|
||||
{
|
||||
IndexBuffer_Delete(Handle);
|
||||
Handle = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
IntPtr Handle;
|
||||
|
||||
[DllImport("BuilderNative.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr IndexBuffer_New(int sizeInBytes);
|
||||
|
||||
[DllImport("BuilderNative.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void IndexBuffer_Delete(IntPtr handle);
|
||||
|
||||
[DllImport("BuilderNative.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void IndexBuffer_SetBufferData(IntPtr handle, int[] data, long size);
|
||||
}
|
||||
}
|
39
Source/Core/Rendering/Mesh.cs
Normal file
39
Source/Core/Rendering/Mesh.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CodeImp.DoomBuilder.Rendering
|
||||
{
|
||||
public class Mesh : IDisposable
|
||||
{
|
||||
public Mesh(VertexElement[] vertexDecl, WorldVertex[] vertexData, int[] indexData)
|
||||
{
|
||||
VertexDecl = new VertexDeclaration(vertexDecl);
|
||||
unsafe { Vertices = new VertexBuffer(sizeof(WorldVertex)); }
|
||||
Vertices.SetBufferData(vertexData);
|
||||
Indices = new IndexBuffer(sizeof(int) * indexData.Length);
|
||||
Indices.SetBufferData(indexData);
|
||||
}
|
||||
|
||||
~Mesh()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
public void DrawSubset(int index)
|
||||
{
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (Vertices != null) Vertices.Dispose();
|
||||
if (Indices != null) Indices.Dispose();
|
||||
}
|
||||
|
||||
VertexDeclaration VertexDecl;
|
||||
VertexBuffer Vertices;
|
||||
IndexBuffer Indices;
|
||||
}
|
||||
}
|
101
Source/Core/Rendering/Texture.cs
Normal file
101
Source/Core/Rendering/Texture.cs
Normal file
|
@ -0,0 +1,101 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace CodeImp.DoomBuilder.Rendering
|
||||
{
|
||||
public class BaseTexture : IDisposable
|
||||
{
|
||||
public BaseTexture()
|
||||
{
|
||||
Handle = Texture_New();
|
||||
if (Handle == IntPtr.Zero)
|
||||
throw new Exception("Texture_New failed");
|
||||
}
|
||||
|
||||
~BaseTexture()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
public bool Disposed { get { return Handle == IntPtr.Zero; } }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (!Disposed)
|
||||
{
|
||||
Texture_Delete(Handle);
|
||||
Handle = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
IntPtr Handle;
|
||||
|
||||
[DllImport("BuilderNative.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr Texture_New();
|
||||
|
||||
[DllImport("BuilderNative.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void Texture_Delete(IntPtr handle);
|
||||
}
|
||||
|
||||
public class Texture : BaseTexture
|
||||
{
|
||||
public Texture(int width, int height, int levels, Format format)
|
||||
{
|
||||
}
|
||||
|
||||
public int Width { get; private set; }
|
||||
public int Height { get; private set; }
|
||||
|
||||
public object Tag { get; set; }
|
||||
|
||||
public void SetPixels(System.Drawing.Bitmap bitmap)
|
||||
{
|
||||
/*
|
||||
BitmapData bmpdata = bitmap.LockBits(new Rectangle(0, 0, bitmap.Size.Width, bitmap.Size.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
|
||||
|
||||
DataRectangle textureLock = texture.LockRectangle(0, LockFlags.None);
|
||||
textureLock.Data.WriteRange(bmlock.Scan0, bmlock.Height * bmlock.Stride);
|
||||
texture.UnlockRectangle(0);
|
||||
|
||||
bitmap.UnlockBits(bmpdata);
|
||||
*/
|
||||
}
|
||||
|
||||
internal Plotter LockPlotter(int visibleWidth, int visibleHeight)
|
||||
{
|
||||
//return new Plotter((PixelColor*)plotlocked.Data.DataPointer.ToPointer(), plotlocked.Pitch / sizeof(PixelColor), Height, visibleWidth, visibleHeight);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void UnlockPlotter()
|
||||
{
|
||||
}
|
||||
|
||||
public static Texture FromStream(System.IO.Stream stream)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Texture FromStream(System.IO.Stream stream, int length, int width, int height, int levels, Format format)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class CubeTexture : BaseTexture
|
||||
{
|
||||
public CubeTexture(int size, int levels, Format format)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetPixels(CubeMapFace face, System.Drawing.Bitmap bitmap)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public enum CubeMapFace { PositiveX, PositiveY, PositiveZ, NegativeX, NegativeY, NegativeZ }
|
||||
}
|
81
Source/Core/Rendering/VertexBuffer.cs
Normal file
81
Source/Core/Rendering/VertexBuffer.cs
Normal file
|
@ -0,0 +1,81 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace CodeImp.DoomBuilder.Rendering
|
||||
{
|
||||
public class VertexBuffer : IDisposable
|
||||
{
|
||||
public VertexBuffer(int sizeInBytes)
|
||||
{
|
||||
Handle = VertexBuffer_New(sizeInBytes);
|
||||
if (Handle == IntPtr.Zero)
|
||||
throw new Exception("VertexBuffer_New failed");
|
||||
}
|
||||
|
||||
~VertexBuffer()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
public void SetBufferData(FlatVertex[] data)
|
||||
{
|
||||
VertexBuffer_SetBufferData(Handle, data, data.Length * Marshal.SizeOf<FlatVertex>());
|
||||
}
|
||||
|
||||
public void SetBufferData(WorldVertex[] data)
|
||||
{
|
||||
VertexBuffer_SetBufferData(Handle, data, data.Length * Marshal.SizeOf<WorldVertex>());
|
||||
}
|
||||
|
||||
public void SetBufferSubdata(long destOffset, FlatVertex[] data)
|
||||
{
|
||||
VertexBuffer_SetBufferSubdata(Handle, destOffset, data, data.Length * Marshal.SizeOf<FlatVertex>());
|
||||
}
|
||||
|
||||
public void SetBufferSubdata(long destOffset, WorldVertex[] data)
|
||||
{
|
||||
VertexBuffer_SetBufferSubdata(Handle, destOffset, data, data.Length * Marshal.SizeOf<WorldVertex>());
|
||||
}
|
||||
|
||||
public void SetBufferSubdata(long destOffset, FlatVertex[] data, long offset, long size)
|
||||
{
|
||||
if (data.Length < size || size < 0) throw new ArgumentOutOfRangeException("size");
|
||||
VertexBuffer_SetBufferSubdata(Handle, destOffset, data, size * Marshal.SizeOf<FlatVertex>());
|
||||
}
|
||||
|
||||
public bool Disposed { get { return Handle == IntPtr.Zero; } }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (!Disposed)
|
||||
{
|
||||
VertexBuffer_Delete(Handle);
|
||||
Handle = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
IntPtr Handle;
|
||||
|
||||
[DllImport("BuilderNative.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr VertexBuffer_New(int sizeInBytes);
|
||||
|
||||
[DllImport("BuilderNative.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void VertexBuffer_Delete(IntPtr handle);
|
||||
|
||||
[DllImport("BuilderNative.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void VertexBuffer_SetBufferData(IntPtr handle, FlatVertex[] data, long size);
|
||||
|
||||
[DllImport("BuilderNative.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void VertexBuffer_SetBufferData(IntPtr handle, WorldVertex[] data, long size);
|
||||
|
||||
[DllImport("BuilderNative.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void VertexBuffer_SetBufferSubdata(IntPtr handle, long destOffset, FlatVertex[] data, long sizeInBytes);
|
||||
|
||||
[DllImport("BuilderNative.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void VertexBuffer_SetBufferSubdata(IntPtr handle, long destOffset, WorldVertex[] data, long sizeInBytes);
|
||||
}
|
||||
}
|
63
Source/Core/Rendering/VertexDeclaration.cs
Normal file
63
Source/Core/Rendering/VertexDeclaration.cs
Normal file
|
@ -0,0 +1,63 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace CodeImp.DoomBuilder.Rendering
|
||||
{
|
||||
public class VertexDeclaration : IDisposable
|
||||
{
|
||||
public VertexDeclaration(VertexElement[] elements)
|
||||
{
|
||||
Handle = VertexDeclaration_New(elements, elements.Length);
|
||||
if (Handle == IntPtr.Zero)
|
||||
throw new Exception("VertexDeclaration_New failed");
|
||||
}
|
||||
|
||||
~VertexDeclaration()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
public bool Disposed { get { return Handle == IntPtr.Zero; } }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (!Disposed)
|
||||
{
|
||||
VertexDeclaration_Delete(Handle);
|
||||
Handle = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
IntPtr Handle;
|
||||
|
||||
[DllImport("BuilderNative.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr VertexDeclaration_New(VertexElement[] elements, int count);
|
||||
|
||||
[DllImport("BuilderNative.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void VertexDeclaration_Delete(IntPtr handle);
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct VertexElement
|
||||
{
|
||||
public VertexElement(short stream, short offset, DeclarationType type, DeclarationUsage usage)
|
||||
{
|
||||
Stream = stream;
|
||||
Offset = offset;
|
||||
Type = type;
|
||||
Usage = usage;
|
||||
}
|
||||
|
||||
public short Stream;
|
||||
public short Offset;
|
||||
public DeclarationType Type;
|
||||
public DeclarationUsage Usage;
|
||||
}
|
||||
|
||||
public enum DeclarationType : int { Float2, Float3, Color }
|
||||
public enum DeclarationUsage : int { Position, Color, TextureCoordinate, Normal }
|
||||
}
|
|
@ -17,13 +17,15 @@
|
|||
#region ================== Namespaces
|
||||
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Rendering
|
||||
{
|
||||
// WorldVertex
|
||||
public struct WorldVertex
|
||||
// WorldVertex
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct WorldVertex
|
||||
{
|
||||
// Vertex format
|
||||
public const int Stride = 36; //mxd: 9 * 4, was 6 * 4
|
||||
|
|
199
Source/Native/BuilderNative.vcxproj
Normal file
199
Source/Native/BuilderNative.vcxproj
Normal file
|
@ -0,0 +1,199 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{78938655-9807-485E-9D4B-46226DC7AD27}</ProjectGuid>
|
||||
<RootNamespace>BuilderNative</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>14.0.25431.1</_ProjectFileVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(ProjectDir)..\..\Build\</OutDir>
|
||||
<IntDir>$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>$(ProjectDir)..\..\Build\</OutDir>
|
||||
<IntDir>$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(ProjectDir)..\..\Build\</OutDir>
|
||||
<IntDir>$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>$(ProjectDir)..\..\Build\</OutDir>
|
||||
<IntDir>$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<OutputFile>$(OutDir)BuilderNative.dll</OutputFile>
|
||||
<ModuleDefinitionFile>exports.def</ModuleDefinitionFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<FixedBaseAddress>false</FixedBaseAddress>
|
||||
<SupportUnloadOfDelayLoadedDLL>true</SupportUnloadOfDelayLoadedDLL>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<OutputFile>$(OutDir)BuilderNative.dll</OutputFile>
|
||||
<ModuleDefinitionFile>exports.def</ModuleDefinitionFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<FixedBaseAddress>false</FixedBaseAddress>
|
||||
<SupportUnloadOfDelayLoadedDLL>true</SupportUnloadOfDelayLoadedDLL>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_RELEASE;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
<FloatingPointModel>Fast</FloatingPointModel>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<OutputFile>$(OutDir)BuilderNative.dll</OutputFile>
|
||||
<ModuleDefinitionFile>exports.def</ModuleDefinitionFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<FixedBaseAddress>false</FixedBaseAddress>
|
||||
<SupportUnloadOfDelayLoadedDLL>true</SupportUnloadOfDelayLoadedDLL>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_RELEASE;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
<FloatingPointModel>Fast</FloatingPointModel>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<OutputFile>$(OutDir)BuilderNative.dll</OutputFile>
|
||||
<ModuleDefinitionFile>exports.def</ModuleDefinitionFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<FixedBaseAddress>false</FixedBaseAddress>
|
||||
<SupportUnloadOfDelayLoadedDLL>true</SupportUnloadOfDelayLoadedDLL>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<None Include="exports.def" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="IndexBuffer.cpp" />
|
||||
<ClCompile Include="RenderDevice.cpp" />
|
||||
<ClCompile Include="Texture.cpp" />
|
||||
<ClCompile Include="VertexBuffer.cpp" />
|
||||
<ClCompile Include="VertexDeclaration.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="IndexBuffer.h" />
|
||||
<ClInclude Include="RenderDevice.h" />
|
||||
<ClInclude Include="Texture.h" />
|
||||
<ClInclude Include="VertexBuffer.h" />
|
||||
<ClInclude Include="VertexDeclaration.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
4
Source/Native/BuilderNative.vcxproj.user
Normal file
4
Source/Native/BuilderNative.vcxproj.user
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
</Project>
|
27
Source/Native/IndexBuffer.cpp
Normal file
27
Source/Native/IndexBuffer.cpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
|
||||
#include "IndexBuffer.h"
|
||||
|
||||
IndexBuffer::IndexBuffer(int sizeInBytes)
|
||||
{
|
||||
}
|
||||
|
||||
void IndexBuffer::SetBufferData(const void* data, int64_t size)
|
||||
{
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
IndexBuffer* IndexBuffer_New(int sizeInBytes)
|
||||
{
|
||||
return new IndexBuffer(sizeInBytes);
|
||||
}
|
||||
|
||||
void IndexBuffer_Delete(IndexBuffer* buffer)
|
||||
{
|
||||
delete buffer;
|
||||
}
|
||||
|
||||
void IndexBuffer_SetBufferData(IndexBuffer* handle, void* data, int64_t size)
|
||||
{
|
||||
handle->SetBufferData(data, size);
|
||||
}
|
11
Source/Native/IndexBuffer.h
Normal file
11
Source/Native/IndexBuffer.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class IndexBuffer
|
||||
{
|
||||
public:
|
||||
IndexBuffer(int sizeInBytes);
|
||||
|
||||
void SetBufferData(const void* data, int64_t size);
|
||||
};
|
16
Source/Native/RenderDevice.cpp
Normal file
16
Source/Native/RenderDevice.cpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
#include "RenderDevice.h"
|
||||
|
||||
RenderDevice::RenderDevice()
|
||||
{
|
||||
}
|
||||
|
||||
RenderDevice* RenderDevice_New()
|
||||
{
|
||||
return new RenderDevice();
|
||||
}
|
||||
|
||||
void RenderDevice_Delete(RenderDevice* device)
|
||||
{
|
||||
delete device;
|
||||
}
|
9
Source/Native/RenderDevice.h
Normal file
9
Source/Native/RenderDevice.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class RenderDevice
|
||||
{
|
||||
public:
|
||||
RenderDevice();
|
||||
};
|
16
Source/Native/Texture.cpp
Normal file
16
Source/Native/Texture.cpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
#include "Texture.h"
|
||||
|
||||
Texture::Texture()
|
||||
{
|
||||
}
|
||||
|
||||
Texture* Texture_New()
|
||||
{
|
||||
return new Texture();
|
||||
}
|
||||
|
||||
void Texture_Delete(Texture* tex)
|
||||
{
|
||||
delete tex;
|
||||
}
|
9
Source/Native/Texture.h
Normal file
9
Source/Native/Texture.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class Texture
|
||||
{
|
||||
public:
|
||||
Texture();
|
||||
};
|
36
Source/Native/VertexBuffer.cpp
Normal file
36
Source/Native/VertexBuffer.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
|
||||
#include "VertexBuffer.h"
|
||||
|
||||
VertexBuffer::VertexBuffer(int sizeInBytes)
|
||||
{
|
||||
}
|
||||
|
||||
void VertexBuffer::SetBufferData(const void* data, int64_t size)
|
||||
{
|
||||
}
|
||||
|
||||
void VertexBuffer::SetBufferSubdata(int64_t destOffset, const void* data, int64_t size)
|
||||
{
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VertexBuffer* VertexBuffer_New(int sizeInBytes)
|
||||
{
|
||||
return new VertexBuffer(sizeInBytes);
|
||||
}
|
||||
|
||||
void VertexBuffer_Delete(VertexBuffer* buffer)
|
||||
{
|
||||
delete buffer;
|
||||
}
|
||||
|
||||
void VertexBuffer_SetBufferData(VertexBuffer* handle, void* data, int64_t size)
|
||||
{
|
||||
handle->SetBufferData(data, size);
|
||||
}
|
||||
|
||||
void VertexBuffer_SetBufferSubdata(VertexBuffer* handle, int64_t destOffset, void* data, int64_t size)
|
||||
{
|
||||
handle->SetBufferSubdata(destOffset, data, size);
|
||||
}
|
12
Source/Native/VertexBuffer.h
Normal file
12
Source/Native/VertexBuffer.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class VertexBuffer
|
||||
{
|
||||
public:
|
||||
VertexBuffer(int sizeInBytes);
|
||||
|
||||
void SetBufferData(const void* data, int64_t size);
|
||||
void SetBufferSubdata(int64_t destOffset, const void* data, int64_t size);
|
||||
};
|
16
Source/Native/VertexDeclaration.cpp
Normal file
16
Source/Native/VertexDeclaration.cpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
#include "VertexDeclaration.h"
|
||||
|
||||
VertexDeclaration::VertexDeclaration(const VertexElement* elements, int count) : Elements(elements, elements + count)
|
||||
{
|
||||
}
|
||||
|
||||
VertexDeclaration* VertexDeclaration_New(const VertexElement* elements, int count)
|
||||
{
|
||||
return new VertexDeclaration(elements, count);
|
||||
}
|
||||
|
||||
void VertexDeclaration_Delete(VertexDeclaration* decl)
|
||||
{
|
||||
delete decl;
|
||||
}
|
23
Source/Native/VertexDeclaration.h
Normal file
23
Source/Native/VertexDeclaration.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
enum class DeclarationType : int32_t { Float2, Float3, Color };
|
||||
enum class DeclarationUsage : int32_t { Position, Color, TextureCoordinate, Normal };
|
||||
|
||||
struct VertexElement
|
||||
{
|
||||
int16_t Stream;
|
||||
int16_t Offset;
|
||||
DeclarationType Type;
|
||||
DeclarationUsage Usage;
|
||||
};
|
||||
|
||||
class VertexDeclaration
|
||||
{
|
||||
public:
|
||||
VertexDeclaration(const VertexElement* elements, int count);
|
||||
|
||||
std::vector<VertexElement> Elements;
|
||||
};
|
16
Source/Native/exports.def
Normal file
16
Source/Native/exports.def
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
EXPORTS
|
||||
|
||||
RenderDevice_New
|
||||
RenderDevice_Delete
|
||||
VertexBuffer_New
|
||||
VertexBuffer_Delete
|
||||
VertexBuffer_SetBufferData
|
||||
VertexBuffer_SetBufferSubdata
|
||||
VertexDeclaration_New
|
||||
VertexDeclaration_Delete
|
||||
IndexBuffer_New
|
||||
IndexBuffer_Delete
|
||||
IndexBuffer_SetBufferData
|
||||
Texture_New
|
||||
Texture_Delete
|
Loading…
Reference in a new issue