MeVisLab Resolution Independence API
Loading...
Searching...
No Matches
MeVisLab Resolution Independence API

High-resolution displays provide a rich visual experience by showing sharper text and more image details than standard-resolution displays. MeVisLab supports OpenGL rendering on high-resolution displays without reducing readability through small fonts, narrow margins, or thin lines.

OpenGL

OpenGL visualization modules do not support resolution independence out of the box, so they must be adapted. MeVisLab extends the OpenGL render state with a pixel scale factor that simplifies this task. Replace the standard OpenGL calls glLineWidth, glPointSize, and glLineStipple with their new counterparts ml::glLineWidthScaled, ml::glPointSizeScaled, and ml::glLineStippleScaled. Fonts are adapted automatically. For margins and spacing, use the template GLHiDPIScale. The following code snippet outlines some of the adaptations:

#include <SoViewerElement.h> // header file is part of MLInventorBinding
#include <mlGLHiDPI.h> // header file is part of MLOpenGL
...
void SoMyNode::initClass()
{
...
// Enable the SoViewerElement for the SoGLRenderAction action
SO_ENABLE(SoGLRenderAction, SoViewerElement);
}
void SoMyNode::GLRender(SoGLRenderAction *action)
{
...
// Returns the ratio between physical pixels and device-independent
// pixels for the connected viewer
double devicePixelRatio = SoViewerElement::getDevicePixelRatio(action->getState());
...
// Set width for line drawing
// Set diameter of rasterized points
// Set line stipple pattern
...
// Automatically adapt a constant or variable value by multiplying
// the value with the ratio between physical pixels and device-independent
// pixels
double margin = GLHiDPIScale(5.0);
}
Element that stores a proxy object to the currently active viewer.
T GLHiDPIScale(T x)
Definition mlGLHiDPI.h:67
void glLineWidthScaled(GLfloat width)
Sets the width of rasterized lines.
void glLineStippleScaled(GLint factor, GLushort pattern)
Sets the line stipple pattern.
static double getDevicePixelRatio(SoState *state)
void glPointSizeScaled(GLfloat size)
Sets the diameter of rasterized points.

OpenGL Shading Language (GLSL)

Using the SoShader framework, the following uniform can be accessed within the shader code:

uniform float oiv_DevicePixelRatio;

Modules