MeVisLab Resolution Independence API
MeVisLab Resolution Independence API

High-resolution displays provide a rich visual experience, allowing users to see sharper text and more details in images than on standard-resolution displays. MeVisLab supports OpenGL rendering on high-resolution displays without scarifying readability due to small fonts, shrunken margins or thin lines.


OpenGL visualization modules do not support resolution independence out-of-the box, they must be adapted to it. MeVisLab extends the OpenGL render state by a pixel scale factor that facilitates this task a great deal. Just replace the standard OpenGL calls glLineWidth, glPointSize, and glLineStipple for their new counterparts ml::glLineWidthScaled, ml::glPointSizeScaled, and ml::glLineStippleScaled. Fonts will be 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)
Convenience template function to scale a value.
Definition: mlGLHiDPI.h:68
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)
Convenience method which calls the corresponding method of SoViewerProxy.
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;