Skip to content
Merged
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
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
https://glvis.org


Version 4.4.1 (development)
===================================

Unlike previous GLVis releases, this version requires a C++17 compiler.

Version 4.4 released on May 1, 2025
===================================

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# introduced.
cmake_minimum_required(VERSION 3.10)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
Comment on lines +16 to 18
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With mfem/mfem#5163 these three lines can be removed and glvis can just track mfem's C++ version. Should be fine to leave these for now so users can build with the 4.9 release.


Expand Down
1 change: 1 addition & 0 deletions lib/aux_vis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#endif

using namespace mfem;
using namespace std;

thread_local int visualize = 0;
thread_local VisualizationScene * locscene;
Expand Down
31 changes: 17 additions & 14 deletions lib/aux_vis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,37 +131,39 @@ float GetLineWidthMS();

void InitFont();
GlVisFont * GetFont();
bool SetFont(const vector<std::string>& patterns, int height);
bool SetFont(const std::vector<std::string>& patterns, int height);
void SetFont(const std::string& fn);

void SetUseHiDPI(bool status);
function<string(double)> NumberFormatter(int precision=4, char format='d',
bool showsign=false);
function<string(double)> NumberFormatter(string formatting);
bool isValidNumberFormatting(const string& formatting);

std::function<std::string(double)> NumberFormatter(int precision=4,
char format='d', bool showsign=false);
std::function<std::string(double)> NumberFormatter(std::string formatting);
bool isValidNumberFormatting(const std::string& formatting);

// This is a helper function for prompting the user for inputs. The benefit
// over using just `cin >> input` is that you can specify a type and optionally
// a validator lambda. The a validator if not specified, it defaults to the
// True function. If the input cannot be type casted to the expected type, or
// if it fails the validation, the user is asked again for a new input.
template <typename T>
T prompt(const string question,
T prompt(const std::string question,
const T* default_value = nullptr,
function<bool(T)> validator = [](T) { return true; })
std::function<bool(T)> validator = [](T) { return true; })
{
T input;
string strInput;
std::string strInput;

while (true)
{
cout << question << " ";
getline(cin, strInput);
stringstream buf(strInput);
std::cout << question << " ";
std::getline(std::cin, strInput);
std::stringstream buf(strInput);

if (strInput.empty() && default_value != nullptr)
{
cout << "Input empty. Using default value: " << *default_value << endl;
std::cout << "Input empty. Using default value: " << *default_value
<< std::endl;
return *default_value;
}

Expand All @@ -173,12 +175,13 @@ function<bool(T)> validator = [](T) { return true; })
}
else
{
cout << "Input is not valid. Please try again." << endl;
std::cout << "Input is not valid. Please try again." << std::endl;
}
}
else
{
cout << "Input can not be casted to expected type. Please try again." << endl;
std::cout << "Input can not be casted to expected type. Please try again."
<< std::endl;
}
}
return input;
Expand Down
3 changes: 3 additions & 0 deletions lib/font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#include "font.hpp"
#include "aux_vis.hpp"

using std::cout;
using std::endl;

