Category archives: Snaking

Discussions of programming, particularly of programming Python RSS

Found the source of SegFaults on AMD + FreeGLUT

So the source of the segfaults that I'm seeing on fglrx and FreeGLUT on Kubuntu 14.04 has come to light. It's a known issue with the registration of FreeGLUT and fglrx at-exit handers (at the C level). You can work around it in your own code with PyOpenGL 3.1.0b3+ (which is still pending release) using:

        try:
            if fgDeinitialize: fgDeinitialize(False)
        except NameError as err:
            pass # Older PyOpenGL, you may see a seg-fault here...
        import sys
        sys.exit( 0 )

Where fgDeinitialize is available in the GLUT namespace.

Continue reading

Auto-generating Output Declarations

So the good news is that I've now got far more PyOpenGL output parameters automatically wrapped such that they can be passed in or automatically generated. That drops a *lot* of the manually maintained code. OpenGLContext works with the revisions, but the revision currently does *not* support non-contiguous input arrays (basically the cleanup included removing manually maintained code that said "this is an input array, so allow it to be non-contiguous"). I'll be moving the logic to doing that wrapping into the run-time eventually.

Upshot, however, is that there are a lot of changes, and while they are ...

Continue reading

Enums and Output Variables

Walter on PyOpenGL Users pointed me at the chromium "regal" tool, which has a table of constant definitions for output parameter sizings. I have a similar mechanism inside PyOpenGL's source code, so I parsed the table out of regal and used it to spot and plug gaps in the PyOpenGL table. The regal stuff is all-one-table for any COMPSIZE() value, while PyOpenGL has traditionally had many tables, one for each output-parameter... seems that could be simplified now to just use the one table, though there are definitely some corner-cases to be addressed (cases where e.g. another API call ...

Continue reading

So close on py2exe with PyOpenGL

I played with getting a py2exe executable created from PyOpenGL today, and it is very close to working.  The basics:

from distutils.core import setup
import py2exe
import glob, os
import OpenGL
data_files = [
    (
        os.path.join('OpenGL','DLLS'),
        glob.glob( os.path.join( os.path.dirname( OpenGL.__file__ ), 'DLLS', '*.*' ))
    ),
]

if __name__ == "__main__":
    setup(
        windows=['shader_test.py'],
        options={
            "py2exe": {
                "includes": [
                    "ctypes", "logging",
                    'OpenGL.platform.win32',
                ] + [
                    'OpenGL.arrays.%s'%x for x in [
                        'ctypesarrays','ctypesparameters','ctypespointers',
                        'lists','nones','numbers','numpymodule','strings','vbo'
                    ]
                ],
                'skip_archive': True,
            },
        },
        data_files = data_files,
    )

Which collects all of PyOpenGL's plugins that are applicable for use in Win32 (basically the ...

Continue reading

PyOpenGL 3.1.0b2 Available for Testing

The second (and hopefully last) beta for PyOpenGL 3.1.0 is now available. These are the changes since Beta 1. If there's nothing critical showing up I'll do a final release in a few weeks.

  • Generation fixes (lots of them) 
  • GLES/GL-only extensions should now be generated only in the appropriate directories 
  • Extensions which are multi-api will show up in each API package (note: custom wrappers are still written per-api) 
  • Freshly generated wrappers from the khronos API repository 
  • Late/lazy binding of all entry points (that is, we do not even attempt to resolve any entry point ...

Continue reading

OpenGLContext-full working on Ubuntu Again

pip's changes to not install pre-release software caught me up on my bad habit of just leaving alphas and betas of little-used packages that pass testing up as the "final" release. While I'm going to have to get that habit quashed, I've updated OpenGLContext-full in the meantime to pull the correct betas and have pushed new betas for PyVRML97 and OpenGLContext.  Long story short, you can now do:

pip install "OpenGLContext-full==3.1.0b1"

and on Ubuntu 13.10, at least, you'll get a working OpenGLContext environment.  As usual, there are some caveats, such as needing ...

Continue reading

Almost ready for a beta 2 for PyOpenGL

Went through my piled-up PyOpenGL email from the vacation and tried to address the various bugs and issues. Other than confirming a fix on hardware I don't have we should be pretty close to ready for a second beta. I regenerated the extensions based on the latest khronos api svn, so we should be pretty up-to-date, but I really need to get some GLES test cases to confirm that we do actually have basic GLES2 support working.

Continue reading

OSMesa Refactoring

We've had a binding/platform for the Off-Screen Mesa (OSMesa) library for a while now. It was originally coded such that it provided all of the OSMesa entry points from the platform package (not really appropriate, as these are the same level as things such as GLX and WGL). Long story short, they've been moved to OpenGL/osmesa instead. Code that uses OSMesa in PyOpenGL can just update the imports to

# from OpenGL.platform import *
from OpenGL.osmesa import *

to get the entry points that have moved.

Continue reading

Raspberry Pi BCM Window Needs Love

So as part of getting a PyOpenGL demo running on the Raspberry Pi I wrote a trivial subset of the Broadcom graphics interface api in ctypes.  There's an (abandoned? not very recent, anyway) full wrapper in Cython, but even getting that compiled just took too long for me working on the Pi (far longer than writing a ctypes wrapper).

The little wrapper module needs work to be usable, but I don't really have the interest needed to do what needs to make it truly useful.  What really seems to be needed is to take the 5 or 6 ...

Continue reading

GL Arrogance Cleanup is Significant

There were (and still are) lots of places where PyOpenGL code assumed (assumes) that it is running GL. So far my cleanup efforts mean that on importing e.g. GLES1 you don't actually trigger a load of OpenGL. They also mean that most DLLs are lazy-loaded, something that means e.g. GLUT should no longer load on every PyOpenGL import.  However, a lot of the helper code is still GL-arrogant, and that includes such basic things as the array handlers (which import OpenGL to get access to constants, etc) and the VBO module, which has a pluggable implementation, but ...

Continue reading