Welcome to mirror list, hosted at ThFree Co, Russian Federation.

render_context.hpp « graphics - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0df84cbab1a0a117ce2150ada9cbfb0b8a093749 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#pragma once

#include "../../std/shared_ptr.hpp"
#include "../../std/map.hpp"
#include "../../base/matrix.hpp"
#include "defines.hpp"

namespace graphics
{
  class ResourceManager;

  /// base class for render contexts.
  /// contains current render state data.
  class RenderContext
  {
  public:

    typedef math::Matrix<float, 4, 4> TMatrix;

  private:

    /// Rendering states
    /// @{
    map<EMatrix, TMatrix> m_matrices;
    /// @}

    unsigned m_threadSlot;
    shared_ptr<ResourceManager> m_resourceManager;

  protected:

    unsigned threadSlot() const;

  public:

    /// Working with rendering states.
    /// @{
    TMatrix const & matrix(EMatrix m) const;
    void setMatrix(EMatrix mt, TMatrix const & m);
    /// @}

    /// Constructor
    RenderContext();
    /// Destructor.
    virtual ~RenderContext();
    /// Make this context current for the specified thread.
    virtual void makeCurrent() = 0;
    /// Create a render context which is shared with this one.
    /// Context sharing means that all resources created in one context
    /// can be used in shared context and vice versa.
    virtual RenderContext * createShared() = 0;
    /// this function should be called from each opengl thread
    /// to setup some thread parameters.
    virtual void startThreadDrawing(unsigned threadSlot);
    /// called at the end of thread
    virtual void endThreadDrawing(unsigned threadSlot);
    /// set attached resource manager
    void setResourceManager(shared_ptr<ResourceManager> const & rm);
    /// get the attached resource manager
    shared_ptr<ResourceManager> const & resourceManager() const;
  };
}