File: opengl.py

package info (click to toggle)
netgen 6.2.2501%2Bdfsg1-12
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 12,980 kB
  • sloc: cpp: 165,197; tcl: 6,310; python: 2,804; sh: 522; makefile: 87
file content (74 lines) | stat: -rw-r--r-- 1,676 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from netgen.csg import *
import netgen.meshing as meshing
import libvisual

from OpenGL.GLUT import *

# import Window class from other file
from opengl_window import Window

sp1 = Sphere (Pnt(0,0,0), 0.2)
sp2 = Sphere (Pnt(0.5,0,0), 0.2)
all = sp1+sp2

geom = CSGeometry()
geom.Add (all)

param = meshing.MeshingParameters()
param.maxh = 0.1
m1 = GenerateMesh (geom, param)

vis = VS(geom)


# window callback functions
def mydraw():
    vis.Draw()
    glutSwapBuffers()

def mymouse(xold, yold, x, y, mode):
    MouseMove(vis,xold,yold, x,y, mode)

# init glut and create window
glutInit("mainwin")
win_geom = Window( name=b"ngs", drawfunc=mydraw, mousefunc=mymouse)

###########################################
# press ctrl+c to break loop
while(True):
    for i in range(10000):
        glutMainLoopEvent()
        print('press ctrl+c to create second window!')

###########################################
# create second window (transformation matrices are shared)
vismesh = libvisual.meshvis.VS(m1)
def mydraw2():
    vismesh.Draw()
    glutSwapBuffers()

win_mesh = Window( name=b"ngs2", drawfunc=mydraw2, mousefunc=mymouse)

###########################################
# press ctrl+c to break loop
try:
    while(True):
        for i in range(10000):
            glutMainLoopEvent()
        print('press ctrl+c to hide/destroy first window!')
except:
    pass

###########################################

## BREAKS (on numericus) as soon as mouse touches remaining window ("Error of failed request:  GLXBadContextTag")
# glutDestroyWindow(win_geom.handle)

## WORKS
glutHideWindow(win_geom.handle)

try:
    while(True):
        glutMainLoopEvent()
except:
    pass