Issue #531 wontfix

draw calls count in C++

Antonio Moder avatarAntonio Moder created an issue

Make records in C++ - how many times the LOVE2D is draw stuff.


Example:

In C + +:

void Graphics::rectangle(DrawMode mode, float x, float y, float w, float h)
{
    quad (mode, x, y, x, y + h, x + w, y + h, x + w, y);
    debug.drawCalls += 1;
}

In LOVE script:              

love.graphics.draw(sprite, 0,0);
love.graphics.draw(sprite2, 0,0);
print(love.drawCalls())           -- print 2

It is not easy to do in Lua:              

love.graphics.draw(sprite, 0,0); 
debug.drawCalls = debug.drawCalls+1;
love.graphics.draw(sprite2, 0,0); 
debug.drawCalls = debug.drawCalls+1;
print(debug.drawCalls)            -- print 2

Comments (7)

  1. Bart van Strien

    What's the use? It's also really easy to wrap things like this:

    drawCalls = 0
    function wrapDrawCall(name)
      local func = love.graphics[name]
      function love.graphics[name](...)
        drawCalls = drawCalls + 1
        return func(...)
      end
    end
    
    wrapDrawCall("draw")
    -- etc
    
  2. vrld

    It's probably slower, but you will likely not be able to notice any difference. To fix the error:

     love.graphics[name] = function (...)
    

    But I have to agree with bartbes: What's the use?

  3. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.