Files
PlantAI-dev/tools/pymol-open-source/examples/devel/gl01.py
T
2026-08-03 18:42:47 +08:00

40 lines
732 B
Python

from OpenGL.GL import *
from OpenGL.GL.ARB.vertex_buffer_object import *
from pymol.callback import Callback
from pymol import cmd
# this is a trivial example of creating a callback object which
# makes OpenGL calls using the PyOpenGL bindings
# define a callback object
class myCallback(Callback):
def __call__(self):
glBegin(GL_LINES)
glColor3f(1.0,1.0,1.0)
glVertex3f(0.0,0.0,0.0)
glVertex3f(1.0,0.0,0.0)
glVertex3f(0.0,0.0,0.0)
glVertex3f(0.0,2.0,0.0)
glVertex3f(0.0,0.0,0.0)
glVertex3f(0.0,0.0,3.0)
glEnd()
def get_extent(self):
return [[0.0,0.0,0.0],[1.0,2.0,3.0]]
# load it into PyMOL
cmd.load_callback(myCallback(),'gl01')