- process lines through the 2D drawer.

This commit is contained in:
Christoph Oelckers 2019-12-31 19:02:55 +01:00
parent 2f8d472d7d
commit 1890df98f9
9 changed files with 36 additions and 177 deletions

View file

@ -681,7 +681,6 @@ set (PCH_SOURCES
#thirdparty/imgui/imgui_widgets.cpp
# Todo: Split out the license-safe code from this.
build/src/2d.cpp
build/src/a-c.cpp
build/src/animvpx.cpp
build/src/baselayer.cpp

View file

@ -52,7 +52,6 @@ typedef struct {
extern palette_t curpalette[256], curpalettefaded[256], palfadergb;
extern char palfadedelta;
extern void videoFadeToBlack(int32_t moreopaquep);
void paletteMakeLookupTable(int32_t palnum, const char *remapbuf, uint8_t r, uint8_t g, uint8_t b, char noFloorPal);
void paletteSetColorTable(int32_t id, uint8_t const *table, bool transient = false);
void paletteFreeColorTable(int32_t id);

View file

@ -1,107 +0,0 @@
// "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman
// Ken Silverman's official web site: "http://www.advsys.net/ken"
// See the included license file "BUILDLIC.TXT" for license info.
//
// This file has been modified from Ken Silverman's original release
// by Jonathon Fowler (jf@jonof.id.au)
// by the EDuke32 team (development@voidpoint.com)
#include "build.h"
#include "compat.h"
#include "baselayer.h"
#include "matrix.h"
#include "../../glbackend/glbackend.h"
//
// drawline256
//
#ifdef USE_OPENGL
static void drawlinegl(int32_t x1, int32_t y1, int32_t x2, int32_t y2, palette_t p)
{
// setpolymost2dview(); // JBF 20040205: more efficient setup
int const dx = x2-x1;
int const dy = y2-y1;
if (dx >= 0)
{
if ((x1 >= wx2) || (x2 < wx1)) return;
if (x1 < wx1) y1 += scale(wx1-x1, dy, dx), x1 = wx1;
if (x2 > wx2) y2 += scale(wx2-x2, dy, dx), x2 = wx2;
}
else
{
if ((x2 >= wx2) || (x1 < wx1)) return;
if (x2 < wx1) y2 += scale(wx1-x2, dy, dx), x2 = wx1;
if (x1 > wx2) y1 += scale(wx2-x1, dy, dx), x1 = wx2;
}
if (dy >= 0)
{
if ((y1 >= wy2) || (y2 < wy1)) return;
if (y1 < wy1) x1 += scale(wy1-y1, dx, dy), y1 = wy1;
if (y2 > wy2) x2 += scale(wy2-y2, dx, dy), y2 = wy2;
}
else
{
if ((y2 >= wy2) || (y1 < wy1)) return;
if (y2 < wy1) x2 += scale(wy1-y2, dx, dy), y2 = wy1;
if (y1 > wy2) x1 += scale(wy2-y1, dx, dy), y1 = wy2;
}
GLInterface.SetViewport(0, 0, xdim, ydim);
VSMatrix proj(0);
proj.ortho(0, xdim, ydim, 0, -1, 1);
GLInterface.SetMatrix(Matrix_Projection, &proj);
gloy1 = -1;
GLInterface.EnableAlphaTest(false);
GLInterface.EnableDepthTest(false);
GLInterface.EnableBlend(true); // When using line antialiasing, this is needed
GLInterface.UseColorOnly(true);
GLInterface.SetColorub(p.r, p.g, p.b, 255);
auto data = GLInterface.AllocVertices(2);
data.second[0].Set((float) x1 * (1.f/4096.f), (float) y1 * (1.f/4096.f));
data.second[1].Set((float) x2 * (1.f/4096.f), (float) y2 * (1.f/4096.f));
GLInterface.Draw(DT_LINES, data.first, 2);
GLInterface.UseColorOnly(false);
}
#endif
void drawlinergb(int32_t x1, int32_t y1, int32_t x2, int32_t y2, palette_t p)
{
#ifdef USE_OPENGL
if (videoGetRenderMode() >= REND_POLYMOST)
{
drawlinegl(x1, y1, x2, y2, p);
return;
}
#endif
//char const col = palookup[0][p.f];
//drawlinepixels(x1, y1, x2, y2, col);
}
void renderDrawLine(int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint8_t col)
{
col = palookup[0][col];
#ifdef USE_OPENGL
if (videoGetRenderMode() >= REND_POLYMOST)
{
palette_t p = paletteGetColor(col);
p.f = col;
drawlinegl(x1, y1, x2, y2, p);
return;
}
#endif
//drawlinepixels(x1, y1, x2, y2, col);
}

View file

@ -10495,10 +10495,10 @@ void videoSetCorrectedAspect()
//
void videoSetViewableArea(int32_t x1, int32_t y1, int32_t x2, int32_t y2)
{
windowxy1.x = x1; wx1 = (x1<<12);
windowxy1.y = y1; wy1 = (y1<<12);
windowxy2.x = x2; wx2 = ((x2+1)<<12);
windowxy2.y = y2; wy2 = ((y2+1)<<12);
windowxy1.x = x1;
windowxy1.y = y1;
windowxy2.x = x2;
windowxy2.y = y2;
xdimen = (x2-x1)+1; halfxdimen = (xdimen>>1);
xdimenrecip = divscale32(1L,xdimen);

View file

@ -63,67 +63,14 @@ int DetermineTranslucency(const uint8_t *table)
if (newcolor2.r == 255) // if black on white results in white it's either
// fully transparent or additive
{
/*
if (developer >= DMSG_NOTIFY)
{
char lumpname[9];
lumpname[8] = 0;
Wads.GetLumpName(lumpname, lumpnum);
Printf("%s appears to be additive translucency %d (%d%%)\n", lumpname, newcolor.r,
newcolor.r * 100 / 255);
}
*/
return -newcolor.r;
}
/*
if (developer >= DMSG_NOTIFY)
{
char lumpname[9];
lumpname[8] = 0;
Wads.GetLumpName(lumpname, lumpnum);
Printf("%s appears to be translucency %d (%d%%)\n", lumpname, newcolor.r,
newcolor.r * 100 / 255);
}
*/
return newcolor.r;
}
void fullscreen_tint_gl(PalEntry pe);
void videoFadeToBlack(int32_t moreopaquep)
{
#ifdef USE_OPENGL
if (videoGetRenderMode() >= REND_POLYMOST)
fullscreen_tint_gl(moreopaquep? PalEntry(168, 0, 0, 0) : PalEntry(84, 0, 0, 0));
else
#endif
{
Bassert(!offscreenrendering);
videoBeginDrawing();
char *const p = (char *) frameplace;
const char *const trans = paletteGetBlendTable(0);
const int32_t shiftamnt = ((!!moreopaquep)*8);
const int32_t dimprod = xdim*ydim;
int32_t i = 0;
#ifdef CLASSIC_SLICE_BY_4
for (; i<dimprod-4; i+=4)
{
p[i] = trans[p[i]<<shiftamnt];
p[i+1] = trans[p[i+1]<<shiftamnt];
p[i+2] = trans[p[i+2]<<shiftamnt];
p[i+3] = trans[p[i+3]<<shiftamnt];
}
#endif
for (; i<dimprod; i++)
p[i] = trans[p[i]<<shiftamnt];
videoEndDrawing();
}
}
void setup_blend(int32_t blend, int32_t doreverse)
{
if (blendtable[blend] == NULL)
@ -846,9 +793,6 @@ static void paletteSetFade(uint8_t offset)
}
}
//#define DEBUG_PALETTEFADE
//
// setpalettefade
//

View file

@ -1,4 +1,4 @@
//
// scissi
//---------------------------------------------------------------------------
//
// Copyright(C) 2016-2018 Christoph Oelckers
@ -36,7 +36,7 @@
//#include "doomtype.h"
#include "templates.h"
//#include "r_utility.h"
//#include "v_video.h"
#include "v_video.h"
//#include "g_levellocals.h"
//#include "vm.h"
@ -391,13 +391,22 @@ void F2DDrawer::AddColorOnlyQuad(int x1, int y1, int w, int h, PalEntry color, F
//
//==========================================================================
void F2DDrawer::AddLine(int x1, int y1, int x2, int y2, uint32_t color, uint8_t alpha)
void F2DDrawer::AddLine(float x1, float y1, float x2, float y2, int clipx1, int clipy1, int clipx2, int clipy2, uint32_t color, uint8_t alpha)
{
PalEntry p = (PalEntry)color;
p.a = alpha;
RenderCommand dg;
if (clipx1 > 0 || clipy1 > 0 || clipx2 < screen->GetWidth()- 1 || clipy2 < screen->GetHeight() - 1)
{
dg.mScissor[0] = clipx1;
dg.mScissor[1] = clipy1;
dg.mScissor[2] = clipx2 + 1;
dg.mScissor[3] = clipy2 + 1;
dg.mFlags |= DTF_Scissor;
}
dg.mType = DrawTypeLines;
dg.mRenderStyle = LegacyRenderStyles[STYLE_Translucent];
dg.mVertCount = 2;
@ -619,7 +628,7 @@ void F2DDrawer::rotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
int method = 0;
dg.mType = DrawTypeRotateSprite;
if (clipx1 > 0 || clipy1 > 0 || clipx2 < xdim - 1 || clipy2 < ydim - 1)
if (clipx1 > 0 || clipy1 > 0 || clipx2 < screen->GetWidth() - 1 || clipy2 < screen->GetHeight() - 1)
{
dg.mScissor[0] = clipx1;
dg.mScissor[1] = clipy1;
@ -714,7 +723,7 @@ void F2DDrawer::AddPoly(FTexture* img, FVector4* vt, size_t vtcount, unsigned in
dg.mType = DrawTypeRotateSprite;
#if 0
if (clipx1 > 0 || clipy1 > 0 || clipx2 < xdim - 1 || clipy2 < ydim - 1)
if (clipx1 > 0 || clipy1 > 0 || clipx2 < screen->GetWidth() - 1 || clipy2 < screen->GetHeight() - 1)
{
dg.mScissor[0] = clipx1;
dg.mScissor[1] = clipy1;
@ -816,4 +825,14 @@ void F2DDrawer::FillPolygon(int *rx1, int *ry1, int *xb1, int32_t npoints, int p
}
void drawlinergb(int32_t x1, int32_t y1, int32_t x2, int32_t y2, palette_t p)
{
twod->AddLine(x1 / 4096.f, y1 / 4096.f, x2 / 4096.f, y2 / 4096.f, windowxy1.x, windowxy1.y, windowxy2.x, windowxy2.y, PalEntry(p.r, p.g, p.b));
}
void renderDrawLine(int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint8_t col)
{
drawlinergb(x1, y1, x2, y2, paletteGetColor(palookup[0][col]));
}

View file

@ -134,7 +134,8 @@ public:
void AddColorOnlyQuad(int left, int top, int width, int height, PalEntry color, FRenderStyle *style = nullptr);
void AddLine(int x1, int y1, int x2, int y2, uint32_t color, uint8_t alpha = 255);
void AddLine(float x1, float y1, float x2, float y2, uint32_t color, uint8_t alpha = 255);
void AddLine(float x1, float y1, float x2, float y2, int cx, int cy, int cx2, int cy2, uint32_t color, uint8_t alpha = 255);
void AddThickLine(int x1, int y1, int x2, int y2, double thickness, uint32_t color, uint8_t alpha = 255);
void AddPixel(int x1, int y1, uint32_t color);

View file

@ -259,10 +259,14 @@ void GLInstance::Draw(EDrawType type, size_t start, size_t count)
}
glEnd();
}
else
else if (type != DT_LINES)
{
glDrawElements(primtypes[type], count, GL_UNSIGNED_INT, (void*)(intptr_t)(start * sizeof(uint32_t)));
}
else
{
glDrawArrays(primtypes[type], start, count);
}
if (MatrixChange) RestoreTextureProps();
}

View file

@ -189,7 +189,7 @@ void GLInstance::Draw2D(F2DDrawer *drawer)
break;
case F2DDrawer::DrawTypeLines:
//Draw(DT_LINES, cmd.mVertIndex, cmd.mVertCount);
Draw(DT_LINES, cmd.mVertIndex, cmd.mVertCount);
break;
case F2DDrawer::DrawTypePoints: