Skip to content

Commit

Permalink
GL|libgui|Client: Draw lines as triangle strips with custom width
Browse files Browse the repository at this point in the history
The DGL shader now supports lines with any width. The automap and
crosshairs may use line widths outside the supported range of
GL_LINES, so this allows drawing with any arbitrary line width.

Setting GL line width via GLInfo was removed.
  • Loading branch information
skyjake committed Sep 22, 2018
1 parent 30ffe7a commit 3e00128
Show file tree
Hide file tree
Showing 8 changed files with 227 additions and 58 deletions.
10 changes: 5 additions & 5 deletions doomsday/apps/api/api_gl.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ enum {

// Types.
typedef unsigned char DGLubyte;
typedef int DGLint;
typedef unsigned int DGLuint;
typedef int DGLsizei;
typedef double DGLdouble;
typedef unsigned int DGLenum;
typedef int DGLint;
typedef unsigned int DGLuint;
typedef int DGLsizei;
typedef double DGLdouble;
typedef unsigned int DGLenum;

/// Texture formats.
typedef enum dgltexformat_e {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@
DENG_LAYOUT_LOC(0) DENG_ATTRIB vec4 aVertex;
DENG_LAYOUT_LOC(1) DENG_ATTRIB vec4 aColor;
DENG_LAYOUT_LOC(2) DENG_ATTRIB vec2 aTexCoord[2];
DENG_LAYOUT_LOC(4) DENG_ATTRIB vec2 aFragOffset;

uniform vec2 uFragmentSize; // used for line width
uniform mat4 uMvpMatrix;
uniform mat4 uTexMatrix0;
uniform mat4 uTexMatrix1;

DENG_VAR vec4 vColor;
DENG_VAR vec2 vTexCoord[2];

vec2 transformTexCoord(const mat4 matrix, const vec2 tc)
vec2 transformTexCoord(const mat4 matrix, const vec2 tc)
{
vec4 coord = vec4(tc.s, tc.t, 0.0, 1.0);
return (matrix * coord).xy;
Expand All @@ -38,7 +40,14 @@ vec2 transformTexCoord(const mat4 matrix, const vec2 tc)
void main()
{
gl_Position = uMvpMatrix * aVertex;
vColor = aColor;

if (uFragmentSize != vec2(0.0))
{
gl_Position.xy += normalize(mat2(uMvpMatrix) * aFragOffset) *
uFragmentSize * gl_Position.w;
}

vColor = aColor;
vTexCoord[0] = transformTexCoord(uTexMatrix0, aTexCoord[0]);
vTexCoord[1] = transformTexCoord(uTexMatrix1, aTexCoord[1]);
}
2 changes: 1 addition & 1 deletion doomsday/apps/client/src/gl/dgl_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ dd_bool DGL_SetFloat(int name, float value)
{
case DGL_LINE_WIDTH:
GL_state.currentLineWidth = value;
GLInfo::setLineWidth(value);
// GLInfo::setLineWidth(value);
break;

case DGL_POINT_SIZE:
Expand Down
Loading

0 comments on commit 3e00128

Please sign in to comment.