Fix sorting bug

This commit is contained in:
Nite Luo 2013-11-05 17:00:34 -08:00
parent e4ffd250cb
commit 51fb1edc0c
1 changed files with 7 additions and 2 deletions

View File

@ -39,17 +39,22 @@ void Renderer::setOpenGLView(EGLView *newOpenGLView)
void Renderer::addRenderCommand(RenderCommand *command)
{
command.generateID();
command->generateID();
_renderQueue.push_back(command);
}
bool compareRenderCommand(RenderCommand* a, RenderCommand* b)
{
return a->getID() < b->getID();
}
void Renderer::render()
{
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//Process render commands
//1. Sort render commands based on ID
// stable_sort(_renderQueue.begin(), _renderQueue.end());
stable_sort(_renderQueue.begin(), _renderQueue.end(), compareRenderCommand);
// sort(_renderQueue.begin(), _renderQueue.end());
//2. Process commands