mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-26 13:51:40 +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
|
||||
{
|
||||
start = -0.5f;
|
||||
end = len + 0.5f;
|
||||
start = 0.0f;
|
||||
end = len;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
|
|
|
@ -365,7 +365,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.SetBufferData(thingsvertices, THING_BUFFER_SIZE * 12, VertexFormat.Flat);
|
||||
|
||||
// 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);
|
||||
|
||||
// Force update of view
|
||||
|
@ -380,27 +380,27 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
private static FlatVertex[] CreateScreenVerts(Size texturesize)
|
||||
{
|
||||
FlatVertex[] screenverts = new FlatVertex[4];
|
||||
screenverts[0].x = 0.5f;
|
||||
screenverts[0].y = 0.5f;
|
||||
screenverts[0].c = -1;
|
||||
screenverts[0].u = 1f / texturesize.Width;
|
||||
screenverts[0].v = 1f / texturesize.Height;
|
||||
screenverts[1].x = texturesize.Width - 1.5f;
|
||||
screenverts[1].y = 0.5f;
|
||||
screenverts[1].c = -1;
|
||||
screenverts[1].u = 1f - 1f / texturesize.Width;
|
||||
screenverts[1].v = 1f / texturesize.Height;
|
||||
screenverts[2].x = 0.5f;
|
||||
screenverts[2].y = texturesize.Height - 1.5f;
|
||||
screenverts[2].c = -1;
|
||||
screenverts[2].u = 1f / texturesize.Width;
|
||||
screenverts[2].v = 1f - 1f / texturesize.Height;
|
||||
screenverts[3].x = texturesize.Width - 1.5f;
|
||||
screenverts[3].y = texturesize.Height - 1.5f;
|
||||
screenverts[3].c = -1;
|
||||
screenverts[3].u = 1f - 1f / texturesize.Width;
|
||||
screenverts[3].v = 1f - 1f / texturesize.Height;
|
||||
return screenverts;
|
||||
screenverts[0].x = 0.0f;
|
||||
screenverts[0].y = 0.0f;
|
||||
screenverts[0].c = -1;
|
||||
screenverts[0].u = 0.0f;
|
||||
screenverts[0].v = 0.0f;
|
||||
screenverts[1].x = texturesize.Width;
|
||||
screenverts[1].y = 0.0f;
|
||||
screenverts[1].c = -1;
|
||||
screenverts[1].u = 1.0f;
|
||||
screenverts[1].v = 0.0f;
|
||||
screenverts[2].x = 0.0f;
|
||||
screenverts[2].y = texturesize.Height;
|
||||
screenverts[2].c = -1;
|
||||
screenverts[2].u = 0.0f;
|
||||
screenverts[2].v = 1.0f;
|
||||
screenverts[3].x = texturesize.Width;
|
||||
screenverts[3].y = texturesize.Height;
|
||||
screenverts[3].c = -1;
|
||||
screenverts[3].u = 1.0f;
|
||||
screenverts[3].v = 1.0f;
|
||||
return screenverts;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -447,9 +447,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
if(vertexsize < 0) vertexsize = 0;
|
||||
if(vertexsize > 4) vertexsize = 4;
|
||||
|
||||
Matrix scaling = Matrix.Scaling((1f / windowsize.Width) * 2f, (1f / windowsize.Height) * -2f, 1f);
|
||||
Matrix translate = Matrix.Translation(-(float)windowsize.Width * 0.5f, -(float)windowsize.Height * 0.5f, 0f);
|
||||
viewmatrix = translate * scaling;
|
||||
viewmatrix = Matrix.Scaling(2.0f / windowsize.Width, -2.0f / windowsize.Height, 1.0f) * Matrix.Translation(-1.0f, 1.0f, 0.0f);
|
||||
Vector2D lt = DisplayToMap(new Vector2D(0.0f, 0.0f));
|
||||
Vector2D rb = DisplayToMap(new Vector2D(windowsize.Width, windowsize.Height));
|
||||
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
|
||||
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?
|
||||
if(surfacetex != null)
|
||||
{
|
||||
|
|
|
@ -118,14 +118,14 @@ int OpenGLContext::GetWidth() const
|
|||
{
|
||||
RECT box = { 0 };
|
||||
GetClientRect(window, &box);
|
||||
return box.right;
|
||||
return box.right - box.left;
|
||||
}
|
||||
|
||||
int OpenGLContext::GetHeight() const
|
||||
{
|
||||
RECT box = { 0 };
|
||||
GetClientRect(window, &box);
|
||||
return box.bottom;
|
||||
return box.bottom - box.top;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -27,13 +27,12 @@ const char* plotter_ps = R"(
|
|||
void main()
|
||||
{
|
||||
// line stipple
|
||||
int visible = int(UV.x) & 1;
|
||||
if (visible == 1)
|
||||
if (mod(UV.x, 2.0) > 1.0)
|
||||
discard;
|
||||
|
||||
// line smoothing
|
||||
float linewidth = 2.0;
|
||||
float falloff = 1.5; //1.5..2.5
|
||||
float linewidth = 3.0;
|
||||
float falloff = 1.8; //1.5..2.5
|
||||
float centerdist = abs(UV.y);
|
||||
float a = pow(clamp((linewidth - centerdist) / linewidth, 0.0, 1.0), falloff);
|
||||
|
||||
|
|
Loading…
Reference in a new issue