2018-11-05 07:28:01 +00:00
|
|
|
// "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)
|
|
|
|
|
2016-06-21 00:33:14 +00:00
|
|
|
#include "build.h"
|
2019-09-09 22:07:11 +00:00
|
|
|
#include "compat.h"
|
|
|
|
#include "baselayer.h"
|
2019-10-04 16:12:03 +00:00
|
|
|
#include "matrix.h"
|
2019-09-16 19:08:42 +00:00
|
|
|
#include "../../glbackend/glbackend.h"
|
2016-06-21 00:33:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// drawline256
|
|
|
|
//
|
2017-06-24 09:20:58 +00:00
|
|
|
#ifdef USE_OPENGL
|
|
|
|
static void drawlinegl(int32_t x1, int32_t y1, int32_t x2, int32_t y2, palette_t p)
|
2016-06-21 00:33:14 +00:00
|
|
|
{
|
2017-06-24 09:20:58 +00:00
|
|
|
// setpolymost2dview(); // JBF 20040205: more efficient setup
|
2016-06-21 00:33:14 +00:00
|
|
|
|
2019-02-18 22:02:42 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-02-21 19:36:47 +00:00
|
|
|
glViewport(0, 0, xdim, ydim);
|
2019-10-04 16:12:03 +00:00
|
|
|
VSMatrix proj(0);
|
|
|
|
proj.ortho(0, xdim, ydim, 0, -1, 1);
|
|
|
|
GLInterface.SetMatrix(Matrix_Projection, &proj);
|
2019-02-21 19:36:47 +00:00
|
|
|
|
|
|
|
gloy1 = -1;
|
2019-10-04 16:12:03 +00:00
|
|
|
GLInterface.EnableAlphaTest(false);
|
|
|
|
GLInterface.EnableDepthTest(false);
|
|
|
|
GLInterface.EnableBlend(true); // When using line antialiasing, this is needed
|
2019-02-21 19:36:47 +00:00
|
|
|
|
|
|
|
polymost_useColorOnly(true);
|
2019-10-04 16:25:18 +00:00
|
|
|
GLInterface.SetColorub(p.r, p.g, p.b, 255);
|
2019-02-21 19:36:47 +00:00
|
|
|
|
2019-09-16 19:08:42 +00:00
|
|
|
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);
|
2016-06-21 00:33:14 +00:00
|
|
|
|
2019-09-16 19:08:42 +00:00
|
|
|
polymost_useColorOnly(false);
|
2017-06-24 09:20:58 +00:00
|
|
|
}
|
2016-06-21 00:33:14 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2017-06-24 09:20:58 +00:00
|
|
|
void drawlinergb(int32_t x1, int32_t y1, int32_t x2, int32_t y2, palette_t p)
|
|
|
|
{
|
|
|
|
#ifdef USE_OPENGL
|
2018-04-12 21:03:12 +00:00
|
|
|
if (videoGetRenderMode() >= REND_POLYMOST)
|
2017-06-24 09:20:58 +00:00
|
|
|
{
|
|
|
|
drawlinegl(x1, y1, x2, y2, p);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-09-20 20:44:42 +00:00
|
|
|
//char const col = palookup[0][p.f];
|
|
|
|
//drawlinepixels(x1, y1, x2, y2, col);
|
2017-06-24 09:20:58 +00:00
|
|
|
}
|
|
|
|
|
2019-10-04 16:12:03 +00:00
|
|
|
void renderDrawLine(int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint8_t col)
|
2017-06-24 09:20:58 +00:00
|
|
|
{
|
|
|
|
col = palookup[0][col];
|
|
|
|
|
|
|
|
#ifdef USE_OPENGL
|
2018-04-12 21:03:12 +00:00
|
|
|
if (videoGetRenderMode() >= REND_POLYMOST)
|
2017-06-24 09:20:58 +00:00
|
|
|
{
|
2018-04-12 21:03:12 +00:00
|
|
|
palette_t p = paletteGetColor(col);
|
2017-06-24 09:20:58 +00:00
|
|
|
p.f = col;
|
|
|
|
drawlinegl(x1, y1, x2, y2, p);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-09-20 20:44:42 +00:00
|
|
|
//drawlinepixels(x1, y1, x2, y2, col);
|
2017-06-24 09:20:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-06-21 00:33:14 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// setpolymost2dview
|
|
|
|
// Sets OpenGL for 2D drawing
|
|
|
|
//
|
2018-04-12 21:03:47 +00:00
|
|
|
void polymostSet2dView(void)
|
2016-06-21 00:33:14 +00:00
|
|
|
{
|
|
|
|
#ifdef USE_OPENGL
|
2018-04-12 21:03:12 +00:00
|
|
|
if (videoGetRenderMode() < REND_POLYMOST) return;
|
2016-06-21 00:33:14 +00:00
|
|
|
|
2018-07-14 21:36:44 +00:00
|
|
|
glViewport(0, 0, xdim, ydim);
|
2016-06-21 00:33:14 +00:00
|
|
|
|
2019-10-04 16:12:03 +00:00
|
|
|
VSMatrix proj(0);
|
|
|
|
proj.ortho(0, xdim, ydim, 0, -1, 1);
|
|
|
|
GLInterface.SetMatrix(Matrix_Projection, &proj);
|
2016-06-21 00:33:14 +00:00
|
|
|
|
|
|
|
gloy1 = -1;
|
|
|
|
|
2019-10-04 16:12:03 +00:00
|
|
|
GLInterface.EnableDepthTest(false);
|
|
|
|
GLInterface.EnableBlend(false);
|
2016-06-21 00:33:14 +00:00
|
|
|
#endif
|
|
|
|
}
|