struct vert_tex2d
{
float x, y;
Expand Down
12 changes: 5 additions & 7 deletions lib/font.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@

#include "gl/platform_gl.hpp"

using namespace std;

class GlVisFont
{
public:
struct glyph
{
uint32_t w, h;
int32_t bear_x, bear_y;
std::uint32_t w, h;
std::int32_t bear_x, bear_y;
float adv_x, adv_y;
float tex_x;
};
Expand All @@ -42,7 +40,7 @@ class GlVisFont
glyph font_chars[256];
float tex_w;
float tex_h;
uint32_t font_tex;
std::uint32_t font_tex;

FT_Library library;
FT_Face face;
Expand All @@ -53,7 +51,7 @@ class GlVisFont

const glyph &GetTexChar(char c) const
{
return font_chars[(uint8_t) c];
return font_chars[(std::uint8_t) c];
}

/// Get the width and height of the bounding box containing the rendered text
Expand All @@ -66,7 +64,7 @@ class GlVisFont
{
if (FT_Init_FreeType(&library))
{
cout << "GLVis: Can not initialize FreeType library!" << endl;
std::cout << "GLVis: Can not initialize FreeType library!" << std::endl;
}
init = true;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/gl/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void MeshRenderer::render(const RenderQueue& queue)

if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
{
cerr << "Unable to create multisampled renderbuffer." << flush;
std::cerr << "Unable to create multisampled renderbuffer." << std::flush;
glDeleteFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
Expand Down Expand Up @@ -268,7 +268,7 @@ void MeshRenderer::render(const RenderQueue& queue)

if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
{
cerr << "Unable to create resolve renderbuffer." << endl;
std::cerr << "Unable to create resolve renderbuffer." << std::endl;
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}

Expand Down
14 changes: 7 additions & 7 deletions lib/gl/renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ struct RenderParams
bool contains_translucent;
};

typedef vector<pair<RenderParams, GlDrawable*>> RenderQueue;
typedef std::vector<std::pair<RenderParams, GlDrawable*>> RenderQueue;

struct SceneInfo
{
vector<GlDrawable*> needs_buffering;
std::vector<GlDrawable*> needs_buffering;
RenderQueue queue;
};

Expand Down Expand Up @@ -88,9 +88,9 @@ struct FeedbackText

struct CaptureBuffer
{
vector<FeedbackVertex> lines;
vector<FeedbackVertex> triangles;
vector<FeedbackText> text;
std::vector<FeedbackVertex> lines;
std::vector<FeedbackVertex> triangles;
std::vector<FeedbackText> text;
};

// OpenGL device interface representing rendering capabilities
Expand Down Expand Up @@ -195,7 +195,7 @@ class GLDevice

class MeshRenderer
{
unique_ptr<GLDevice> device;
std::unique_ptr<GLDevice> device;
bool msaa_enable;
int msaa_samples;
GLuint color_tex, alpha_tex, font_tex;
Expand Down Expand Up @@ -243,7 +243,7 @@ class MeshRenderer
std::cerr << "GL_MAX_SAMPLES = " << msaa_samples
<< " but requested " << samples << "x MSAA. ";
std::cerr << "Setting antialiasing mode to "
<< msaa_samples << "x MSAA." << endl;
<< msaa_samples << "x MSAA." << std::endl;
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions lib/gl/renderer_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const std::string PRINTING_FS =
namespace gl3
{

using namespace std;

const std::vector<std::string> CoreGLDevice::unif_list =
{
"useClipPlane",
Expand Down
4 changes: 2 additions & 2 deletions lib/gl/renderer_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ class CoreGLDevice : public GLDevice
void drawDeviceBufferImpl(GLenum shape, int count, bool indexed);

void processTriangleXfbBuffer(CaptureBuffer& cbuf,
const vector<ShaderXfbVertex>& verts);
const std::vector<ShaderXfbVertex>& verts);
void processLineXfbBuffer(CaptureBuffer& cbuf,
const vector<ShaderXfbVertex>& verts);
const std::vector<ShaderXfbVertex>& verts);

public:
CoreGLDevice()
Expand Down
6 changes: 3 additions & 3 deletions lib/gl/renderer_ff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void FFGLDevice::bufferToDevice(array_layout layout, IVertexBuffer& buf)
bufferFFDeviceImpl(static_cast<const VertexBuffer<VertexNormTex>&>(buf));
break;
default:
cerr << "WARNING: Unhandled vertex layout " << layout << endl;
std::cerr << "WARNING: Unhandled vertex layout " << layout << std::endl;
}
}

Expand Down Expand Up @@ -232,7 +232,7 @@ void FFGLDevice::bufferToDevice(array_layout layout, IIndexedBuffer& buf)
bufferFFDeviceImpl(static_cast<const IndexedVertexBuffer<VertexNormTex>&>(buf));
break;
default:
cerr << "WARNING: Unhandled vertex layout " << layout << endl;
std::cerr << "WARNING: Unhandled vertex layout " << layout << std::endl;
}
}

Expand Down Expand Up @@ -370,7 +370,7 @@ void FFGLDevice::captureXfbBuffer(PaletteState& pal, CaptureBuffer& cbuf,
return;
}
// allocate feedback buffer
vector<float> xfb_buf;
std::vector<float> xfb_buf;
xfb_buf.resize(sizebuf);
glFeedbackBuffer(sizebuf, fbType, xfb_buf.data());
// draw with feedback capture
Expand Down
4 changes: 2 additions & 2 deletions lib/gl/shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ bool ShaderProgram::linkShaders(const std::vector<GLuint>& shaders)
glGetProgramiv(program_id, GL_LINK_STATUS, &stat);
if (stat == GL_FALSE)
{
cerr << "fatal: Shader linking failed" << endl;
std::cerr << "fatal: Shader linking failed" << std::endl;
}
return (stat == GL_TRUE);
}
Expand All @@ -283,7 +283,7 @@ void ShaderProgram::mapShaderUniforms()

