Defines
core/vgui/internals/vgui_gl_selection_macros.h File Reference
#include <vgui/vgui_gl.h>
#include <vgui/vgui_pixel.h>

Go to the source code of this file.

Defines

#define ConditionList0(format, type)
#define ConditionList1(format, type)
#define ConditionList2(format, type)
#define ConditionList3(format, type)
#define ConditionList4(format, type)
#define ConditionListBody(format, type)
#define ConditionListBegin   if (0) do {} while (0)
#define ConditionListFail   else
#define ConditionListEnd   else { /* null */ }

Detailed Description

Author:
Amitha Perera

This collection of macros is used to simplify the selection of the vgui_pixel_* type based on the GL format and GL type. Suppose the current format is in fmt and the current type is in typ. First define a macro "Code" that containing the code that relies on the corresponding vgui_pixel_type, and then call ConditionListBegin, ConditionListBody, ConditionListFail. This will generate a collection of if statements that will run "Code" with the appropriate type. For example:

 #define Code(pixel_type) buffer_of<pixel_type > buffer; convert_to_buffer(in_image,buffer);

    ConditionListBegin;
    ConditionListBody( fmt, typ );
    ConditionListFail
    {
       vcl_cerr << "don't know " << fmt << " and " << typ << "\n";
       return false;
    }

 #undef Code

will generate code like

 if ( fmt==GL_RGB && typ==GL_UNSIGNED )
 {
   buffer_of<vgui_pixel_rgb888 > buffer;
   convert_to_buffer(in_image,buffer);
 } else if ( fmt==GL_RGB && typ==GL_UNSIGNED_SHORT_5_6_5 )
 {
   buffer_of<vgui_pixel_rgb565 > buffer;
   convert_to_buffer(in_image,buffer);
 } else if (
      ...
 } else
 {
   vcl_cerr << "don't know " << fmt << " and " << typ << "\n";
   return false;
 }

If you don't want to handle the failure condition, you can replace ConditionListFail with ConditionListEnd.

Definition in file vgui_gl_selection_macros.h.


Define Documentation

#define ConditionList0 (   format,
  type 
)
Value:
else if ( format==GL_RGB && type==GL_UNSIGNED_BYTE ) { Code( vgui_pixel_rgb888 ) } \
  else if ( format==GL_BGR && type==GL_UNSIGNED_BYTE ) { Code( vgui_pixel_bgr888 ) } \
  else if ( format==GL_RGBA && type==GL_UNSIGNED_BYTE ) { Code( vgui_pixel_rgba8888 ) }

Definition at line 56 of file vgui_gl_selection_macros.h.

#define ConditionList1 (   format,
  type 
)

Definition at line 65 of file vgui_gl_selection_macros.h.

#define ConditionList2 (   format,
  type 
)

Definition at line 73 of file vgui_gl_selection_macros.h.

#define ConditionList3 (   format,
  type 
)

Definition at line 80 of file vgui_gl_selection_macros.h.

#define ConditionList4 (   format,
  type 
)

Definition at line 87 of file vgui_gl_selection_macros.h.

#define ConditionListBegin   if (0) do {} while (0)

Definition at line 99 of file vgui_gl_selection_macros.h.

#define ConditionListBody (   format,
  type 
)
Value:
ConditionList0(format,type) \
  ConditionList1(format,type) \
  ConditionList2(format,type) \
  ConditionList3(format,type) \
  ConditionList4(format,type) \
  else if (0)do{}while (0)

Definition at line 91 of file vgui_gl_selection_macros.h.

#define ConditionListEnd   else { /* null */ }

Definition at line 101 of file vgui_gl_selection_macros.h.

#define ConditionListFail   else

Definition at line 100 of file vgui_gl_selection_macros.h.