Maciej Kalisiak wrote:
>Hello all,
>
>For the longest time I've been using the following method to import
>OpenGL functions and constants:
>
> from OpenGL.GL import *
>
>After starting to use pydoc to make documentation of my code, I came to
>realize how badly this pollutes the namespace (and makes huge HTML
>files). I'm also recently concerned that this is seriously slowing down
>my app's startup time on old HW.
>
>In view of this I looked at alternatives. Thought of two. Either
>
> from OpenGL.GL import glBegin, glVertex3f, glEnd, GL_LINES
> # ... and whatever else is used in module
>
>or
>
> import OpenGL.GL as GL
>
> GL.glBegin(GL.GL_LINES)
> GL.glVertex3f(0,0,0)
> GL.glVertex3f(1,1,1)
> GL.glEnd()
>
>I'm unhappy with both methods. Method 1 makes for long import lines,
>and you end up invariably running into unimported names as they get used
>in the code. The second method is also error-prone, as it is quite easy
>to forget the prefix each time you add a block of OpenGL code.
>
>Surely this is an old problem, and someone on the list can deliver me
>from my misery by showing me the "one, true, perfect" method, no? :)
>
>
>
Hey,
A more environmentally friendly way is to make a module where you import
the functions you use most often.
So you could do:
from my_gl_funcs import *
If that polutes, maybe get a muffler.
|