picogl.examples.utils.molecular_glut_window

Shared GLUT molecular viewer: atoms as points, bonds as lines.

Used by modern_molecular_viewer.py and modern_pdb_picogl_simple.py. Never draws atom positions through ObjectRenderer / GL_TRIANGLES (that produces triangle soup).

Attributes

_EXAMPLES_DIR

_PICOGL_ROOT

_ELMO_ROOT_CANDIDATES

_ELMO_ROOT

_ELMO_GLSL

_ATOM_POINT_SIZE

_MOLECULAR_GLSL_DIR

Classes

MolecularViewer

Load a PDB and expose PicoGL meshes + optional molecular shaders.

MolecularRenderWindow

GLUT window that draws atoms as points and bonds as lines.

Functions

_molecular_shader_directory() → pathlib.Path

Prefer ElMo molecular GLSL tree when present; else PicoGL shader src.

_mesh_vertex_count(mesh) → int

_build_mesh_vao(mesh) → picogl.backend.modern.core.vertex.array.object.VertexArrayObject

Upload positions + colours for non-indexed glDrawArrays.

_enable_blending() → None

Soft circular points need blending for the smoothstep rim.

Module Contents

picogl.examples.utils.molecular_glut_window._EXAMPLES_DIR[source]
picogl.examples.utils.molecular_glut_window._PICOGL_ROOT[source]
picogl.examples.utils.molecular_glut_window._ELMO_ROOT_CANDIDATES[source]
picogl.examples.utils.molecular_glut_window._ELMO_ROOT[source]
picogl.examples.utils.molecular_glut_window._ELMO_GLSL[source]
picogl.examples.utils.molecular_glut_window._ATOM_POINT_SIZE = 6.0[source]
picogl.examples.utils.molecular_glut_window._MOLECULAR_GLSL_DIR[source]
picogl.examples.utils.molecular_glut_window._molecular_shader_directory() → pathlib.Path[source]

Prefer ElMo molecular GLSL tree when present; else PicoGL shader src.

class picogl.examples.utils.molecular_glut_window.MolecularViewer(pdb_path: str)[source]

Load a PDB and expose PicoGL meshes + optional molecular shaders.

pdb_path[source]
pdb_loader = None[source]
atom_data = None[source]
bond_data = None[source]
_center[source]
_extent = 50.0[source]
shader_registry[source]
_shaders_loaded = False[source]
ensure_shaders_loaded() → None[source]

Compile shaders once an OpenGL context exists.

_load_structure() → None[source]
_load_shaders() → None[source]
create_atom_mesh() → picogl.renderer.MeshData[source]
create_bond_mesh() → picogl.renderer.MeshData[source]
export_molviewspec(output_path: str) → None[source]
picogl.examples.utils.molecular_glut_window._mesh_vertex_count(mesh: picogl.renderer.MeshData) → int[source]
picogl.examples.utils.molecular_glut_window._build_mesh_vao(mesh: picogl.renderer.MeshData) → picogl.backend.modern.core.vertex.array.object.VertexArrayObject[source]

Upload positions + colours for non-indexed glDrawArrays.

picogl.examples.utils.molecular_glut_window._enable_blending() → None[source]

Soft circular points need blending for the smoothstep rim.

class picogl.examples.utils.molecular_glut_window.MolecularRenderWindow(molecular_viewer: MolecularViewer, **kwargs)[source]

Bases: picogl.ui.backend.glut.window.object.RenderWindow

GLUT window that draws atoms as points and bonds as lines.

molecular_viewer[source]
atom_mesh[source]
bond_mesh[source]
atom_vao: picogl.backend.modern.core.vertex.array.object.VertexArrayObject | None = None[source]
bond_vao: picogl.backend.modern.core.vertex.array.object.VertexArrayObject | None = None[source]
atom_point_shader: picogl.backend.modern.core.shader.program.ShaderProgram | None = None[source]
_gl_ready = False[source]
zoom_distance[source]
distance_threshold[source]
initializeGL() → None[source]

Load bond shaders only; do not upload atom mesh for triangle drawing.

initialize() → None[source]
run() → None[source]

run

_load_atom_point_shader() → None[source]

Circular point sprites (gl_PointCoord discard + soft edge).

_setup_molecular_rendering() → None[source]
paintGL() → None[source]

Clear, then bonds (lines) and atoms (points) — never triangles.

_bond_shader()[source]

Prefer ObjectRenderer tu01; fall back to ElMo bonds if needed.

_bind_uniforms(shader, kind: str | None) → None[source]
_render_atoms() → None[source]

Draw atoms as smooth circular GL_POINTS.

_render_bonds() → None[source]