You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Where are the draw calls of the OpenGL backend? #194
First I want to say: Thank you for this amazing library. This is exactly what I need.
I want to use this library with OpenGL to render a GUI. I would like to have hardware acceleration which draw2d provides via draw2dgl. But this backend is implemented in OpenGL 1.0 and therefore you are limited to a Context of OpenGL 2.1 at max. If you want to have nice shader effects or if your hardware does not support immediate mode rendering, you have a problem. Therefore I would like to port the OpenGL backend to OpenGL ES 2 to also get better support on ARM SoCs. Now I am wondering: Where is the code that actually calls OpenGL? All I can find are a few lines in gc.go that render lines. But where are the triangles getting rendered?
// A Span is a horizontal segment of pixels with constant alpha. X0 is an// inclusive bound and X1 is exclusive, the same as for slices. A fully opaque// Span has Alpha == 0xffff.typeSpanstruct {
Y, X0, X1intAlphauint32
}
I did some research and found out that the draw2dgl.Painter is rendering raster.Span elements. If I understand correctly, a CPU rasterizer first creates horizontal lines out of filled geometry and then those lines are rendered using a line renderer in OpenGL. This seems to be very inefficient, since OpenGL can rasterize geometry on the GPU. Maybe I will use draw2d only for text rendering and create my own shape renderer. But at least this answers my question.
I will keep this issue open, in case someone wants to comment on this. Feel free to close it.
Activity
PucklaJ commentedon Feb 10, 2026
raster.Span
I did some research and found out that the
draw2dgl.Painteris renderingraster.Spanelements. If I understand correctly, a CPU rasterizer first creates horizontal lines out of filled geometry and then those lines are rendered using a line renderer in OpenGL. This seems to be very inefficient, since OpenGL can rasterize geometry on the GPU. Maybe I will use draw2d only for text rendering and create my own shape renderer. But at least this answers my question.I will keep this issue open, in case someone wants to comment on this. Feel free to close it.
llgcode commentedon Feb 11, 2026
Hi @PucklaJ,
Yes the gl renderer is not efficient at all it needs to be rewritten. It was an experimentation.