for (int i = 0; i < num_unifs; i++)
{
vector<char> unif_buf(max_unif_len+1);
std::vector<char> unif_buf(max_unif_len+1);
GLsizei name_length;
GLint gl_size;
GLenum gl_type;
Expand Down
2 changes: 0 additions & 2 deletions lib/gl/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@

#include "platform_gl.hpp"

using namespace std;

class VisualizationScene;

namespace gl3
Expand Down
17 changes: 9 additions & 8 deletions lib/openglvis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "aux_vis.hpp"

using namespace mfem;
using std::cout;

const int NUM_MATERIALS = 5;
extern Material materials[5];
Expand Down Expand Up @@ -479,7 +480,7 @@ VisualizationScene::AddPaletteMaterial(glTF_Builder &bld)
/* wrapT: */ glTF_Builder::wrap_type::CLAMP_TO_EDGE);
// create palette image
const int palette_size = palette.GetNumColors();
vector<array<float,4>> palette_data = palette.GetPalette()->GetData();
std::vector<std::array<float,4>> palette_data = palette.GetPalette()->GetData();
#if 0
glGetTextureImage(
palette.GetColorTexture(), 0,
Expand Down Expand Up @@ -563,7 +564,7 @@ VisualizationScene::AddPaletteLinesMaterial(
}

glTF_Builder::node_id
VisualizationScene::AddModelNode(glTF_Builder &bld, const string &nodeName)
VisualizationScene::AddModelNode(glTF_Builder &bld, const std::string &nodeName)
{
auto new_node = bld.addNode(nodeName);
// Coordinate system switch: (x,y,z) -> (x,z,-y).
Expand All @@ -582,12 +583,12 @@ VisualizationScene::AddModelNode(glTF_Builder &bld, const string &nodeName)

// Used in VisualizationScene::AddTriangles() below.
void minmax(const float *data, size_t components, size_t stride, size_t count,
vector<float> &mins, vector<float> &maxs)
std::vector<float> &mins, std::vector<float> &maxs)
{
if (count == 0)
{
mins.assign(components, +numeric_limits<float>::infinity());
maxs.assign(components, -numeric_limits<float>::infinity());
mins.assign(components, +std::numeric_limits<float>::infinity());
maxs.assign(components, -std::numeric_limits<float>::infinity());
return;
}
mins.resize(components);
Expand Down Expand Up @@ -652,7 +653,7 @@ int VisualizationScene::AddTriangles(glTF_Builder &bld,
}
const gl3::IVertexBuffer *surf_buf = nullptr;
const gl3::IIndexedBuffer *surf_ibuf = nullptr;
const vector<int> *surf_indices = nullptr;
const std::vector<int> *surf_indices = nullptr;
if (num_ibuf)
{
surf_buf = surf_ibuf = gl_drawable.indexed_buffers[ibuf_layout][1].get();
Expand All @@ -667,7 +668,7 @@ int VisualizationScene::AddTriangles(glTF_Builder &bld,
const size_t surf_vertices_stride = surf_buf->getStride(); // in bytes
const float *surf_vertices_data =
reinterpret_cast<const float *>(surf_buf->getData());
vector<float> vmins, vmaxs;
std::vector<float> vmins, vmaxs;
int components = surf_vertices_stride/sizeof(float);
switch (buf_layout)
{
Expand Down Expand Up @@ -882,7 +883,7 @@ int VisualizationScene::AddLines(glTF_Builder &bld,
const size_t lines_vertices_stride = lines_buf->getStride(); // in bytes
const float *lines_vertices_data =
reinterpret_cast<const float *>(lines_buf->getData());
vector<float> vmins, vmaxs;
std::vector<float> vmins, vmaxs;
int components = lines_vertices_stride/sizeof(float);
switch (buf_layout)
{
Expand Down
1 change: 1 addition & 0 deletions lib/palettes_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "palettes_default.cpp"
#include "gl/renderer.hpp"

using namespace std;

void RGBAf::Print(ostream& os) const
{
Expand Down
Loading