STLL  0.0
Simple Text Layouting Library
STLL::showOpenGL< V, G > Class Template Reference

a class to output layouts using OpenGL More...

Inheritance diagram for STLL::showOpenGL< V, G >:

Classes

class  imageDrawer_c
 helper class used to draw images More...
 

Public Types

using DrawCache_c = typename internal::openGL_internals< V >::DrawCacheInternal_c
 type to keep the caching information for redrawing layouts extra fast. You dont't need to know anything about its internals, just git a pointer to an object of this class to the show function for extra speedup. More...
 

Public Member Functions

 showOpenGL (uint32_t cStart=256, uint32_t cMax=1024)
 constructor More...
 
 ~showOpenGL (void)
 
void showLayout (const TextLayout_c &l, int sx, int sy, SubPixelArrangement sp, imageDrawer_c *images=nullptr, DrawCache_c *dc=nullptr)
 paint the layout More...
 
void setupMatrixes (int width, int height)
 helper function to setup the projection matrices for the showLayout function. It will change the viewport and the modelview and projection matrix to an orthogonal projection More...
 
const uint8_t * getData (void) const
 get a pointer to the texture atlas with all the glyphs More...
 
uint32_t cacheWidth (void) const
 
uint32_t cacheHeight (void) const
 
void setGamma (uint8_t gamma=22)
 update the gamma value used for output More...
 
void clear (void)
 clear the glyph cache. This might be useful when you change the fonts that you use for output, or any other reason that will make the cache content useless More...
 

Detailed Description

template<int V, class G = internal::Gamma_c<>>
class STLL::showOpenGL< V, G >

a class to output layouts using OpenGL

To output layouts using this class, create an object of it and then use the showLayout Function to output the layout.

The class contains a glyph cache in form of an texture atlas. Once this atlas if full, things available will be output and then the atlas will be cleared and repopulated for the next section of the output. This will slow down output considerably, so choose the size wisely. The atlas will be destroyed once the class is destroyed. Things to consider:

  • using sub pixel placement triples the space requirements for the glyphs
  • blurring adds quite some amount of space around the glyphs, but as soon as you blurr the sub pixel placement will not be used as you will not see the difference anyways
  • normal rectangles will not go into the cache, but blurres ones will
  • so in short avoid blurring

As OpenGL required function loaders and does not provide a header with all available functionality you will need to include the proper OpenGL before including the header file for this class.

You need to activate the sRGB framebuffer for the framebuffer that this class paints on

For more details look at example 2 Using the XHTML Layouter and the OpenGL output and at the drawing page: OpenGL drawing

Template Parameters
VMajor version of OpenGL to use, supported are 1, 2 and 3, use 3 as well for OpenGL 4
Gthe gamma calculation function, if you use sRGB output... normally you don't need to change this, keep the default

Member Typedef Documentation

template<int V, class G = internal::Gamma_c<>>
using STLL::showOpenGL< V, G >::DrawCache_c = typename internal::openGL_internals<V>::DrawCacheInternal_c

type to keep the caching information for redrawing layouts extra fast. You dont't need to know anything about its internals, just git a pointer to an object of this class to the show function for extra speedup.

Constructor & Destructor Documentation

template<int V, class G = internal::Gamma_c<>>
STLL::showOpenGL< V, G >::showOpenGL ( uint32_t  cStart = 256,
uint32_t  cMax = 1024 
)
inline

constructor

Parameters
cStartinitial size of the texture cache for the glyphs, the cache will be a square image with the dimensions of cStart
cMaxonce the cache is full its dimensions will be doubled, quadrupling the area until it has reached at least this value (it may get bigger, depending on what values you get by doubling cStart again and again
template<int V, class G = internal::Gamma_c<>>
STLL::showOpenGL< V, G >::~showOpenGL ( void  )
inline

Member Function Documentation

template<int V, class G = internal::Gamma_c<>>
uint32_t STLL::showOpenGL< V, G >::cacheHeight ( void  ) const
inline
template<int V, class G = internal::Gamma_c<>>
uint32_t STLL::showOpenGL< V, G >::cacheWidth ( void  ) const
inline
template<int V, class G = internal::Gamma_c<>>
void STLL::showOpenGL< V, G >::clear ( void  )
inline

clear the glyph cache. This might be useful when you change the fonts that you use for output, or any other reason that will make the cache content useless

template<int V, class G = internal::Gamma_c<>>
const uint8_t* STLL::showOpenGL< V, G >::getData ( void  ) const
inline

get a pointer to the texture atlas with all the glyphs

This is mainly helpful to check how full the texture atlas is

template<int V, class G = internal::Gamma_c<>>
void STLL::showOpenGL< V, G >::setGamma ( uint8_t  gamma = 22)
inline

update the gamma value used for output

Default value for the class is 22, which is good for sRGB output, which should be your default for high quality output. See Gamma for details.

Parameters
gammathe new gamma value in 1/10th units. Use 22 for sRGB and 10 for normal linear
template<int V, class G = internal::Gamma_c<>>
void STLL::showOpenGL< V, G >::setupMatrixes ( int  width,
int  height 
)
inline

helper function to setup the projection matrices for the showLayout function. It will change the viewport and the modelview and projection matrix to an orthogonal projection

template<int V, class G = internal::Gamma_c<>>
void STLL::showOpenGL< V, G >::showLayout ( const TextLayout_c l,
int  sx,
int  sy,
SubPixelArrangement  sp,
imageDrawer_c images = nullptr,
DrawCache_c dc = nullptr 
)
inline

paint the layout

Parameters
lthe layout to draw
sxx position on the target surface in 1/64th pixels
syy position on the target surface in 1/64th pixels
spwhich kind of sub-pixel positioning do you want?
imagesa pointer to an image drawer class that is used to draw the images, when you give a nullptr here, no images will be drawn
dcpointer to a cache object that will speed up drawing by reusing OpenGL buffers when nullptr is given here, no caching will be don. If you know you will ouput something many times, give the pointer. You will not loose much speed on the creation of this cache, except for OpenGL 1, so you can simply always specify this and forget about it later on.

The documentation for this class was generated from the following file: