Package: python-cg
What is python-cg?python-cgis a Python wrapper forNVidia Cg Toolkitruntime. I’ve started it because I like Python, I like NVidia CG and I want to to do some computer game/3d graphicsprototyping and research. Also I still find C++ counterproductive as far as my needs are concerned and I don’t want to waste my time doing boring stuff. Programming in Python is fun.I know about some projects that were meant to bring CG to Python but as far as I know they’re history now.Project is hostead at GitHub:https://github.com/jstasiak/python-cg.What’s the state?The project is in very early development stage. Overview of what’s supported right now:Cg contextscreatingdestroyingCgFX effectscreating from filecreating directly from source codeaccessing effects` techniques and their passesaccessing effect parameters with their names, semantics and parameter-specific metadata (rows, columns etc.)setting sampler parameters and most of numerical parametersWhat doesn’t work at the moment and there’s no plan to implement it:everything that’s left (well, until I decide I need some of it or someone else does that)RequirementsThis project requires:NVidia Cg Toolkit ≥ 3.0Python interpreter (+ development files):2.x ≥ 2.6, or3.x ≥ 3.2C and C++ compilerPython packages required to build and installpython-cg:Cython ≥ 0.18numpyTo build documentation/run tests you also need:Mock ≥ 1.0Nose ≥ 1.2Sphinx ~ 1.2 (development version)DocumentationPregenerated documentation can be found athttps://python-cg.readthedocs.org/en/latest/.You can also build documentation all by yourself by calling:sphinx-build -b html docs docs/build/htmlGenerated HTML files are placed indocs/build/html/directory.BuildingTo build the project in place, run:python setup.py build_ext --inplaceImportant informationThis project works with OpenGL and OpenGL onlyIt uses row-major matrices by default, just like numpy doesQuickstartFirst you need to create an instance ofCGclass and use it to create newContext:from cg import CG

cg = CG()
context = cg.create_context()We want to use an effect to render some stuff so we’re gonna createEffectfrom file:effect = context.create_effect_from_file('effect.cgfx')NoteThis assumes that you have a file namedeffect.cgfxand that it contains
a valid CG effect.We now have access to Effect’s techniques and parameters:for technique in effect.techniques:
   # ...

for parameter in effect.parameters:
   # ...For the sake of simplicity let’s say we have a parameterless effect with only oneTechnique:technique = effect.techniques[0]Now we can access technique’s passes. EachPasshas methodsbegin()andend()and the actual
drawing has to take place between a call tobeginandend:gl.glClear(gl.GL_COLOR_BUFFER_BIT)

for pass_  in technique.passes:
   pass_.begin()


   gl.glBegin(gl.GL_TRIANGLES)
   gl.glVertex3f(-0.5, -0.5, 0)
   gl.glVertex3f(0.5, -0.5, 0)
   gl.glVertex3f(0, 0.5, 0)
   gl.glEnd()

   pass_.end()

# swap buffersYou can find complete, runnable example application inexampledirectory. Please note that
it requires (in addition topython-cgrequirements):Development version of SFML 2Python packages listed inexample/requirements.txt:pip install -r example/requirements.txtThen to run the example:python setup.py build_ext --inplace
PYTHONPATH=. python example/main.pyTestingTo run tests, execute:python runtests.pyLicense© 2013, Jakub StasiakThis project is licensed under MIT License, seeLICENSEfile for details.