mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-22 11:51:25 +00:00
Fixed: line can be either dotted or smoothed
This commit is contained in:
parent
ca75897bc5
commit
d1ff6bcc36
7 changed files with 612 additions and 535 deletions
26
Builder.sln
26
Builder.sln
|
@ -1,7 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29201.188
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Builder", "Source\Core\Builder.csproj", "{818B3D10-F791-4C3F-9AF5-BB2D0079B63C}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
|
@ -322,6 +322,28 @@ 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|Any CPU.ActiveCfg = Release|x64
|
||||
{78938655-9807-485E-9D4B-46226DC7AD27}.Debug + Profiler|Any CPU.Build.0 = Release|x64
|
||||
{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|Any CPU.ActiveCfg = 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|Any CPU.ActiveCfg = Release|x64
|
||||
{78938655-9807-485E-9D4B-46226DC7AD27}.Release + Profiler|Any CPU.Build.0 = Release|x64
|
||||
{78938655-9807-485E-9D4B-46226DC7AD27}.Release + Profiler|x64.ActiveCfg = Release|x64
|
||||
{78938655-9807-485E-9D4B-46226DC7AD27}.Release + Profiler|x64.Build.0 = Release|x64
|
||||
{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|Any CPU.ActiveCfg = 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
|
||||
{88CFD996-027B-4CBE-9828-26B2728B6127}.Debug + Profiler|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{88CFD996-027B-4CBE-9828-26B2728B6127}.Debug + Profiler|Any CPU.Build.0 = Debug|Any CPU
|
||||
{88CFD996-027B-4CBE-9828-26B2728B6127}.Debug + Profiler|x64.ActiveCfg = Debug|x64
|
||||
|
|
|
@ -1509,45 +1509,5 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>echo Current Output Directory: %25cd%25
|
||||
echo Copying platform-appropriate DevIL.dll file.
|
||||
copy /Y ..\DevIL\$(PlatformName)\DevIL.dll .\
|
||||
echo Copying platform-appropriate SlimDX.dll file.
|
||||
copy /Y ..\SlimDX\$(PlatformName)\SlimDX.dll .\
|
||||
echo Copying platform-appropriate Updater.ini.
|
||||
copy /Y ..\UpdaterConfig\Updater-$(PlatformName).ini Updater.ini</PreBuildEvent>
|
||||
<PostBuildEvent>if exist "%25VS140COMNTOOLS%25" goto tools140
|
||||
if exist "%25VS120COMNTOOLS%25" goto tools120
|
||||
if exist "%25VS110COMNTOOLS%25" goto tools110
|
||||
if exist "%25VS100COMNTOOLS%25" goto tools100
|
||||
if exist "%25VS90COMNTOOLS%25" goto tools90
|
||||
if exist "%25VSAPPIDDIR%25" goto tools17
|
||||
|
||||
:tools17
|
||||
call "%25VSAPPIDDIR%25..\Tools\vsdevcmd" -arch=x86
|
||||
goto end
|
||||
|
||||
:tools140
|
||||
call "%25VS140COMNTOOLS%25vsvars32.bat"
|
||||
goto end
|
||||
|
||||
:tools120
|
||||
call "%25VS120COMNTOOLS%25vsvars32.bat"
|
||||
goto end
|
||||
|
||||
:tools110
|
||||
call "%25VS110COMNTOOLS%25vsvars32.bat"
|
||||
goto end
|
||||
|
||||
:tools100
|
||||
call "%25VS100COMNTOOLS%25vsvars32.bat"
|
||||
goto end
|
||||
|
||||
:tools90
|
||||
call "%25VS90COMNTOOLS%25vsvars32.bat"
|
||||
goto end
|
||||
|
||||
:end
|
||||
editbin.exe /NOLOGO /LARGEADDRESSAWARE "$(TargetPath)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -42,7 +42,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
|
||||
public void DrawContents(RenderDevice graphics)
|
||||
{
|
||||
if (clear == false && vertices.Count == 0)
|
||||
if (clear == false && Lists.Count == 0)
|
||||
return;
|
||||
|
||||
var projmat = Matrix.Scaling(2.0f / this.Texture.Width, 2.0f / this.Texture.Height, 1.0f) * Matrix.Translation(-1.0f, -1.0f, 0.0f);
|
||||
|
@ -54,12 +54,30 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.SetBlendOperation(BlendOperation.Add);
|
||||
graphics.SetSourceBlend(Blend.SourceAlpha);
|
||||
graphics.SetDestinationBlend(Blend.InverseSourceAlpha);
|
||||
graphics.Draw(PrimitiveType.TriangleList, 0, vertices.Count / 3, vertices.ToArray());
|
||||
for (int i = 0; i < Lists.Count; i++)
|
||||
{
|
||||
PrimitiveType pt = Lists[i].PrimitiveType;
|
||||
List<FlatVertex> vertices = Lists[i].Vertices;
|
||||
int cnt = vertices.Count;
|
||||
switch (pt)
|
||||
{
|
||||
case PrimitiveType.TriangleList:
|
||||
cnt /= 3;
|
||||
break;
|
||||
case PrimitiveType.LineList:
|
||||
cnt /= 2;
|
||||
break;
|
||||
case PrimitiveType.TriangleStrip:
|
||||
cnt = 1;
|
||||
break;
|
||||
}
|
||||
graphics.Draw(Lists[i].PrimitiveType, 0, cnt, vertices.ToArray());
|
||||
}
|
||||
graphics.SetAlphaBlendEnable(false);
|
||||
graphics.FinishRendering();
|
||||
|
||||
clear = false;
|
||||
vertices.Clear();
|
||||
Lists.Clear();
|
||||
}
|
||||
|
||||
private int TransformY(int y)
|
||||
|
@ -67,11 +85,9 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
return this.Texture.Height - y;
|
||||
}
|
||||
|
||||
void DrawLine(int x0, int y0, int x1, int y1, int c, bool dotted = false)
|
||||
// non-dotted line may be smoothed
|
||||
void DrawSmoothedLine(int x0, int y0, int x1, int y1, int c)
|
||||
{
|
||||
y0 = TransformY(y0);
|
||||
y1 = TransformY(y1);
|
||||
|
||||
var v = new FlatVertex();
|
||||
v.c = c;
|
||||
|
||||
|
@ -105,28 +121,73 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
float xx1 = x1 + 0.5f + dx;
|
||||
float yy1 = y1 + 0.5f + dy;
|
||||
|
||||
float start, end;
|
||||
if (!dotted)
|
||||
{
|
||||
start = 0.5f;
|
||||
end = 0.5f;
|
||||
}
|
||||
else
|
||||
{
|
||||
start = 0.0f;
|
||||
end = len;
|
||||
}
|
||||
|
||||
float lineextent = 3.0f; // line width in shader + 1
|
||||
nx *= lineextent;
|
||||
ny *= lineextent;
|
||||
|
||||
v.u = start; v.v = -lineextent; v.x = xx0 - nx; v.y = yy0 - ny; vertices.Add(v);
|
||||
v.u = start; v.v = lineextent; v.x = xx0 + nx; v.y = yy0 + ny; vertices.Add(v);
|
||||
v.u = end; v.v = lineextent; v.x = xx1 + nx; v.y = yy1 + ny; vertices.Add(v);
|
||||
vertices.Add(v);
|
||||
v.u = end; v.v = -lineextent; v.x = xx1 - nx; v.y = yy1 - ny; vertices.Add(v);
|
||||
v.u = start; v.v = -lineextent; v.x = xx0 - nx; v.y = yy0 - ny; vertices.Add(v);
|
||||
v.u = 0.5f;
|
||||
|
||||
v.v = -lineextent; v.x = xx0 - nx; v.y = yy0 - ny; AddVertex(PrimitiveType.TriangleList, v);
|
||||
v.v = lineextent; v.x = xx0 + nx; v.y = yy0 + ny; AddVertex(PrimitiveType.TriangleList, v);
|
||||
v.v = lineextent; v.x = xx1 + nx; v.y = yy1 + ny; AddVertex(PrimitiveType.TriangleList, v);
|
||||
AddVertex(PrimitiveType.TriangleList, v);
|
||||
v.v = -lineextent; v.x = xx1 - nx; v.y = yy1 - ny; AddVertex(PrimitiveType.TriangleList, v);
|
||||
v.v = -lineextent; v.x = xx0 - nx; v.y = yy0 - ny; AddVertex(PrimitiveType.TriangleList, v);
|
||||
}
|
||||
|
||||
void DrawLine(int x0, int y0, int x1, int y1, int c, bool dotted = false)
|
||||
{
|
||||
y0 = TransformY(y0);
|
||||
y1 = TransformY(y1);
|
||||
|
||||
if (!dotted)
|
||||
{
|
||||
DrawSmoothedLine(x0, y0, x1, y1, c);
|
||||
return;
|
||||
}
|
||||
|
||||
var v = new FlatVertex();
|
||||
v.c = c;
|
||||
|
||||
float nx, ny, len;
|
||||
if (x0 == x1)
|
||||
{
|
||||
nx = 1.0f;
|
||||
ny = 0.0f;
|
||||
len = y1 - y0;
|
||||
}
|
||||
else if (y0 == y1)
|
||||
{
|
||||
nx = 0.0f;
|
||||
ny = 1.0f;
|
||||
len = x1 - x0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nx = (float)(y1 - y0);
|
||||
ny = (float)-(x1 - x0);
|
||||
len = (float)Math.Sqrt(nx * nx + ny * ny);
|
||||
nx /= len;
|
||||
ny /= len;
|
||||
}
|
||||
|
||||
float xx0 = x0 + 0.5f;
|
||||
float yy0 = y0 + 0.5f;
|
||||
float xx1 = x1 + 0.5f;
|
||||
float yy1 = y1 + 0.5f;
|
||||
|
||||
float dotType = 0;
|
||||
if (dotted)
|
||||
{
|
||||
if (Math.Abs(ny) > Math.Abs(nx))
|
||||
dotType = -1;
|
||||
else dotType = -2;
|
||||
}
|
||||
|
||||
v.u = dotType; v.v = 0; v.x = xx0; v.y = yy0;
|
||||
AddVertex(PrimitiveType.LineList, v);
|
||||
v.u = dotType; v.v = 0; v.x = xx1; v.y = yy1;
|
||||
AddVertex(PrimitiveType.LineList, v);
|
||||
}
|
||||
|
||||
void FillBox(int x0, int y0, int x1, int y1, int c)
|
||||
|
@ -139,12 +200,12 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
v.u = 0.5f;
|
||||
v.v = 0.0f;
|
||||
|
||||
v.x = x0; v.y = y0; vertices.Add(v);
|
||||
v.x = x1; v.y = y0; vertices.Add(v);
|
||||
v.x = x1; v.y = y1; vertices.Add(v);
|
||||
vertices.Add(v);
|
||||
v.x = x0; v.y = y1; vertices.Add(v);
|
||||
v.x = x0; v.y = y0; vertices.Add(v);
|
||||
v.x = x0; v.y = y0; AddVertex(PrimitiveType.TriangleList, v);
|
||||
v.x = x1; v.y = y0; AddVertex(PrimitiveType.TriangleList, v);
|
||||
v.x = x1; v.y = y1; AddVertex(PrimitiveType.TriangleList, v);
|
||||
AddVertex(PrimitiveType.TriangleList, v);
|
||||
v.x = x0; v.y = y1; AddVertex(PrimitiveType.TriangleList, v);
|
||||
v.x = x0; v.y = y0; AddVertex(PrimitiveType.TriangleList, v);
|
||||
}
|
||||
|
||||
public void DrawVertexSolid(int x, int y, int size, PixelColor c, PixelColor l, PixelColor d)
|
||||
|
@ -214,7 +275,26 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
}
|
||||
|
||||
bool clear = true;
|
||||
List<FlatVertex> vertices = new List<FlatVertex>();
|
||||
//
|
||||
private struct PlotVertexList
|
||||
{
|
||||
public PrimitiveType PrimitiveType;
|
||||
public List<FlatVertex> Vertices;
|
||||
}
|
||||
private List<PlotVertexList> Lists = new List<PlotVertexList>();
|
||||
|
||||
private void AddVertex(PrimitiveType t, FlatVertex v)
|
||||
{
|
||||
if (Lists.Count == 0 || Lists[Lists.Count-1].PrimitiveType != t)
|
||||
{
|
||||
PlotVertexList vxlist;
|
||||
vxlist.PrimitiveType = t;
|
||||
vxlist.Vertices = new List<FlatVertex>();
|
||||
Lists.Add(vxlist);
|
||||
}
|
||||
|
||||
Lists[Lists.Count - 1].Vertices.Add(v);
|
||||
}
|
||||
|
||||
const int DASH_INTERVAL = 16;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{78938655-9807-485E-9D4B-46226DC7AD27}</ProjectGuid>
|
||||
<RootNamespace>BuilderNative</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
|
|
|
@ -7,6 +7,7 @@ static const char* plotter_vs = R"(
|
|||
|
||||
out vec4 Color;
|
||||
out vec2 UV;
|
||||
out vec2 Pos;
|
||||
|
||||
uniform mat4 projection;
|
||||
|
||||
|
@ -15,20 +16,34 @@ static const char* plotter_vs = R"(
|
|||
gl_Position = projection * vec4(AttrPosition, 1.0f);
|
||||
Color = AttrColor;
|
||||
UV = AttrUV;
|
||||
Pos = AttrPosition.xy;
|
||||
}
|
||||
)";
|
||||
|
||||
const char* plotter_ps = R"(
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
in vec2 Pos;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec4 rendersettings;
|
||||
|
||||
void main()
|
||||
{
|
||||
if (UV.x < 0)
|
||||
{
|
||||
float yFrac = -(UV.x + 1);
|
||||
|
||||
vec2 tPos = vec2(
|
||||
gl_FragCoord.x,
|
||||
gl_FragCoord.y
|
||||
);
|
||||
|
||||
// line stipple
|
||||
if (mod(UV.x, 2.0) > 1.0)
|
||||
if (mod(floor(mix(tPos.x, tPos.y, yFrac)), 2.0) > 0f)
|
||||
discard;
|
||||
}
|
||||
|
||||
// line smoothing
|
||||
float linewidth = 3.0;
|
||||
|
|
Binary file not shown.
|
@ -21,7 +21,7 @@
|
|||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{29C8D76F-DE3D-482D-AD7D-B86BBD0824DE}</ProjectGuid>
|
||||
<RootNamespace>vpo_dll</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
|
|
Loading…
Reference in a new issue