Topic/drawable 2 (#1029)
This commit is contained in:
committed by
Bart Louwers
parent
14b53e54ec
commit
e2bc75289c
@@ -14,6 +14,8 @@ class PaintParameters;
|
||||
namespace gfx {
|
||||
|
||||
class DrawableTweaker;
|
||||
class ShaderProgramBase;
|
||||
using ShaderProgramBasePtr = std::shared_ptr<ShaderProgramBase>;
|
||||
|
||||
using DrawPriority = int64_t;
|
||||
using DrawableTweakerPtr = std::shared_ptr<DrawableTweaker>;
|
||||
@@ -32,10 +34,8 @@ public:
|
||||
virtual void draw(const PaintParameters &) const = 0;
|
||||
|
||||
/// Which shader to use when rendering this drawable
|
||||
//util::SimpleIdentity getShaderID() const { return shaderID; }
|
||||
//void setShaderID(util::SimpleIdentity value) { shaderID = value; }
|
||||
const std::string& getShaderID() const { return shaderID; }
|
||||
void setShaderID(std::string value) { shaderID = std::move(value); }
|
||||
const gfx::ShaderProgramBasePtr& getShader() const { return shader; }
|
||||
void setShader(gfx::ShaderProgramBasePtr value) { shader = std::move(value); }
|
||||
|
||||
/// DrawPriority determines the drawing order
|
||||
DrawPriority getDrawPriority() const { return drawPriority; }
|
||||
@@ -58,8 +58,7 @@ public:
|
||||
|
||||
protected:
|
||||
util::SimpleIdentity uniqueID;
|
||||
//util::SimpleIdentity shaderID = util::SimpleIdentity::Empty;
|
||||
std::string shaderID;
|
||||
gfx::ShaderProgramBasePtr shader;
|
||||
|
||||
DrawPriority drawPriority = 0;
|
||||
|
||||
|
||||
@@ -13,8 +13,10 @@ class Color;
|
||||
namespace gfx {
|
||||
|
||||
class DrawableTweaker;
|
||||
class ShaderProgramBase;
|
||||
|
||||
using DrawableTweakerPtr = std::shared_ptr<DrawableTweaker>;
|
||||
using ShaderProgramBasePtr = std::shared_ptr<ShaderProgramBase>;
|
||||
|
||||
/**
|
||||
Base class for drawable builders, which construct Drawables from primitives
|
||||
@@ -54,10 +56,8 @@ public:
|
||||
void setColor(const Color& value);
|
||||
|
||||
/// Which shader to use when rendering emitted drawables
|
||||
//util::SimpleIdentity getShaderID() const { return shaderID; }
|
||||
//void setShaderID(util::SimpleIdentity value) { shaderID = value; }
|
||||
const std::string& getShaderID() const { return shaderID; }
|
||||
void setShaderID(std::string value) { shaderID = std::move(value); }
|
||||
const gfx::ShaderProgramBasePtr& getShader() const { return shader; }
|
||||
void setShader(gfx::ShaderProgramBasePtr value) { shader = std::move(value); }
|
||||
|
||||
/// Get the vertex attributes that override default values in the shader program
|
||||
virtual const gfx::VertexAttributeArray& getVertexAttributes() const = 0;
|
||||
@@ -83,8 +83,7 @@ protected:
|
||||
protected:
|
||||
DrawPriority drawPriority = 0;
|
||||
|
||||
//util::SimpleIdentity shaderID = util::SimpleIdentity::Empty;
|
||||
std::string shaderID;
|
||||
gfx::ShaderProgramBasePtr shader;
|
||||
|
||||
DrawablePtr currentDrawable;
|
||||
std::vector<DrawablePtr> drawables;
|
||||
|
||||
@@ -8,9 +8,10 @@
|
||||
namespace mbgl {
|
||||
namespace gfx {
|
||||
|
||||
class BackendScope;
|
||||
class Context;
|
||||
class Renderable;
|
||||
class BackendScope;
|
||||
class ShaderRegistry;
|
||||
|
||||
// We can make some optimizations if we know that the drawing context is not shared with other code.
|
||||
enum class ContextMode : bool {
|
||||
@@ -40,6 +41,9 @@ public:
|
||||
/// Returns a reference to the default surface that should be rendered on.
|
||||
virtual Renderable& getDefaultRenderable() = 0;
|
||||
|
||||
/// One-time shader initialization
|
||||
virtual void initShaders(gfx::ShaderRegistry&) = 0;
|
||||
|
||||
protected:
|
||||
virtual std::unique_ptr<Context> createContext() = 0;
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@ public:
|
||||
/// Called prior to rendering to update the internally assumed OpenGL state.
|
||||
virtual void updateAssumedState() = 0;
|
||||
|
||||
/// One-time shader initialization
|
||||
void initShaders(gfx::ShaderRegistry&) override;
|
||||
|
||||
protected:
|
||||
std::unique_ptr<gfx::Context> createContext() override;
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ private:
|
||||
class VertexAttributeArrayGL final : public gfx::VertexAttributeArray {
|
||||
public:
|
||||
VertexAttributeArrayGL(int initCapacity = 10) : VertexAttributeArray(initCapacity) { }
|
||||
VertexAttributeArrayGL(VertexAttributeArray &&other) : VertexAttributeArray(std::move(other)) { }
|
||||
VertexAttributeArrayGL(const VertexAttributeArray& other) : VertexAttributeArray(other) { }
|
||||
VertexAttributeArrayGL(VertexAttributeArrayGL &&other) : VertexAttributeArray(std::move(other)) { }
|
||||
VertexAttributeArrayGL(const VertexAttributeArrayGL& other) : VertexAttributeArray(other) { }
|
||||
~VertexAttributeArrayGL() = default;
|
||||
|
||||
VertexAttributeArrayGL& operator=(VertexAttributeArrayGL &&other) {
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace gl {
|
||||
class ShaderProgramGL final : public gfx::ShaderProgramBase {
|
||||
public:
|
||||
ShaderProgramGL(UniqueProgram&& glProgram_);
|
||||
ShaderProgramGL(UniqueProgram&& glProgram_, VertexAttributeArrayGL&& attributes);
|
||||
ShaderProgramGL(ShaderProgramGL&& other);
|
||||
virtual ~ShaderProgramGL() noexcept = default;
|
||||
|
||||
@@ -24,6 +25,8 @@ public:
|
||||
|
||||
const gfx::VertexAttributeArray& getVertexAttributes() const override { return vertexAttributes; }
|
||||
|
||||
ProgramID getGLProgramID() const { return glProgram; }
|
||||
|
||||
protected:
|
||||
UniqueProgram glProgram;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user