File: opengl_thread.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 (53 lines) | stat: -rw-r--r-- 1,015 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
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)


###########################################
glutInit("mainwin")  

# IMPORTANT: create window in the mainloop - thread!

## not working:
#win_geom = Window( name=b"ngs", drawfunc=mydraw, mousefunc=mymouse)

def runVisualization():
## working:
    win_geom = Window( name=b"ngs", drawfunc=mydraw, mousefunc=mymouse)
    glutMainLoop()

# create thread
from threading import Thread
thread = Thread(target = runVisualization)        
thread.start()
thread.join()