mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-11 21:50:34 +05:00
opengl
This commit is contained in:
parent
ece18134d1
commit
e456fce948
@ -1,12 +1,20 @@
|
|||||||
from netgen.csg import *
|
from netgen.csg import *
|
||||||
import netgen.meshing as meshing
|
import netgen.meshing as meshing
|
||||||
|
|
||||||
|
from OpenGL.GL import *
|
||||||
|
from OpenGL.GLU import *
|
||||||
|
from OpenGL.GLUT import *
|
||||||
|
|
||||||
sp1 = Sphere (Point3d(1,0,0), 1)
|
|
||||||
sp2 = Sphere (Point3d(2,0,0), 1)
|
|
||||||
|
|
||||||
both = Or(sp1, sp2)
|
|
||||||
all = And (both, OrthoBrick ( Point3d(0,0,0), Point3d (3,0.5,1)))
|
sp1 = Sphere (Pnt(0,0,0), 0.2)
|
||||||
|
sp2 = Sphere (Pnt(0.5,0,0), 0.2)
|
||||||
|
sp3 = Sphere (Pnt(0,0,0.5), 0.2)
|
||||||
|
sp4 = Sphere (Pnt(0,0.2,0.7), 0.2)
|
||||||
|
sp5 = Sphere (Pnt(0,0,0.3), 0.2)
|
||||||
|
|
||||||
|
|
||||||
|
all = sp1+sp2+sp3+sp4+sp5
|
||||||
|
|
||||||
|
|
||||||
geom = CSGeometry()
|
geom = CSGeometry()
|
||||||
@ -14,7 +22,57 @@ geom.Add (all)
|
|||||||
|
|
||||||
|
|
||||||
vis = VS(geom)
|
vis = VS(geom)
|
||||||
vis.Draw()
|
# vis.Draw()
|
||||||
|
|
||||||
|
|
||||||
|
window = 0 # glut window number
|
||||||
|
width, height = 500, 500
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def mydraw():
|
||||||
|
|
||||||
|
glViewport(0, 0, width, height);
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
|
pnear = 0.1;
|
||||||
|
pfar = 10;
|
||||||
|
|
||||||
|
gluPerspective(20.0, 1.0*width / height, pnear, pfar);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
||||||
|
# glLoadIdentity()
|
||||||
|
# gluLookAt (0, 0, 6, 0, 0, 0, 0, 1, 0);
|
||||||
|
|
||||||
|
## glBegin(GL_QUADS)
|
||||||
|
## glColor4d(0.0, 1.0, 0.0, 0.0);
|
||||||
|
## glVertex3d(0.0,0.0,0.7)
|
||||||
|
## glVertex3d(1.0,0.0,2.1)
|
||||||
|
## glColor4d(1.0, 1.0, 1.0, 0.0);
|
||||||
|
## glVertex3d(1.0,1.0,0.2)
|
||||||
|
## glVertex3d(0.0,1.0,0.5)
|
||||||
|
## glEnd()
|
||||||
|
|
||||||
|
vis.Draw()
|
||||||
|
|
||||||
|
glutSwapBuffers()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
glutInit("mainwin") # initialize glut
|
||||||
|
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH)
|
||||||
|
glutInitWindowSize(width, height) # set window size
|
||||||
|
glutInitWindowPosition(0, 0) # set window position
|
||||||
|
window = glutCreateWindow(b"ngs") # create window with title
|
||||||
|
#glutDisplayFunc(vis.Draw) # set draw function callback
|
||||||
|
glutIdleFunc(mydraw) # draw all the time
|
||||||
|
glutMainLoop()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# param = meshing.MeshingParameters(maxh=0.2)
|
# param = meshing.MeshingParameters(maxh=0.2)
|
||||||
|
@ -31,35 +31,10 @@ width, height = 500, 500
|
|||||||
|
|
||||||
|
|
||||||
def mydraw():
|
def mydraw():
|
||||||
|
|
||||||
glViewport(0, 0, width, height);
|
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glLoadIdentity();
|
|
||||||
|
|
||||||
pnear = 0.1;
|
|
||||||
pfar = 10;
|
|
||||||
|
|
||||||
gluPerspective(20.0, 1.0*width / height, pnear, pfar);
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
|
||||||
# glLoadIdentity()
|
|
||||||
# gluLookAt (0, 0, 6, 0, 0, 0, 0, 1, 0);
|
|
||||||
|
|
||||||
## glBegin(GL_QUADS)
|
|
||||||
## glColor4d(0.0, 1.0, 0.0, 0.0);
|
|
||||||
## glVertex3d(0.0,0.0,0.7)
|
|
||||||
## glVertex3d(1.0,0.0,2.1)
|
|
||||||
## glColor4d(1.0, 1.0, 1.0, 0.0);
|
|
||||||
## glVertex3d(1.0,1.0,0.2)
|
|
||||||
## glVertex3d(0.0,1.0,0.5)
|
|
||||||
## glEnd()
|
|
||||||
|
|
||||||
vis.Draw()
|
vis.Draw()
|
||||||
|
|
||||||
glutSwapBuffers()
|
glutSwapBuffers()
|
||||||
|
|
||||||
|
|
||||||
xold = -1;
|
xold = -1;
|
||||||
yold = -1;
|
yold = -1;
|
||||||
mode = 'r'
|
mode = 'r'
|
||||||
@ -69,6 +44,7 @@ def myMotionHandler( x, y ):
|
|||||||
MouseMove(vis,xold,yold, x,y, mode) # 'm','z'
|
MouseMove(vis,xold,yold, x,y, mode) # 'm','z'
|
||||||
xold = x
|
xold = x
|
||||||
yold = y
|
yold = y
|
||||||
|
mydraw()
|
||||||
|
|
||||||
def myPassiveMotionHandler( x, y ):
|
def myPassiveMotionHandler( x, y ):
|
||||||
global xold, yold
|
global xold, yold
|
||||||
@ -92,11 +68,25 @@ glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH)
|
|||||||
glutInitWindowSize(width, height) # set window size
|
glutInitWindowSize(width, height) # set window size
|
||||||
glutInitWindowPosition(0, 0) # set window position
|
glutInitWindowPosition(0, 0) # set window position
|
||||||
window = glutCreateWindow(b"ngs") # create window with title
|
window = glutCreateWindow(b"ngs") # create window with title
|
||||||
|
|
||||||
glutMotionFunc(myMotionHandler)
|
glutMotionFunc(myMotionHandler)
|
||||||
glutMouseFunc(myMouseHandler)
|
glutMouseFunc(myMouseHandler)
|
||||||
glutPassiveMotionFunc(myPassiveMotionHandler)
|
glutPassiveMotionFunc(myPassiveMotionHandler)
|
||||||
glutDisplayFunc(mydraw) # set draw function callback
|
glutDisplayFunc(mydraw) # set draw function callback
|
||||||
glutIdleFunc(mydraw) # draw all the time
|
# glutIdleFunc(mydraw) # draw all the time
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
pnear = 0.1;
|
||||||
|
pfar = 10;
|
||||||
|
gluPerspective(20.0, 1.0*width / height, pnear, pfar);
|
||||||
|
glViewport(0, 0, width, height);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glutMainLoop()
|
glutMainLoop()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user