Skip to content

Where are the draw calls of the OpenGL backend? #194

Open

Description

@PucklaJ

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?

This information would be very appreciated.

Activity

  1. PucklaJ commented on Feb 10, 2026

    @PucklaJ
    Author

    raster.Span

    // 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.
    type Span struct {
    	Y, X0, X1 int
    	Alpha     uint32
    }

    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.

  2. llgcode commented on Feb 11, 2026

    @llgcode
    Owner

    Hi @PucklaJ,
    Yes the gl renderer is not efficient at all it needs to be rewritten. It was an experimentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions