1.3.49
 
Loading...
Searching...
No Matches
Visualizer.h File Reference
#include "Context.h"
#include <GLFW/glfw3.h>
#include "glm/glm.hpp"
#include "glm/gtc/matrix_transform.hpp"
#include "glm/gtx/transform.hpp"
#include "GeometryHandler.h"
#include "Visualizer.h"

Go to the source code of this file.

Data Structures

class  Glyph
 Glyph object - 2D matrix shape. More...
 
struct  Shader
 OpenGL Shader data structure. More...
 
struct  Colormap
 RGB color map. More...
 
class  Visualizer
 Class for visualization of simulation results. More...
 

Functions

bool validateTextureFile (const std::string &texture_file, bool pngonly=false)
 Validates the given texture file.
 
void mouseCallback (GLFWwindow *window, int button, int action, int mods)
 Callback function for mouse button presses.
 
void cursorCallback (GLFWwindow *window, double x, double y)
 Callback function for mouse cursor movements.
 
void scrollCallback (GLFWwindow *window, double xoffset, double yoffset)
 Callback function for mouse scroll.
 
int read_JPEG_file (const char *filename, std::vector< unsigned char > &texture, uint &height, uint &width)
 Reads a JPEG file and extracts its pixel data.
 
int write_JPEG_file (const char *filename, uint width, uint height, bool print_messages)
 Writes an image to a JPEG file.
 
int write_JPEG_file (const char *filename, uint width, uint height, const std::vector< helios::RGBcolor > &data, bool print_messages)
 Writes image data to a JPEG file.
 
void read_png_file (const char *filename, std::vector< unsigned char > &texture, uint &height, uint &width)
 Reads a PNG file and extracts its pixel data.
 
glm::vec3 glm_vec3 (const helios::vec3 &v)
 
int checkerrors ()
 
void check_opengl_errors_safe (const std::string &context)
 Safe error checking that throws exceptions instead of using assert.
 

Detailed Description

Visualizer header.

Copyright (C) 2016-2025 Brian Bailey

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Definition in file Visualizer.h.

Macro Definition Documentation

◆ APIENTRY

#define APIENTRY

Definition at line 24 of file Visualizer.h.

◆ GLM_FORCE_RADIANS

#define GLM_FORCE_RADIANS

Definition at line 22 of file Visualizer.h.

Function Documentation

◆ check_opengl_errors_safe()

void check_opengl_errors_safe ( const std::string &  context)

Safe error checking that throws exceptions instead of using assert.

Definition at line 1839 of file VisualizerRendering.cpp.

◆ checkerrors()

int checkerrors ( )

Definition at line 1824 of file VisualizerRendering.cpp.

◆ cursorCallback()

void cursorCallback ( GLFWwindow *  window,
double  x,
double  y 
)

Callback function for mouse cursor movements.

Definition at line 1489 of file VisualizerRendering.cpp.

◆ glm_vec3()

glm::vec3 glm_vec3 ( const helios::vec3 v)
inline

Definition at line 1465 of file Visualizer.h.

◆ mouseCallback()

void mouseCallback ( GLFWwindow *  window,
int  button,
int  action,
int  mods 
)

Callback function for mouse button presses.

Definition at line 1463 of file VisualizerRendering.cpp.

◆ read_JPEG_file()

int read_JPEG_file ( const char *  filename,
std::vector< unsigned char > &  texture,
uint height,
uint width 
)

Reads a JPEG file and extracts its pixel data.

This function reads a JPEG file from the specified path, decodes it into RGB pixel data, and populates the provided texture vector with RGBA (Red, Green, Blue, Alpha) values. Each pixel in the texture is represented as four unsigned bytes, with the alpha channel always set to 255 (opaque). The function also outputs the height and width of the image.

Parameters
[in]filenameThe path to the JPEG file to read.
[out]textureVector that will be populated with the decoded RGBA pixel data.
[out]heightReference to store the height of the read image.
[out]widthReference to store the width of the read image.
Returns
Always returns 0 upon completion.

Definition at line 30 of file VisualizerCore.cpp.

◆ read_png_file()

void read_png_file ( const char *  filename,
std::vector< unsigned char > &  texture,
uint height,
uint width 
)

Reads a PNG file and extracts its pixel data.

This function loads a PNG file and processes its pixel data into a texture format. It also retrieves the dimensions of the image.

Parameters
[in]filenamePath to the PNG file to be read.
[out]textureVector to store the extracted RGBA pixel data as unsigned char values.
[out]heightVariable to store the height (in pixels) of the loaded image.
[out]widthVariable to store the width (in pixels) of the loaded image.

Definition at line 85 of file VisualizerCore.cpp.

◆ scrollCallback()

void scrollCallback ( GLFWwindow *  window,
double  xoffset,
double  yoffset 
)

Callback function for mouse scroll.

Definition at line 1504 of file VisualizerRendering.cpp.

◆ validateTextureFile()

bool validateTextureFile ( const std::string &  texture_file,
bool  pngonly = false 
)

Validates the given texture file.

This function checks whether the provided texture file can be used for loading a texture. If the pngonly flag is set to true, the function specifically validates for PNG file formats.

Parameters
[in]texture_fileThe path to the texture file to validate.
[in]pngonly[optional] If true, only validates the file for PNG format. Defaults to false.
Returns
True if the texture file is valid, false otherwise.

Definition at line 997 of file VisualizerCore.cpp.

◆ write_JPEG_file() [1/2]

int write_JPEG_file ( const char *  filename,
uint  width,
uint  height,
bool  print_messages 
)

Writes an image to a JPEG file.

This function captures the current framebuffer content, converts it into a JPEG-compatible data structure, and writes it to the specified file.

Parameters
[in]filenameThe path to the output JPEG file.
[in]widthThe width of the image to be written.
[in]heightThe height of the image to be written.
[in]print_messages[optional] If true, outputs status messages to the console. Defaults to false.
Returns
An integer indicating success (1) or failure (0) of the writing operation.

Definition at line 47 of file VisualizerCore.cpp.

◆ write_JPEG_file() [2/2]

int write_JPEG_file ( const char *  filename,
uint  width,
uint  height,
const std::vector< helios::RGBcolor > &  data,
bool  print_messages 
)

Writes image data to a JPEG file.

This function saves the given image data as a JPEG file to the specified filename, with the provided width and height. Optionally, it can print status messages to the console during the process.

Parameters
[in]filenameThe name of the file where the image will be saved.
[in]widthThe width of the image in pixels.
[in]heightThe height of the image in pixels.
[in]dataA vector containing the RGB color data for the image.
[in]print_messages[optional] Whether to print status messages to the console. Defaults to false.
Returns
Returns 1 if the file was successfully written.