mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-29 23:22:32 +00:00
- fix screenverts math and some line drawing bugs
This commit is contained in:
parent
4c0e6e8fcc
commit
0562dac685
4 changed files with 35 additions and 34 deletions
|
@ -105,8 +105,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
start = -0.5f;
|
start = 0.0f;
|
||||||
end = len + 0.5f;
|
end = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
float lineextent = 3.0f; // line width in shader + 1
|
float lineextent = 3.0f; // line width in shader + 1
|
||||||
|
@ -165,7 +165,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
|
|
||||||
public void DrawLineSolid(int x1, int y1, int x2, int y2, PixelColor c, bool dotted = false)
|
public void DrawLineSolid(int x1, int y1, int x2, int y2, PixelColor c, bool dotted = false)
|
||||||
{
|
{
|
||||||
DrawLine(x1, y1, x2, y2, c.ToInt(), true);
|
DrawLine(x1, y1, x2, y2, c.ToInt(), dotted);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawLine3DFloor(Vector2D start, Vector2D end, PixelColor c, PixelColor c2)
|
public void DrawLine3DFloor(Vector2D start, Vector2D end, PixelColor c, PixelColor c2)
|
||||||
|
|
|
@ -365,7 +365,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
graphics.SetBufferData(thingsvertices, THING_BUFFER_SIZE * 12, VertexFormat.Flat);
|
graphics.SetBufferData(thingsvertices, THING_BUFFER_SIZE * 12, VertexFormat.Flat);
|
||||||
|
|
||||||
// Make screen vertices
|
// Make screen vertices
|
||||||
FlatVertex[] verts = CreateScreenVerts(new Size(plotter.Width, plotter.Height));
|
FlatVertex[] verts = CreateScreenVerts(new Size(windowsize.Width, windowsize.Height));
|
||||||
graphics.SetBufferData(screenverts, verts);
|
graphics.SetBufferData(screenverts, verts);
|
||||||
|
|
||||||
// Force update of view
|
// Force update of view
|
||||||
|
@ -380,27 +380,27 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
private static FlatVertex[] CreateScreenVerts(Size texturesize)
|
private static FlatVertex[] CreateScreenVerts(Size texturesize)
|
||||||
{
|
{
|
||||||
FlatVertex[] screenverts = new FlatVertex[4];
|
FlatVertex[] screenverts = new FlatVertex[4];
|
||||||
screenverts[0].x = 0.5f;
|
screenverts[0].x = 0.0f;
|
||||||
screenverts[0].y = 0.5f;
|
screenverts[0].y = 0.0f;
|
||||||
screenverts[0].c = -1;
|
screenverts[0].c = -1;
|
||||||
screenverts[0].u = 1f / texturesize.Width;
|
screenverts[0].u = 0.0f;
|
||||||
screenverts[0].v = 1f / texturesize.Height;
|
screenverts[0].v = 0.0f;
|
||||||
screenverts[1].x = texturesize.Width - 1.5f;
|
screenverts[1].x = texturesize.Width;
|
||||||
screenverts[1].y = 0.5f;
|
screenverts[1].y = 0.0f;
|
||||||
screenverts[1].c = -1;
|
screenverts[1].c = -1;
|
||||||
screenverts[1].u = 1f - 1f / texturesize.Width;
|
screenverts[1].u = 1.0f;
|
||||||
screenverts[1].v = 1f / texturesize.Height;
|
screenverts[1].v = 0.0f;
|
||||||
screenverts[2].x = 0.5f;
|
screenverts[2].x = 0.0f;
|
||||||
screenverts[2].y = texturesize.Height - 1.5f;
|
screenverts[2].y = texturesize.Height;
|
||||||
screenverts[2].c = -1;
|
screenverts[2].c = -1;
|
||||||
screenverts[2].u = 1f / texturesize.Width;
|
screenverts[2].u = 0.0f;
|
||||||
screenverts[2].v = 1f - 1f / texturesize.Height;
|
screenverts[2].v = 1.0f;
|
||||||
screenverts[3].x = texturesize.Width - 1.5f;
|
screenverts[3].x = texturesize.Width;
|
||||||
screenverts[3].y = texturesize.Height - 1.5f;
|
screenverts[3].y = texturesize.Height;
|
||||||
screenverts[3].c = -1;
|
screenverts[3].c = -1;
|
||||||
screenverts[3].u = 1f - 1f / texturesize.Width;
|
screenverts[3].u = 1.0f;
|
||||||
screenverts[3].v = 1f - 1f / texturesize.Height;
|
screenverts[3].v = 1.0f;
|
||||||
return screenverts;
|
return screenverts;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -447,9 +447,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
if(vertexsize < 0) vertexsize = 0;
|
if(vertexsize < 0) vertexsize = 0;
|
||||||
if(vertexsize > 4) vertexsize = 4;
|
if(vertexsize > 4) vertexsize = 4;
|
||||||
|
|
||||||
Matrix scaling = Matrix.Scaling((1f / windowsize.Width) * 2f, (1f / windowsize.Height) * -2f, 1f);
|
viewmatrix = Matrix.Scaling(2.0f / windowsize.Width, -2.0f / windowsize.Height, 1.0f) * Matrix.Translation(-1.0f, 1.0f, 0.0f);
|
||||||
Matrix translate = Matrix.Translation(-(float)windowsize.Width * 0.5f, -(float)windowsize.Height * 0.5f, 0f);
|
|
||||||
viewmatrix = translate * scaling;
|
|
||||||
Vector2D lt = DisplayToMap(new Vector2D(0.0f, 0.0f));
|
Vector2D lt = DisplayToMap(new Vector2D(0.0f, 0.0f));
|
||||||
Vector2D rb = DisplayToMap(new Vector2D(windowsize.Width, windowsize.Height));
|
Vector2D rb = DisplayToMap(new Vector2D(windowsize.Width, windowsize.Height));
|
||||||
viewport = new RectangleF(lt.x, lt.y, rb.x - lt.x, rb.y - lt.y);
|
viewport = new RectangleF(lt.x, lt.y, rb.x - lt.x, rb.y - lt.y);
|
||||||
|
@ -1537,6 +1535,10 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
if(renderlayer != RenderLayers.None) return; //mxd
|
if(renderlayer != RenderLayers.None) return; //mxd
|
||||||
renderlayer = RenderLayers.Surface;
|
renderlayer = RenderLayers.Surface;
|
||||||
|
|
||||||
|
// Recreate render targets if the window was resized
|
||||||
|
if (windowsize.Width != graphics.RenderTarget.ClientSize.Width || windowsize.Height != graphics.RenderTarget.ClientSize.Height)
|
||||||
|
CreateRendertargets();
|
||||||
|
|
||||||
// Rendertargets available?
|
// Rendertargets available?
|
||||||
if(surfacetex != null)
|
if(surfacetex != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -118,14 +118,14 @@ int OpenGLContext::GetWidth() const
|
||||||
{
|
{
|
||||||
RECT box = { 0 };
|
RECT box = { 0 };
|
||||||
GetClientRect(window, &box);
|
GetClientRect(window, &box);
|
||||||
return box.right;
|
return box.right - box.left;
|
||||||
}
|
}
|
||||||
|
|
||||||
int OpenGLContext::GetHeight() const
|
int OpenGLContext::GetHeight() const
|
||||||
{
|
{
|
||||||
RECT box = { 0 };
|
RECT box = { 0 };
|
||||||
GetClientRect(window, &box);
|
GetClientRect(window, &box);
|
||||||
return box.bottom;
|
return box.bottom - box.top;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -27,13 +27,12 @@ const char* plotter_ps = R"(
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
// line stipple
|
// line stipple
|
||||||
int visible = int(UV.x) & 1;
|
if (mod(UV.x, 2.0) > 1.0)
|
||||||
if (visible == 1)
|
|
||||||
discard;
|
discard;
|
||||||
|
|
||||||
// line smoothing
|
// line smoothing
|
||||||
float linewidth = 2.0;
|
float linewidth = 3.0;
|
||||||
float falloff = 1.5; //1.5..2.5
|
float falloff = 1.8; //1.5..2.5
|
||||||
float centerdist = abs(UV.y);
|
float centerdist = abs(UV.y);
|
||||||
float a = pow(clamp((linewidth - centerdist) / linewidth, 0.0, 1.0), falloff);
|
float a = pow(clamp((linewidth - centerdist) / linewidth, 0.0, 1.0), falloff);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue