Beatmup
Beatmup::Scene::BitmapLayer Class Reference

Layer having an image to render. More...

#include <scene.h>

Inheritance diagram for Beatmup::Scene::BitmapLayer:
Beatmup::Scene::Layer Beatmup::Object Beatmup::Scene::CustomMaskedBitmapLayer Beatmup::Scene::ShadedBitmapLayer Beatmup::Scene::MaskedBitmapLayer Beatmup::Scene::ShapedBitmapLayer

Public Member Functions

bool testPoint (float x, float y) const
 Tests if a given point falls in the layer. More...
 
const AbstractBitmapgetBitmap () const
 
void setBitmap (AbstractBitmap *bitmap)
 
AffineMappinggetBitmapMapping ()
 
const AffineMappinggetBitmapMapping () const
 
void setBitmapMapping (const AffineMapping &mapping)
 
color4i getModulationColor () const
 
void setModulationColor (color4i color)
 
- Public Member Functions inherited from Beatmup::Scene::Layer
Type getType () const
 
const std::string & getName () const
 
void setName (const char *name)
 
AffineMappinggetMapping ()
 
const AffineMappinggetMapping () const
 
void setMapping (const AffineMapping &mapping)
 
virtual LayergetChild (float x, float y, unsigned int recursionDepth=0) const
 Picks a child layer at given point, if any. More...
 
bool isVisible () const
 Returns layer visibility flag. More...
 
bool isPhantom () const
 Returns true if the layer is ignored when searching a layer by point. More...
 
void setVisible (bool visible)
 Sets layer visibility. More...
 
void setPhantom (bool phantom)
 Makes/unmakes the layer "phantom". More...
 
template<class LayerType >
LayerType & castTo () const
 
- Public Member Functions inherited from Beatmup::Object
virtual ~Object ()
 

Protected Member Functions

 BitmapLayer ()
 
 BitmapLayer (Type type)
 
GL::TextureHandlerresolveContent (RenderingContext &context)
 
void configure (RenderingContext &context, GL::TextureHandler *content)
 Configures current rendering program to render this layer. More...
 
void render (RenderingContext &context)
 
- Protected Member Functions inherited from Beatmup::Scene::Layer
 Layer (Type type)
 

Protected Attributes

float invAr
 inverse aspect ratio of what is rendered (set by SceneRenderer) More...
 
AbstractBitmapbitmap
 content to display, used if the image source is set to BITMAP More...
 
AffineMapping bitmapMapping
 bitmap mapping w.r.t. the layer mapping More...
 
color4i modulation
 modulation color More...
 
- Protected Attributes inherited from Beatmup::Scene::Layer
AffineMapping mapping
 layer mapping More...
 
bool visible
 layer visibility More...
 
bool phantom
 if true, layer is ignored by selection by point More...
 

Friends

class Scene
 
class SceneRenderer
 

Additional Inherited Members

- Public Types inherited from Beatmup::Scene::Layer
enum class  Type {
  SceneLayer = 0 , BitmapLayer , MaskedBitmapLayer , ShapedBitmapLayer ,
  ShadedBitmapLayer
}
 

Detailed Description

Layer having an image to render.

The image has a position and orientation with respect to the layer. This is expressed with an affine mapping applied on top of the layer mapping.

Definition at line 158 of file scene.h.

Constructor & Destructor Documentation

◆ BitmapLayer() [1/2]

Scene::BitmapLayer::BitmapLayer ( )
protected

Definition at line 264 of file scene.cpp.

264  :
266 {}
@ BitmapLayer
layer displaying a bitmap

◆ BitmapLayer() [2/2]

Scene::BitmapLayer::BitmapLayer ( Type  type)
protected

Definition at line 268 of file scene.cpp.

268  :
270 {}
float invAr
inverse aspect ratio of what is rendered (set by SceneRenderer)
Definition: scene.h:173
AffineMapping bitmapMapping
bitmap mapping w.r.t. the layer mapping
Definition: scene.h:175
AbstractBitmap * bitmap
content to display, used if the image source is set to BITMAP
Definition: scene.h:174
color4i modulation
modulation color
Definition: scene.h:176
Layer(const Layer &)=delete
disabling copying constructor
static const color4i WHITE
Definition: constants.h:26

Member Function Documentation

◆ resolveContent()

GL::TextureHandler * Scene::BitmapLayer::resolveContent ( RenderingContext context)
protected

Definition at line 273 of file scene.cpp.

273  {
274  if (bitmap)
275  context.lockBitmap(bitmap);
276  return bitmap;
277 }
void lockBitmap(AbstractBitmap *bitmap)

◆ configure()

void Scene::BitmapLayer::configure ( RenderingContext context,
GL::TextureHandler content 
)
protected

Configures current rendering program to render this layer.

Definition at line 279 of file scene.cpp.

279  {
280  if (content) {
281  invAr = content->getInvAspectRatio();
282  context.getProgram().bindSampler(context.getGpu(), *content, "image", TextureParam::INTERP_LINEAR);
283  }
284  else
285  invAr = 0;
286 
287  context.getProgram().setVector4("modulationColor", modulation);
288 }
void bindSampler(GraphicPipeline &gpu, GL::TextureHandler &image, const char *uniformId, TextureParam param)
Definition: program.cpp:474
void setVector4(const std::string &name, const float x, const float y, const float z, const float w)
Definition: program.cpp:378
GraphicPipeline & getGpu()
@ INTERP_LINEAR
bilinear pixel interpolation
std::string content

◆ render()

void Scene::BitmapLayer::render ( RenderingContext context)
protectedvirtual

Reimplemented from Beatmup::Scene::Layer.

Reimplemented in Beatmup::Scene::ShadedBitmapLayer, Beatmup::Scene::ShapedBitmapLayer, and Beatmup::Scene::MaskedBitmapLayer.

Definition at line 291 of file scene.cpp.

291  {
293  if (content) {
294  // program selection
295  switch (content->getTextureFormat()) {
296  case GL::TextureHandler::TextureFormat::OES_Ext:
298  break;
299  default:
301  break;
302  }
303 
304  configure(context, content);
305 
306  AffineMapping arMapping(context.getMapping() * bitmapMapping);
307  arMapping.matrix.scale(1.0f, invAr);
309  context.blend();
310  }
311 }
2x3 affine mapping containing a 2x2 matrix and a 2D point
Definition: geometry.h:639
void setMatrix3(const std::string &name, const Matrix2 &mat, const Point &pos)
Definition: program.cpp:402
@ BLEND_EXT
default blending using a texture extension
@ BLEND
default blending of a single image
static const char * MODELVIEW_MATRIX_ID
Modelview matrix (mapping input geometry to output) shader variable name in vertex shader.
void blend()
Initiates the rendering operation.
const AffineMapping & getMapping() const
void enableProgram(GL::RenderingPrograms::Operation operation)
GL::TextureHandler * resolveContent(RenderingContext &context)
Definition: scene.cpp:273
void configure(RenderingContext &context, GL::TextureHandler *content)
Configures current rendering program to render this layer.
Definition: scene.cpp:279

◆ testPoint()

bool Scene::BitmapLayer::testPoint ( float  x,
float  y 
) const
virtual

Tests if a given point falls in the layer.

Reimplemented from Beatmup::Scene::Layer.

Reimplemented in Beatmup::Scene::ShapedBitmapLayer, and Beatmup::Scene::MaskedBitmapLayer.

Definition at line 314 of file scene.cpp.

314  {
315  // no bitmap - no deal (if the source is set to bitmap)
316  if (!bitmap)
317  return false;
318  return (mapping * bitmapMapping).isPointInside(x, y, 1, invAr);
319 }
AffineMapping mapping
layer mapping
Definition: scene.h:80
jobject jlong jint jint y
jobject jlong jint x

◆ getBitmap()

const AbstractBitmap* Beatmup::Scene::BitmapLayer::getBitmap ( ) const
inline

Definition at line 181 of file scene.h.

181 { return bitmap; }

◆ setBitmap()

void Beatmup::Scene::BitmapLayer::setBitmap ( AbstractBitmap bitmap)
inline

Definition at line 182 of file scene.h.

182 { this->bitmap = bitmap; }

◆ getBitmapMapping() [1/2]

AffineMapping& Beatmup::Scene::BitmapLayer::getBitmapMapping ( )
inline

Definition at line 184 of file scene.h.

184 { return bitmapMapping; }

◆ getBitmapMapping() [2/2]

const AffineMapping& Beatmup::Scene::BitmapLayer::getBitmapMapping ( ) const
inline

Definition at line 185 of file scene.h.

185 { return bitmapMapping; }

◆ setBitmapMapping()

void Beatmup::Scene::BitmapLayer::setBitmapMapping ( const AffineMapping mapping)
inline

Definition at line 186 of file scene.h.

186 { this->bitmapMapping = mapping; }

◆ getModulationColor()

color4i Beatmup::Scene::BitmapLayer::getModulationColor ( ) const
inline

Definition at line 188 of file scene.h.

188 { return modulation; }

◆ setModulationColor()

void Beatmup::Scene::BitmapLayer::setModulationColor ( color4i  color)
inline

Definition at line 189 of file scene.h.

189 { this->modulation = color; }

Friends And Related Function Documentation

◆ Scene

friend class Scene
friend

Definition at line 159 of file scene.h.

◆ SceneRenderer

friend class SceneRenderer
friend

Definition at line 160 of file scene.h.

Member Data Documentation

◆ invAr

float Beatmup::Scene::BitmapLayer::invAr
protected

inverse aspect ratio of what is rendered (set by SceneRenderer)

Definition at line 173 of file scene.h.

◆ bitmap

AbstractBitmap* Beatmup::Scene::BitmapLayer::bitmap
protected

content to display, used if the image source is set to BITMAP

Definition at line 174 of file scene.h.

◆ bitmapMapping

AffineMapping Beatmup::Scene::BitmapLayer::bitmapMapping
protected

bitmap mapping w.r.t. the layer mapping

Definition at line 175 of file scene.h.

◆ modulation

color4i Beatmup::Scene::BitmapLayer::modulation
protected

modulation color

Definition at line 176 of file scene.h.


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