Beatmup
Beatmup::GL::RenderingPrograms::Backend Class Reference

Public Member Functions

 Backend ()
 
 ~Backend ()
 
void bindMaskLookup (PixelFormat format)
 

Private Attributes

GLuint hMaskLookups [3]
 texture containing mask values for 1, 2 and 4 bpp More...
 
bool maskLookupsSet
 

Detailed Description

Definition at line 193 of file rendering_programs.cpp.

Constructor & Destructor Documentation

◆ Backend()

Beatmup::GL::RenderingPrograms::Backend::Backend ( )
inline

Definition at line 199 of file rendering_programs.cpp.

◆ ~Backend()

Beatmup::GL::RenderingPrograms::Backend::~Backend ( )
inline

Definition at line 200 of file rendering_programs.cpp.

200 {}

Member Function Documentation

◆ bindMaskLookup()

void Beatmup::GL::RenderingPrograms::Backend::bindMaskLookup ( PixelFormat  format)
inline

Definition at line 203 of file rendering_programs.cpp.

203  {
204  glActiveTexture(GL_TEXTURE0 + TextureUnits::MASK_LOOKUP);
205 
206  if (!maskLookupsSet) {
207  // masked blending lookup textures initialization
208  unsigned char mask1[8][256], mask2[4][256], mask4[2][256];
209  for (int v = 0; v < 256; ++v) {
210  for (int o = 0; o < 8; ++o)
211  mask1[o][v] = ((v >> o) % 2) * 255;
212  for (int o = 0; o < 4; ++o)
213  mask2[o][v] = (int)((v >> (2 * o)) % 4) * 255 / 3;
214  for (int o = 0; o < 2; ++o)
215  mask4[o][v] = (int)((v >> (4 * o)) % 16) * 255 / 15;
216  }
217  glGenTextures(3, hMaskLookups);
218  glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
219  glBindTexture(GL_TEXTURE_2D, hMaskLookups[0]);
220  glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 256, 8, 0, GL_ALPHA, GL_UNSIGNED_BYTE, mask1);
221  glBindTexture(GL_TEXTURE_2D, hMaskLookups[1]);
222  glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 256, 4, 0, GL_ALPHA, GL_UNSIGNED_BYTE, mask2);
223  glBindTexture(GL_TEXTURE_2D, hMaskLookups[2]);
224  glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 256, 2, 0, GL_ALPHA, GL_UNSIGNED_BYTE, mask4);
225  maskLookupsSet = true;
226  }
227 
228  switch (format) {
229  case BinaryMask:
230  glBindTexture(GL_TEXTURE_2D, hMaskLookups[0]);
231  break;
232  case QuaternaryMask:
233  glBindTexture(GL_TEXTURE_2D, hMaskLookups[1]);
234  break;
235  case HexMask:
236  glBindTexture(GL_TEXTURE_2D, hMaskLookups[2]);
237  break;
238  default:
239  throw GLException("Mask bitmap pixel format is not supported");
240  }
241  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
242  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
243  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
244  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
245  }
GPU exception.
Definition: bgl.h:56
GLuint hMaskLookups[3]
texture containing mask values for 1, 2 and 4 bpp
@ QuaternaryMask
2 bits per pixel
@ BinaryMask
1 bit per pixel
@ HexMask
4 bits per pixel
@ MASK_LOOKUP
JNIEnv jobject jint format
JNIEnv jlong jfloat jfloat jfloat v

Member Data Documentation

◆ hMaskLookups

GLuint Beatmup::GL::RenderingPrograms::Backend::hMaskLookups[3]
private

texture containing mask values for 1, 2 and 4 bpp

Definition at line 195 of file rendering_programs.cpp.

◆ maskLookupsSet

bool Beatmup::GL::RenderingPrograms::Backend::maskLookupsSet
private

Definition at line 196 of file rendering_programs.cpp.


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