TINYGL: Replaced Array with List as the container for draw calls queue.

NOTE: I also had to construct the struct GLContext properly now.
This commit is contained in:
Stefano Musumeci 2014-07-26 17:56:44 +02:00
parent 98d6944c22
commit 7f560daf04
3 changed files with 12 additions and 7 deletions

View file

@ -36,7 +36,7 @@ void glInit(void *zbuffer1, int textureSize) {
if (textureSize <= 1 || textureSize > 4096) if (textureSize <= 1 || textureSize > 4096)
error("glInit: texture size not allowed: %d", textureSize); error("glInit: texture size not allowed: %d", textureSize);
c = (GLContext *)gl_zalloc(sizeof(GLContext)); c = new GLContext();
gl_ctx = c; gl_ctx = c;
c->fb = zbuffer; c->fb = zbuffer;

View file

@ -4,6 +4,7 @@
#include "common/util.h" #include "common/util.h"
#include "common/textconsole.h" #include "common/textconsole.h"
#include "common/array.h" #include "common/array.h"
#include "common/list.h"
#include "graphics/tinygl/gl.h" #include "graphics/tinygl/gl.h"
#include "graphics/tinygl/zbuffer.h" #include "graphics/tinygl/zbuffer.h"
@ -284,7 +285,7 @@ struct GLContext {
Common::Array<Graphics::BlitImage *> blitImages; Common::Array<Graphics::BlitImage *> blitImages;
// Draw call queue // Draw call queue
Common::Array<Graphics::DrawCall *> _drawCallsQueue; Common::List<Graphics::DrawCall *> _drawCallsQueue;
}; };
extern GLContext *gl_ctx; extern GLContext *gl_ctx;

View file

@ -5,8 +5,8 @@
namespace TinyGL { namespace TinyGL {
void glIssueDrawCall(Graphics::DrawCall *drawCall) { void glIssueDrawCall(Graphics::DrawCall *drawCall) {
drawCall->execute(); TinyGL::GLContext *c = TinyGL::gl_get_context();
delete drawCall; c->_drawCallsQueue.push_back(drawCall);
} }
} // end of namespace TinyGL } // end of namespace TinyGL
@ -14,10 +14,14 @@ void glIssueDrawCall(Graphics::DrawCall *drawCall) {
void tglPresentBuffer() { void tglPresentBuffer() {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
for(int i = 0; i < c->_drawCallsQueue.size(); ++i) {
c->_drawCallsQueue[i]->execute(); Common::List<Graphics::DrawCall *>::const_iterator it = c->_drawCallsQueue.begin();
delete c->_drawCallsQueue[i]; while (it != c->_drawCallsQueue.end()) {
(*it)->execute();
delete (*it);
it++;
} }
c->_drawCallsQueue.clear(); c->_drawCallsQueue.clear();
TinyGL::GLTexture *t = c->shared_state.texture_hash_table[0]; TinyGL::GLTexture *t = c->shared_state.texture_hash_table[0];