Beatmup
rendering_context.h
Go to the documentation of this file.
1 /*
2  Beatmup image and signal processing library
3  Copyright (C) 2019, lnstadrum
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #pragma once
20 
21 #include "../bitmap/content_lock.h"
22 #include "../gpu/pipeline.h"
23 #include "../gpu/program.h"
24 
25 namespace Beatmup {
26  /**
27  Stores the rendering context: current program, current mapping in the scene space, common rendering properties,
28  locked bitmaps, etc. Provides a set of tools and shortcuts to access rendering programs routines.
29  */
31  friend class SceneRenderer;
32  public:
33  class EventListener {
34  public:
35  virtual void onRenderingStart() = 0;
36  };
37 
38  private:
41 
43  const float outputWidth;
44  const bool renderingOnScreen;
45 
48 
49  public:
52  GraphicPipeline& getGpu() { return gpu; }
53 
55 
56  /**
57  Initiates the rendering operation.
58  */
59  void blend();
60 
63 
64  void bindMask(AbstractBitmap& mask);
65 
66  void setMapping(const AffineMapping& mapping) { this->mapping = mapping; }
67  const AffineMapping& getMapping() const { return mapping; }
68 
69  const float getOutputWidth() const { return outputWidth; }
70  const bool isRenderingOnScreen() const { return renderingOnScreen; }
71  };
72 
73 }
A very basic class for any image.
2x3 affine mapping containing a 2x2 matrix and a 2D point
Definition: geometry.h:639
Makes sure the bitmap content is accessible within an image processing task.
Definition: content_lock.h:34
Regular OpenGL program.
Definition: program.h:229
Operation
Standard rendering operations.
Internal low-level GPU control API.
Definition: pipeline.h:33
Represents image size in pixels.
Stores the rendering context: current program, current mapping in the scene space,...
ImageResolution outputResolution
void blend()
Initiates the rendering operation.
const float getOutputWidth() const
void bindMask(AbstractBitmap &mask)
void unlockBitmap(AbstractBitmap *bitmap)
const AffineMapping & getMapping() const
const bool isRenderingOnScreen() const
RenderingContext(GraphicPipeline &gpu, EventListener *eventListener, const ImageResolution &outputResolution, const float refWidth, const bool renderingOnScreen)
GraphicPipeline & getGpu()
const ImageResolution & getOutputResolution() const
void setMapping(const AffineMapping &mapping)
void enableProgram(GL::RenderingPrograms::Operation operation)
void lockBitmap(AbstractBitmap *bitmap)
AbstractTask rendering a Scene.
Definition: renderer.h:29
Beatmup::InternalBitmap * bitmap