Graphic-Surface-Configuration

A configuration which describes the capabilities of an OpenGL graphic surface.  The configuration is used during construction of a surface.  A surface supports additional configuration attributes which are specified during surface construction.

Summary
Graphic-Surface-ConfigurationA configuration which describes the capabilities of an OpenGL graphic surface.
CopyrightThis program is free software.
Files
C-kern/api/graphic/gconfig.hHeader file Graphic-Surface-Configuration.
C-kern/graphic/gconfig.cImplementation file Graphic-Surface-Configuration impl.
Types
struct gconfig_tExport gconfig_t into global namespace.
gconfig_filter_tDeclares filter to select between different possible configuration.
Enumerations
gconfig_e
gconfig_value_e
Functions
test
unittest_graphic_gconfigTest gconfig_t functionality.
gconfig_filter_tDeclares filter to select between different possible configuration.
Macros
gconfig_filter_INITStatic initializer.
gconfig_tContains a specific surface configuration.
lifetime
gconfig_INITStatic initializer.
gconfig_FREEStatic initializer.
init_gconfigReturns an OpenGL surface configuration for display.
initfiltered_gconfigSame as init_gconfig except that more than one possible configuration is considered.
initfromconfigid_gconfigReturns an OpenGL surface configuration whose ID matches configid.
free_gconfigFrees any memory associated with a configuration.
query
gl_gconfigReturns the native OpenGL surface config.
value_gconfigReturns the value of attribute stored in gconf.
configid_gconfigReturns the configuration ID of gconf.
visualid_gconfigReturns the native visualid of the configuration.
maxpbuffer_gconfigReturns the maximum size of an off-screen pixel buffer.
inline implementation
gconfig_t
free_gconfigImplements gconfig_t.free_gconfig.
configid_gconfigImplements gconfig_t.configid_gconfig.
gl_gconfigImplements gconfig_t.gl_gconfig.
maxpbuffer_gconfigImplements gconfig_t.maxpbuffer_gconfig.
value_gconfigImplements gconfig_t.value_gconfig.
visualid_gconfigImplements gconfig_t.visualid_gconfig.

Copyright

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; either version 2 of the License, or (at your option) any later version.

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.

Author

© 2014 Jörg Seebohn

Files

C-kern/api/graphic/gconfig.h

C-kern/graphic/gconfig.c

Types

struct gconfig_t

typedef struct gconfig_t gconfig_t

Export gconfig_t into global namespace.

gconfig_filter_t

typedef struct gconfig_filter_t gconfig_filter_t

Declares filter to select between different possible configuration.  The filter function must return true if it accepts the visual ID given in parameter visualid else false.  If no visualid passes the filter <initfiltered_eglconfig> returns ESRCH.

Enumerations

gconfig_e

