While working on my projects I wanted to use a graphic debugger like RenderDoc to check a few things.
Löve doesn't really create any events by default, so checking the OpenGL api calls in a flat list can be a bit tedious sometimes.
So here is a code snippet that shows how to manually push events that are visible in RenderDoc:
ogl.lua
Code: Select all
local FFI = require( 'ffi' )
local OGL_LIBS = {
OSX = { x86 = "OpenGL.framework/OpenGL", x64 = "OpenGL.framework/OpenGL" },
Windows = { x86 = "OPENGL32.DLL", x64 = "OPENGL32.DLL" },
Linux = { x86 = "libGL.so", x64 = "libGL.so", arm = "libGL.so" },
}
local OGL_LIB = OGL_LIBS[ FFI.os ][ FFI.arch ]
FFI.cdef[[
typedef char GLchar;
typedef int GLsizei;
typedef unsigned int GLuint;
typedef unsigned int GLenum;
void glPushDebugGroup( GLenum source, GLuint id, GLsizei length, const GLchar *message );
void glPopDebugGroup( void );
]]
local OPENGL = {
GL = FFI.load( OGL_LIB ),
PushEvent = function( self, Message )
self.GL.glPushDebugGroup(
0,
0,
string.len( Message ),
Message
)
end,
PopEvent = function( self )
self.GL.glPopDebugGroup()
end
}
return OPENGL
Code: Select all
local GL = require( "ogl.lua" )
function love.load()
end
function love.update( dt )
end
function love.draw()
GL:PushEvent( "ParentEvent" )
love.graphics.rectangle( "fill", 10, 50, 60, 120 )
GL:PushEvent( "ChildEvent" )
love.graphics.rectangle( "fill", 40, 50, 60, 120 )
GL:PopEvent()
GL:PopEvent()
end
Bonus, if you want to check/use other OpenGL functions they can be found here: https://www.khronos.org/registry/OpenGL ... lcorearb.h