mirror of https://github.com/axmolengine/axmol.git
Cleanup the code a bit before implement sprite batching
This commit is contained in:
parent
21cd03bc13
commit
3421eb8e5d
|
@ -19,6 +19,11 @@ QuadCommand::QuadCommand(int viewport, int32_t depth, GLuint textureID, GLuint s
|
|||
_type = QUAD_COMMAND;
|
||||
}
|
||||
|
||||
QuadCommand::~QuadCommand()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int64_t QuadCommand::generateID()
|
||||
{
|
||||
_id = 0;
|
||||
|
|
|
@ -16,6 +16,7 @@ class QuadCommand : public RenderCommand
|
|||
{
|
||||
public:
|
||||
QuadCommand(int viewport, int32_t depth, GLuint textureID, GLuint shaderID, BlendFunc blendType, V3F_C4B_T2F_Quad quad);
|
||||
~QuadCommand();
|
||||
|
||||
// +----------+----------+-----+-----------------------------------+
|
||||
// | | | | | |
|
||||
|
@ -26,12 +27,17 @@ public:
|
|||
|
||||
//TODO use material to decide if it is translucent
|
||||
inline bool isTranslucent() { return true; }
|
||||
|
||||
inline bool isCommand() { return false; }
|
||||
|
||||
inline int32_t getMaterialID() { return _materialID; }
|
||||
|
||||
inline GLuint getTextureID() { return _textureID; }
|
||||
|
||||
inline V3F_C4B_T2F_Quad* getQuad() { return &_quad; }
|
||||
|
||||
inline GLuint getShaderID() { return _shaderID; }
|
||||
|
||||
inline BlendFunc getBlendType() { return _blendType; }
|
||||
|
||||
protected:
|
||||
|
@ -39,11 +45,15 @@ protected:
|
|||
|
||||
//Key Data
|
||||
int _viewport; /// Which view port it belongs to
|
||||
|
||||
//TODO use material to determine if it's translucent
|
||||
int32_t _depth;
|
||||
|
||||
//Maternal
|
||||
GLuint _textureID;
|
||||
|
||||
GLuint _shaderID;
|
||||
|
||||
BlendFunc _blendType;
|
||||
|
||||
V3F_C4B_T2F_Quad _quad;
|
||||
|
|
|
@ -13,6 +13,9 @@ RenderCommand::RenderCommand()
|
|||
_type = UNKNOWN_COMMAND;
|
||||
}
|
||||
|
||||
RenderCommand::~RenderCommand()
|
||||
{
|
||||
}
|
||||
|
||||
void printBits(size_t const size, void const * const ptr)
|
||||
{
|
||||
|
|
|
@ -27,6 +27,7 @@ class RenderCommand
|
|||
public:
|
||||
|
||||
RenderCommand();
|
||||
virtual ~RenderCommand();
|
||||
virtual int64_t generateID() = 0;
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,17 +27,11 @@ Renderer *Renderer::getInstance()
|
|||
}
|
||||
|
||||
Renderer::Renderer()
|
||||
:_currentMaterialID(0)
|
||||
:_lastMaterialID(0)
|
||||
{
|
||||
_shaderProgram = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR);
|
||||
}
|
||||
|
||||
void Renderer::setOpenGLView(EGLView *newOpenGLView)
|
||||
{
|
||||
//TODO move render related logic to render
|
||||
_openGLView = newOpenGLView;
|
||||
}
|
||||
|
||||
void Renderer::addRenderCommand(RenderCommand *command)
|
||||
{
|
||||
command->generateID();
|
||||
|
|
|
@ -20,7 +20,7 @@ class Renderer
|
|||
public:
|
||||
static Renderer* getInstance();
|
||||
|
||||
void setOpenGLView(EGLView *newOpenGLView);
|
||||
//TODO support multiple viewport
|
||||
void addRenderCommand(RenderCommand* commnad);
|
||||
void render();
|
||||
|
||||
|
@ -28,10 +28,10 @@ protected:
|
|||
Renderer();
|
||||
|
||||
protected:
|
||||
EGLView* _openGLView;
|
||||
vector<RenderCommand*> _renderQueue;
|
||||
GLProgram* _shaderProgram;
|
||||
int _currentMaterialID;
|
||||
int _lastMaterialID;
|
||||
V3F_C4B_T2F_Quad* _quadBuffer;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
|
Loading…
Reference in New Issue