gconfig_NONEThis is the last entry in a list to indicate termination.
gconfig_TYPEThe configuration supports drawing into a specific surface type.  Supported values are any combination of bits ored together from gconfig_value_TYPE_WINDOW_BIT, ...  .
gconfig_TRANSPARENT_ALPHAA value != 0 sets a flag which makes the background of a window surface shine through.  Default value is 0.  The alpha value of a pixel determines its opacity.  Use this to overlay a window surface to another window surface.  This attribute must be supplied during creation of a window to enable alpha transparency.  An alpha value of 1 means the pixel is fully opaque.  An alpha value of 0 means the pixel is fully transparent so the background of a window is visible with 100%.  If the alpha channel has 8 bits then the value 255 corresponds to 1 and the value 128 to 0.5.  Blending function on X11: The blending function assumes that every pixel’s color value is premultiplied by alpha.
Screen-Pixel-RGB = Window-Pixel-RGB + (1Window-Pixel-Alpha) * Background-Pixel-RGB Before drawing you need to change the color of the pixels to: Window-Pixel-RGB = Window-Pixel-RGB * Window-Pixel-Alpha
gconfig_BITS_BUFFERThe minimum number of bits per pixel for all color channels together including alpha.
gconfig_BITS_REDThe minimum number of bits per pixel which determine the red color.  The number of red bits the color buffer supports, e.g.  8 on current hardware.
gconfig_BITS_GREENThe minimum number of bits per pixel which determine the green color.  The number of green bits the color buffer supports, e.g.  8 on current hardware.
gconfig_BITS_BLUEThe minimum number of bits per pixel which determine the blue color.  The number of blue bits the color buffer supports, e.g.  8 on current hardware.
gconfig_BITS_ALPHAThe minimum number of bits per pixel which determine the alpha value (1: fully opaque, 0: fully transparent).  The number of alpha bits the color buffer supports, e.g.  8 on current hardware.
gconfig_BITS_DEPTHThe minimum number of bits the depth buffer must support.  If set to 0 no depth buffer is supported.
gconfig_BITS_STENCILThe minimum number of bits the stencil buffer must support.  If set to 0 no stencil buffer is supported.
gconfig_CONFORMANTDetermine the supported drawing APIs.  Supported values are any combination of bits ored together from gconfig_value_CONFORMANT_ES1_BIT, gconfig_value_CONFORMANT_ES2_BIT, gconfig_value_CONFORMANT_OPENGL_BIT, gconfig_value_CONFORMANT_OPENVG_BIT.
gconfig_NROFELEMENTSGives the number of all valid configuration options excluding gconfig_NROFELEMENTS.

gconfig_value_e

gconfig_value_TYPE_PBUFFER_BITThe config supports drawing into a OpenGL (ES) pixel buffer surface.  A pbuffer surface always supports single buffering.
gconfig_value_TYPE_PIXMAP_BITThe config supports drawing into a native pixmap surface.  A pixmap surface always supports single buffering.
gconfig_value_TYPE_WINDOW_BITThe config supports drawing into a window surface.  A window surface always supports double buffering.
gconfig_value_CONFORMANT_ES1_BITConfig supports creating OpenGL ES 1.0/1.1 graphic contexts.
gconfig_value_CONFORMANT_OPENVG_BITConfig supports creating OpenVG graphic contexts.
gconfig_value_CONFORMANT_ES2_BITConfig supports creating OpenGL ES 2.0 graphic contexts.
gconfig_value_CONFORMANT_OPENGL_BITConfig supports creating OpenGL graphic contexts.

Functions

Summary

test

unittest_graphic_gconfig

int unittest_graphic_gconfig(void)

Test gconfig_t functionality.

gconfig_filter_t

struct gconfig_filter_t

Declares filter to select between different possible configuration.  The filter function accept must return true if it accepts the visual ID given in parameter visualid else false.  If no visualid passes the constructor <initfiltered_gconfig> returns ESRCH.

Summary
Macros
gconfig_filter_INITStatic initializer.

Macros

gconfig_filter_INIT

#define gconfig_filter_INIT(accept,
user) { user, accept }

Static initializer.

gconfig_t

struct gconfig_t

Contains a specific surface configuration.

Summary
lifetime
gconfig_INITStatic initializer.
gconfig_FREEStatic initializer.
init_gconfigReturns an OpenGL surface configuration for display.
initfiltered_gconfigSame as init_gconfig except that more than one possible configuration is considered.
initfromconfigid_gconfigReturns an OpenGL surface configuration whose ID matches configid.
free_gconfigFrees any memory associated with a configuration.
query
gl_gconfigReturns the native OpenGL surface config.
value_gconfigReturns the value of attribute stored in gconf.
configid_gconfigReturns the configuration ID of gconf.
visualid_gconfigReturns the native visualid of the configuration.
maxpbuffer_gconfigReturns the maximum size of an off-screen pixel buffer.

lifetime

gconfig_INIT

#define gconfig_INIT(glconfig) { glconfig }

Static initializer.

gconfig_FREE

#define gconfig_FREE { 0 }

