Sunday, 20 February 2011

PCB+GL repository instructions

Ethan Swint suggested I write about my PCB+GL branches and how people can check out the code. I'm heartened to know that there are several people who use my PCB+GL branches regularly, and it does motivate me to continue working on the branches (and eventually, I hope - to merge them back to git HEAD).

The branches have been in existance for a very long time now - far longer than I originally intended. I first started an effort of porting PCB to OpenGL many years ago, and I would have liked to have seen the work a long time ago.

The primary advantages of the branches are:
  • Rendering performance
  • Layer translucency
  • 3D view helps visualise the board

The repository I push to is at:

A gitweb view of the repository is at

To clone this repository, you want some variant of:

git clone -o pcjc2 git://

Which will clone the repository into the "pcjc2" directory, with "pcjc2" as the remote name (rather than "origin"). If you have an existing checkout of PCB (e.g. from git://, you can add it as a new "remote" to that checkout with this command:

git remote add pcjc2 git://

I use the excellent "stgit" tools to manage my branches, which means that as I re-arrange and refactor the patch series' which constitute my branches, git history for those branches will be re-written. As long as you have no changes made, you can update your checkout with:

git fetch pcjc2
git reset --hard pcjc2/BRANCH_NAME

If you wish to base code changes from my branches, you should use stgit to manage your additions as patches. You CANNOT "git pull" or even "git rebase" to update your local branches cleanly, as the re-written history from my stgit branches will confuse both processes. (Sorry!).

Checkout the branch you want and initialise stgit:

git checkout -b local_pcb+gl_experimental pcjc2/pcb+gl_experimental
stg init

You can then "git fetch pcjc2" to fetch updates, and "stg rebase pcjc2/BRANCH_NAME" to rebase your changes against the latest changes I have pushed in the given branch. (You might find that "stg pull" will also work as an alternative to the fetch / rebase combination if your checkout is set to track my remote branch - try it!)

There are several branches in the repository, and the one most people will want is either "pcb+gl", or "pcb+gl_experimental". I use both for work, and you should find they are stable. The experimental varient has had less testing though, and might not work flawlessly with your graphics card if it doesn't support GLSL shaders. If you see square vias and pins, you need the "pcb+gl" branch as I've not yet added fallbacks to the old rendering code in the experimental branch.

Here is an example board rendering from the pcb+gl_experimental branch:

Now for some background on the branches...

What has been merged to git HEAD already?
  • Faster polygon rendering (by caching "NoHoles" polygons)
  • Speeding up polygon boolean calculations through various tricks and optimisations
  • Rendering bug fixes for hairlines
  • DRC rendering improvements
  • Polygon holes
  • Various refactoring of the GTK hid rendering code

What will you find in the branches?
  • Fast OpenGL rendering
  • Translucent layer rendering
  • 3D board view
  • Beginnings of crude 3D model rendering support (not visible unless you look at the non-committed stgit patches)
  • Polygon pours support (with island removal)

What are all the different branches for?
  • for_master

    (Staging area for pushing patches)

  • thermal-geometry

    Work on fixing thermal calculations - DO NOT USE (will cause geometry changes in your layouts!)

  • void_ptr_to_hid_flags

    An attempt to stop some harmless 64bit compiler warnings

    Author: Peter Clifton
    Date: Thu Dec 9 18:06:06 2010 +0000

    Convert argument in HID_Flags to (void *) rather than (int)

    void * allows us to pass pointers on all platforms, 64bit or
    otherwise. We can still use casting macros to safely pass integer
    values via this pointer.

    Avoids the ugliness of castnig a size_t sized offset_of value into
    an int. Due to the size of our structures, this did not cause any
    actual bugs, but was not good practice.

  • polygon_speedup

    Where I was working on performance of our polygon routines - now mostly merged, only debug stuff remains in my local stgit branch

    • bentley_ottmann_intersect

      Finding intersections between polygon contours is one of the tasks whcih consumes a lot of computation time when performing polygon operations. This branch attempts to use a sweepline algorithm (implementation from cairo), to compute intersections in a more efficient way.

  • pcb+gl

    Basic OpenGL rendering support for the GTK HID. Does not yet compile with --disable-gl

    • pcb+gl_experimental

      More experimental rendering changes, including:

      • More rendering in world coordinates
      • GLSL shader to speed up rendering line caps and circles (e.g. vias)
      • Caching of polygon tesselations for better performance
      • Perspective rendering
      • More efficient stencil buffer usage
      • More efficient rendering order for masking holes in polygons

      • local_customisation_pcb+gl

        A few favourite local patches I keep applied - such as changing mouse bindings and a handful of little hacks I use.

      • pours

        Adds support for keeping all pieces of a "poured" polygon, rather than PCB's default behaviour of only using the largest piece. The main contribution in this branch is the ability to track connectivity of each polygon fragment created when clipping "pours" against the board geometry.

        The branch also includes crude island-removal capability, in that any polygon fragment from a pour must be connected to a line or via before it will be drawn. (It is still possible to create floating polygon fragments, so long as they connect to a via or track).

        • local_customisation_pours

          A few favourite local patches I keep applied - such as changing mouse bindings and a handful of little hacks I use.

    • lesstif_gl (Not currently tested)

      A proof-of concept to show that the Lesstif HID could eventually share OpenGL rendering code with the GTK HID. Not recommended for use.

    • anti-polygons

      Before I merged support for holes in polygons to git HEAD, this was the first approach I experimented with. It allows a polygon with a special flag to cut holes in other polygons, just as tracks with clearance do. I've kept it around as it documents some of the changes required for support of "negative objects" (in polygons at least).

      • pours_with_anti_polygons

        Version of the pours branch which supports "anti-polygon" objects

        Kept for interest's sake in case anti-polygons are ever useful.

    • display_list_debug (not updated)
  • old_idea (not updated - an old version of "pours")

Finally, a screen-shot showing some of the things to come (when I get time to work on them!)

As always, constructive feedback and bug reports about my branches are welcome. For general PCB bugs (or bugs which can be reproduced in git HEAD, please file a bug on launchpad.


  1. It's not just good. It' fantastic! Congratulations!!! OpenGL is much faster!! How will we solve the problem about 3D components?