Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@
https://glvis.org


Version 4.5.1 (development)
===========================
- Added configurable line width for mesh edges and element boundaries when MSAA
is enabled. Line width can be adjusted at runtime using ';' (decrease) and '''
(increase) keys in 0.25 pixel increments (minimum 0.25, no maximum). Default
line width now is 1.5 pixels.

- Without antialiasing, the original GL_LINES rendering is still used. With
antialiasing, lines are rendered using shader-expanded triangles and hardware
MSAA with fragment shader techniques. The line rendering format switches
automatically when toggling MSAA with the 'A' key.


Version 4.5 released on Feb 6, 2026
===================================

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ Key commands
- <kbd>*</kbd> / <kbd>/</kbd> – Zoom in/out
- <kbd>+</kbd> / <kbd>-</kbd> – Stretch/compress in `z`-direction
- <kbd>[</kbd> / <kbd>]</kbd> – Shrink/enlarge the bounding box (relative to the colorbar)
- <kbd>;</kbd> / <kbd>'</kbd> – Decrease/increase line width
- <kbd>(</kbd> / <kbd>)</kbd> – Shrink/enlarge the visualization window
- <kbd>.</kbd> – Start/stop `z`-spinning (speed/direction can be controlled with <kbd>0</kbd> / <kbd>Enter</kbd>)
- <kbd>←</kbd>, <kbd>→</kbd>, <kbd>↑</kbd>, <kbd>↓</kbd> – Manual rotation
Expand Down
22 changes: 22 additions & 0 deletions lib/aux_vis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ GLWindow* InitVisualization(const char name[], int x, int y, int w, int h,

wnd->setOnKeyDown (SDLK_LEFTBRACKET, ScaleDown);
wnd->setOnKeyDown (SDLK_RIGHTBRACKET, ScaleUp);
wnd->setOnKeyDown (SDLK_SEMICOLON, DecreaseLineWidth);
wnd->setOnKeyDown (SDLK_QUOTE, IncreaseLineWidth);
wnd->setOnKeyDown (SDLK_AT, LookAt);

#ifndef __EMSCRIPTEN__
Expand Down Expand Up @@ -1650,6 +1652,26 @@ void ScaleDown()
SendExposeEvent();
}

void IncreaseLineWidth()
{
float new_w = GetLineWidth() + 0.25f;
float new_w_aa = GetLineWidthMS() + 0.25f;
SetLineWidth(new_w);
SetLineWidthMS(new_w_aa);
cout << "Line width: " << new_w << " (antialiased: " << new_w_aa << ")" << endl;
SendExposeEvent();
}

void DecreaseLineWidth()
{
float new_w = std::max(0.25f, GetLineWidth() - 0.25f);
float new_w_aa = std::max(0.25f, GetLineWidthMS() - 0.25f);
SetLineWidth(new_w);
SetLineWidthMS(new_w_aa);
cout << "Line width: " << new_w << " (antialiased: " << new_w_aa << ")" << endl;
SendExposeEvent();
}

void LookAt()
{
cout << "ViewCenter = (" << locscene->ViewCenterX << ','
Expand Down
2 changes: 2 additions & 0 deletions lib/aux_vis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ void ScaleDown();
void LookAt();
void ShrinkWindow();
void EnlargeWindow();
void IncreaseLineWidth();
void DecreaseLineWidth();
void MoveResizeWindow(int x, int y, int w, int h);
void ResizeWindow(int w, int h);
void SetWindowTitle(const char *title);
Expand Down
8 changes: 8 additions & 0 deletions lib/gl/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ void MeshRenderer::setAntialiasing(bool aa_status)
if (msaa_enable != aa_status)
{
msaa_enable = aa_status;
// Update device's MSAA state for conditional line rendering
if (device)
{
device->setMSAAEnabled(aa_status);
}
if (msaa_enable)
{
if (!feat_use_fbo_antialias)
Expand Down Expand Up @@ -398,6 +403,9 @@ void MeshRenderer::buffer(GlDrawable* buf)

void GLDevice::init()
{
// Initialize line width
line_w = 1.0f;
msaa_enabled = false;
// enable depth testing
glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST);
Expand Down
14 changes: 12 additions & 2 deletions lib/gl/renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ class GLDevice

std::array<float, 4> static_color;

float line_w;
bool msaa_enabled;

protected:
resource::TextureHandle passthrough_texture;

Expand Down Expand Up @@ -135,7 +138,9 @@ class GLDevice
void disableBlend() { glDisable(GL_BLEND); }
void enableDepthWrite() { glDepthMask(GL_TRUE); }
void disableDepthWrite() { glDepthMask(GL_FALSE); }
void setLineWidth(float w) { glLineWidth(w); }
void setLineWidth(float w) { line_w = w; glLineWidth(w); }
// Update MSAA state for conditional line rendering
void setMSAAEnabled(bool enabled) { msaa_enabled = enabled; }

virtual void init();
virtual DeviceType getType() = 0;
Expand Down Expand Up @@ -195,6 +200,8 @@ class MeshRenderer
bool msaa_enable;
int msaa_samples;
GLuint color_tex, alpha_tex, font_tex;
// Separate line widths for non-MSAA (line_w) and MSAA (line_w_aa) modes
// Allows different defaults: 1.0 for GL_LINES, 1.5 for shader-expanded
float line_w, line_w_aa;
PaletteState* palette;

Expand All @@ -213,7 +220,8 @@ class MeshRenderer
device.reset(new TDevice());
device->setLineWidth(line_w);
device->init();
msaa_enable = false;
// Synchronize device's MSAA state with renderer's state
device->setMSAAEnabled(msaa_enable);
}

template<typename TDevice>
Expand Down Expand Up @@ -248,8 +256,10 @@ class MeshRenderer
}
int getSamplesMSAA() { return msaa_samples; }

// Line width for non-MSAA mode (GL_LINES)
void setLineWidth(float w);
float getLineWidth() { return line_w; }
// Line width for MSAA mode (shader-expanded triangles)
void setLineWidthMS(float w);
float getLineWidthMS() { return line_w_aa; }

Expand Down
Loading
Loading