Static initializer.

init_gconfig

int init_gconfig(/*out*/gconfig_t *gconf,
struct display_t *display,
const int32_t config_attributes[])

Returns an OpenGL surface configuration for display.  The parameters stored in config_attributes must be tupels of type (gconfig_e value, int value) followed by the end of list value gconfig_NONE.  The display parameter must be valid as long as gconf is valid.  Uses initfiltered_gconfig to implement its functionality.  The internal filter is created from a call to <configfilter_x11window> (in case of X11 as selected UI).

initfiltered_gconfig

int initfiltered_gconfig(/*out*/gconfig_t *gconf,
struct display_t *display,
const int32_t config_attributes[],
gconfig_filter_t *filter)

Same as init_gconfig except that more than one possible configuration is considered.  The provided filter is repeatedly called for every possible configuration as long as it returns false.  The first configuration which passes the filter is used.  Parameter user is passed as user data into the filter function.

initfromconfigid_gconfig

int initfromconfigid_gconfig(/*out*/gconfig_t *gconf,
struct display_t *display,
const uint32_t configid)

Returns an OpenGL surface configuration whose ID matches configid.  Use this function to create a copy of an existing configuration.

free_gconfig

int free_gconfig(gconfig_t *gconf)

Frees any memory associated with a configuration.

query

gl_gconfig

struct opengl_config_t * gl_gconfig(const gconfig_t *gconf)

Returns the native OpenGL surface config.

value_gconfig

int value_gconfig(const gconfig_t *gconf,
struct display_t *display,
int32_t attribute,
/*out*/int32_t *value)

Returns the value of attribute stored in gconf.  Set attribute to a value from gconfig_e and display must be set to the same display given in the init function.

configid_gconfig

int configid_gconfig(const gconfig_t *gconf,
struct display_t *display,
/*out*/uint32_t *configid)

Returns the configuration ID of gconf.  Use this id to create a native window with the correct surface graphic attributes.

visualid_gconfig

int visualid_gconfig(const gconfig_t *gconf,
struct display_t *display,
/*out*/int32_t *visualid)

Returns the native visualid of the configuration.  Use this id to create a native window with the correct surface graphic attributes.

maxpbuffer_gconfig

int maxpbuffer_gconfig(const gconfig_t *gconf,
struct display_t *display,
/*out*/uint32_t *maxwidth,
/*out*/uint32_t *maxheight,
/*out*/uint32_t *maxpixels)

Returns the maximum size of an off-screen pixel buffer.  The values are returned in maxwidth(in pixels), maxheight(in pixels) and maxpixels(width*height).  The parameter maxpixels may be less than maxwidth multiplied by maxheight.  If one of the out parameter is set to NULL no value is returned.

gconfig_t

free_gconfig

#define free_gconfig(gconf) (*(gconf) = (gconfig_t) gconfig_FREE, 0)

Implements gconfig_t.free_gconfig.

configid_gconfig

#define configid_gconfig(
   gconf,
   display,
   configid
) configid_eglconfig(gl_gconfig(gconf), gl_display(display), configid)

Implements gconfig_t.configid_gconfig.

gl_gconfig

#define gl_gconfig(gconf) ((gconf)->glconfig)

Implements gconfig_t.gl_gconfig.

maxpbuffer_gconfig

#define maxpbuffer_gconfig(
   gconf,
   display,
   maxwidth,
   maxheight,
   maxpixels
) maxpbuffer_eglconfig(gl_gconfig(gconf), gl_display(display), maxwidth, maxheight, maxpixels)

Implements gconfig_t.maxpbuffer_gconfig.

value_gconfig

#define value_gconfig(
   gconf,
   display,
   attribute,
   value
) value_eglconfig(gl_gconfig(gconf), gl_display(display), attribute, value)

Implements gconfig_t.value_gconfig.

visualid_gconfig

#define visualid_gconfig(
   gconf,
   display,
   visualid
) visualconfigid_eglconfig(gl_gconfig(gconf), gl_display(display), visualid)

Implements gconfig_t.visualid_gconfig.

A configuration which describes the capabilities of an OpenGL graphic surface.
Implements Graphic-Surface-Configuration.
typedef struct gconfig_t gconfig_t
Export gconfig_t into global namespace.
struct gconfig_t
Contains a specific surface configuration.
typedef struct gconfig_filter_t gconfig_filter_t
Declares filter to select between different possible configuration.
int unittest_graphic_gconfig(void)
Test gconfig_t functionality.
#define gconfig_filter_INIT(accept,
user) { user, accept }
Static initializer.
#define gconfig_INIT(glconfig) { glconfig }
Static initializer.
#define gconfig_FREE { 0 }
Static initializer.
int init_gconfig(/*out*/gconfig_t *gconf,
struct display_t *display,
const int32_t config_attributes[])
Returns an OpenGL surface configuration for display.
int initfiltered_gconfig(/*out*/gconfig_t *gconf,
struct display_t *display,
const int32_t config_attributes[],
gconfig_filter_t *filter)
Same as init_gconfig except that more than one possible configuration is considered.
int initfromconfigid_gconfig(/*out*/gconfig_t *gconf,
struct display_t *display,
const uint32_t configid)
Returns an OpenGL surface configuration whose ID matches configid.
int free_gconfig(gconfig_t *gconf)
Frees any memory associated with a configuration.
struct opengl_config_t * gl_gconfig(const gconfig_t *gconf)
Returns the native OpenGL surface config.
int value_gconfig(const gconfig_t *gconf,
struct display_t *display,
int32_t attribute,
/*out*/int32_t *value)
Returns the value of attribute stored in gconf.
int configid_gconfig(const gconfig_t *gconf,
struct display_t *display,
/*out*/uint32_t *configid)
Returns the configuration ID of gconf.
int visualid_gconfig(const gconfig_t *gconf,
struct display_t *display,
/*out*/int32_t *visualid)
Returns the native visualid of the configuration.
int maxpbuffer_gconfig(const gconfig_t *gconf,
struct display_t *display,
/*out*/uint32_t *maxwidth,
/*out*/uint32_t *maxheight,
/*out*/uint32_t *maxpixels)
Returns the maximum size of an off-screen pixel buffer.
#define free_gconfig(gconf) (*(gconf) = (gconfig_t) gconfig_FREE, 0)
Implements gconfig_t.free_gconfig.
#define configid_gconfig(
   gconf,
   display,
   configid
) configid_eglconfig(gl_gconfig(gconf), gl_display(display), configid)
Implements gconfig_t.configid_gconfig.
#define gl_gconfig(gconf) ((gconf)->glconfig)
Implements gconfig_t.gl_gconfig.
#define maxpbuffer_gconfig(
   gconf,
   display,
   maxwidth,
   maxheight,
   maxpixels
) maxpbuffer_eglconfig(gl_gconfig(gconf), gl_display(display), maxwidth, maxheight, maxpixels)
Implements gconfig_t.maxpbuffer_gconfig.
#define value_gconfig(
   gconf,
   display,
   attribute,
   value
) value_eglconfig(gl_gconfig(gconf), gl_display(display), attribute, value)
Implements gconfig_t.value_gconfig.
#define visualid_gconfig(
   gconf,
   display,
   visualid
) visualconfigid_eglconfig(gl_gconfig(gconf), gl_display(display), visualid)
Implements gconfig_t.visualid_gconfig.
The config supports drawing into a window surface.
Config supports creating OpenGL ES 1.0/1.1 graphic contexts.
Config supports creating OpenGL ES 2.0 graphic contexts.
Config supports creating OpenGL graphic contexts.
Config supports creating OpenVG graphic contexts.
Gives the number of all valid configuration options excluding gconfig_NROFELEMENTS.
This is the last entry in a list to indicate termination.
Close