示例#1
0
    def display(self):
	GL.glClearColor( 0.0, 0.0, 0.0, 0.0)
	GL.glClear( GL.GL_COLOR_BUFFER_BIT)
	GL.glColor3f( 1.0,1.0,0.0)
	self.x = self.x + self.move_x
	self.y = self.y + self.move_y
	self.age = self.age + 1
	which = Numeric.greater( self.age, MAX_AGE)
	self.x = Numeric.choose( which, (self.x, RandomArray.random( NUMDOTS)))
	selfy = Numeric.choose( which, (self.y, RandomArray.random( NUMDOTS)))
	self.age = Numeric.choose( which, (self.age, 0))
	self.x = Numeric.choose( Numeric.greater( self.x, 1.0), (self.x, self.x - 1.0)) 
	self.y = Numeric.choose( Numeric.greater( self.y, 1.0), (self.y, self.y - 1.0))
	x2 = RandomArray.random( NUMDOTS2)
	y2 = RandomArray.random( NUMDOTS2)
	v = Numeric.concatenate(
		(Numeric.transpose( Numeric.array( [self.x, self.y])),
		 Numeric.transpose( Numeric.array( [self.x - 0.005, self.y + 0.005])),
		 Numeric.transpose( Numeric.array( [self.x + 0.005, self.y - 0.005])),
		 Numeric.transpose( Numeric.array( [x2, y2]))))
        #from opengltk.util import GLdouble
        #av = bufarray.readArray( v, GLdouble)
	#GL.glVertexPointer( 2, av)
        GL.glVertexPointer( 2, v)
	GL.glEnableClientState( GL.GL_VERTEX_ARRAY)
	#glplus.DrawArrays( GL.POINTS, len( av))
        from opengltk import  glplus
        glplus.DrawArrays( GL.GL_POINTS, len( v))
	#GL.glDisableClientState( GL.VERTEX_ARRAY)
	GL.glFlush()
	GLUT.glutSwapBuffers()
示例#2
0
    def Draw(self):
        if __debug__:
            if hasattr(DejaVu, 'functionName'): DejaVu.functionName()

            GL.glEnable(GL.GL_AUTO_NORMAL)
            GL.glEnable(GL.GL_NORMALIZE)

            if self.theNurb is None:
                self.theNurb = GLU.gluNewNurbsRenderer()

                GLU.gluNurbsProperty(self.theNurb, GLU.GLU_SAMPLING_TOLERANCE,
                                     25.0)
                GLU.gluNurbsProperty(self.theNurb, GLU.GLU_DISPLAY_MODE,
                                     GLU.GLU_OUTLINE_POLYGON)
                GLU.gluNurbsCallback(self.theNurb, GLU.GLU_ERROR,
                                     self.nurbsError)

            GLU.gluBeginSurface(self.theNurb)
            _glulib.gluNurbsSurface(self.theNurb, 8, self.knots, 8, self.knots,
                                    4 * 3, 3, self.ctlpoints, 4, 4,
                                    GL.GL_MAP2_VERTEX_3)

            GLU.gluEndSurface(self.theNurb)

            GL.glPointSize(5.0)
            GL.glDisable(GL.GL_LIGHTING)
            GL.glColor3f(1.0, 1.0, 0.0)
            GL.glBegin(GL.GL_POINTS)
            for i in range(4):
                for j in range(4):
                    GL.glVertex3fv(self.ctlpoints[i][j])

            GL.glEnd()
            GL.glDisable(GL.GL_AUTO_NORMAL)
            GL.glDisable(GL.GL_NORMALIZE)
示例#3
0
 def display(self):
        GL.glClear( GL.GL_COLOR_BUFFER_BIT)
        GL.glColor3f( 1.0, 1.0, 1.0)
        GL.glLoadIdentity()             # clear the matrix 
        # viewing transformation 
        GLU.gluLookAt( 0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0)
        GL.glScalef( 1.0, 2.0, 1.0)      # modeling transformation 
        GLUT.glutWireCube( 1.0)
        GL.glFlush()
示例#4
0
    def redraw(self):
        """ redraw the Material editor opengl sphere that shows the effect
of the modifications
"""
        if __debug__:
            if hasattr(DejaVu, 'functionName'): DejaVu.functionName()

        self.tk.call(self._w, 'makecurrent')
        GL.glClearColor(0, 0, 0, 0)
        self.initProjection()
        self.Configure()
        GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
        """ draw the black background squares """
        GL.glDisable(GL.GL_LIGHTING)
        GL.glColor3f(0.1, 0.1, 0.1)
        GL.glBegin(GL.GL_QUADS)
        GL.glVertex3f(-2, 0, 2)
        GL.glVertex3f(-2, 2, 2)
        GL.glVertex3f(0, 2, 2)
        GL.glVertex3f(0, 0, 2)
        GL.glEnd()
        GL.glBegin(GL.GL_QUADS)
        GL.glVertex3f(0, -2, 2)
        GL.glVertex3f(0, 0, 2)
        GL.glVertex3f(2, 0, 2)
        GL.glVertex3f(2, -2, 2)
        GL.glEnd()
        """ draw the grey background squares """
        GL.glColor3f(0.3, 0.3, 0.3)
        GL.glBegin(GL.GL_QUADS)
        GL.glVertex3f(-2, -2, 2)
        GL.glVertex3f(-2, 0, 2)
        GL.glVertex3f(0, 0, 2)
        GL.glVertex3f(0, -2, 2)
        GL.glEnd()
        GL.glBegin(GL.GL_QUADS)
        GL.glVertex3f(0, 0, 2)
        GL.glVertex3f(0, 2, 2)
        GL.glVertex3f(2, 2, 2)
        GL.glVertex3f(2, 0, 2)
        GL.glEnd()
        """ enable the sphere transparancy """
        GL.glEnable(GL.GL_BLEND)
        GL.glDepthMask(GL.GL_FALSE)
        GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)
        """ draw the sphere """
        #GL.glEnable(GL.GL_LIGHTING)
        if self.viewer is not None:
            self.viewer.enableOpenglLighting()
        self.setMaterial()
        extractedGlutSolidSphere(1.6, 30, 30, 0)
示例#5
0
    def display(self):
        GL.glClear(GL.GL_COLOR_BUFFER_BIT)

        # select white for all lines
        GL.glColor3f(1.0, 1.0, 1.0)

        # in 1st row, 3 lines, each with a different stipple
        GL.glEnable(GL.GL_LINE_STIPPLE)

        GL.glLineStipple(1, 0x0101)  #  dotted
        self.drawOneLine(50.0, 125.0, 150.0, 125.0)
        GL.glLineStipple(1, 0x00FF)  #  dashed
        self.drawOneLine(150.0, 125.0, 250.0, 125.0)
        GL.glLineStipple(1, 0x1C47)  #  dash/dot/dash
        self.drawOneLine(250.0, 125.0, 350.0, 125.0)

        # in 2nd row, 3 wide lines, each with different stipple
        GL.glLineWidth(5.0)
        GL.glLineStipple(1, 0x0101)  #  dotted
        self.drawOneLine(50.0, 100.0, 150.0, 100.0)
        GL.glLineStipple(1, 0x00FF)  #  dashed
        self.drawOneLine(150.0, 100.0, 250.0, 100.0)
        GL.glLineStipple(1, 0x1C47)  #  dash/dot/dash
        self.drawOneLine(250.0, 100.0, 350.0, 100.0)
        GL.glLineWidth(1.0)

        # in 3rd row, 6 lines, with dash/dot/dash stipple
        # as part of a single connected line strip
        GL.glLineStipple(1, 0x1C47)  # dash/dot/dash
        GL.glBegin(GL.GL_LINE_STRIP)
        try:
            for i in range(0, 7):
                GL.glVertex2f(50.0 + (i * 50.0), 75.0)
        finally:
            GL.glEnd()

        # in 4th row, 6 independent lines with same stipple  */
        for i in range(0, 6):
            self.drawOneLine(50.0 + (i * 50.0), 50.0, 50.0 + ((i + 1) * 50.0),
                             50.0)

        # in 5th row, 1 line, with dash/dot/dash stipple
        # and a stipple repeat factor of 5
        GL.glLineStipple(5, 0x1C47)  #  dash/dot/dash
        self.drawOneLine(50.0, 25.0, 350.0, 25.0)

        GL.glDisable(GL.GL_LINE_STIPPLE)
        GL.glFlush()
    def display(self):
        GL.glClear( GL.GL_COLOR_BUFFER_BIT)

        # select white for all lines
        GL.glColor3f( 1.0, 1.0, 1.0)

        # in 1st row, 3 lines, each with a different stipple
        GL.glEnable( GL.GL_LINE_STIPPLE)

        GL.glLineStipple( 1, 0x0101)  #  dotted  
        self.drawOneLine( 50.0, 125.0, 150.0, 125.0)
        GL.glLineStipple( 1, 0x00FF)  #  dashed 
        self.drawOneLine( 150.0, 125.0, 250.0, 125.0);
        GL.glLineStipple( 1, 0x1C47)  #  dash/dot/dash
        self.drawOneLine( 250.0, 125.0, 350.0, 125.0)

        # in 2nd row, 3 wide lines, each with different stipple 
        GL.glLineWidth( 5.0)
        GL.glLineStipple( 1, 0x0101)  #  dotted 
        self.drawOneLine( 50.0, 100.0, 150.0, 100.0)
        GL.glLineStipple( 1, 0x00FF)  #  dashed
        self.drawOneLine( 150.0, 100.0, 250.0, 100.0)
        GL.glLineStipple( 1, 0x1C47)  #  dash/dot/dash
        self.drawOneLine( 250.0, 100.0, 350.0, 100.0)
        GL.glLineWidth( 1.0)

        # in 3rd row, 6 lines, with dash/dot/dash stipple  
        # as part of a single connected line strip        
        GL.glLineStipple( 1, 0x1C47)  # dash/dot/dash
        GL.glBegin( GL.GL_LINE_STRIP)
        try:
            for i in range( 0, 7):
                GL.glVertex2f( 50.0 + (i * 50.0), 75.0)
        finally:
            GL.glEnd()

        # in 4th row, 6 independent lines with same stipple  */
        for i in range( 0, 6):
            self.drawOneLine( 50.0 + (i * 50.0), 50.0, 50.0 + ((i+1) * 50.0), 50.0)

        # in 5th row, 1 line, with dash/dot/dash stipple 
        # and a stipple repeat factor of 5               
        GL.glLineStipple( 5, 0x1C47)  #  dash/dot/dash 
        self.drawOneLine( 50.0, 25.0, 350.0, 25.0)

        GL.glDisable( GL.GL_LINE_STIPPLE)
        GL.glFlush()
    def redraw(self):
        """ redraw the Material editor opengl sphere that shows the effect
of the modifications
"""
        if __debug__:
         if hasattr(DejaVu, 'functionName'): DejaVu.functionName()

        self.tk.call(self._w, 'makecurrent')
        GL.glClearColor(0,0,0,0)
        self.initProjection()
        self.Configure()
        GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)

        """ draw the black background squares """
        GL.glDisable( GL.GL_LIGHTING )
        GL.glColor3f( 0.1, 0.1, 0.1 )
        GL.glBegin(GL.GL_QUADS)
        GL.glVertex3f(-2, 0, 2); GL.glVertex3f(-2, 2, 2)
        GL.glVertex3f( 0, 2, 2); GL.glVertex3f( 0, 0, 2)
        GL.glEnd()
        GL.glBegin(GL.GL_QUADS)
        GL.glVertex3f( 0,-2, 2); GL.glVertex3f( 0, 0, 2)
        GL.glVertex3f( 2, 0, 2); GL.glVertex3f( 2,-2, 2)
        GL.glEnd()

        """ draw the grey background squares """
        GL.glColor3f( 0.3, 0.3, 0.3 )
        GL.glBegin(GL.GL_QUADS)
        GL.glVertex3f(-2,-2, 2); GL.glVertex3f(-2, 0, 2)
        GL.glVertex3f( 0, 0, 2); GL.glVertex3f( 0,-2, 2)
        GL.glEnd()
        GL.glBegin(GL.GL_QUADS)
        GL.glVertex3f( 0, 0, 2); GL.glVertex3f( 0, 2, 2)
        GL.glVertex3f( 2, 2, 2); GL.glVertex3f( 2, 0, 2)
        GL.glEnd()

        """ enable the sphere transparancy """
        GL.glEnable(GL.GL_BLEND)
        GL.glDepthMask(GL.GL_FALSE)
        GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)

        """ draw the sphere """
        #GL.glEnable(GL.GL_LIGHTING)
        if self.viewer is not None:
            self.viewer.enableOpenglLighting()
        self.setMaterial()
        extractedGlutSolidSphere(1.6, 30, 30, 0)
示例#8
0
    def redraw(self):
        if __debug__:
            if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
        self.tk.call(self._w, 'makecurrent')

        GL.glDisable(GL.GL_DEPTH_TEST)
        GL.glDisable(GL.GL_LIGHTING)
        #GL.glPolygonMode(GL.GL_FRONT, GL.GL_FILL)
        GL.glBegin(GL.GL_QUADS)
        GL.glColor3f(0., 0., 0.)
        GL.glVertex2f(0., 1.)
        GL.glVertex2f(0., 0.)
        GL.glColor3f(float(self.rgbMax[0]), float(self.rgbMax[1]),
                     float(self.rgbMax[2]))
        GL.glVertex2f(1., 0.)
        GL.glVertex2f(1., 1.)
        GL.glEnd()

        GL.glEnable(GL.GL_COLOR_LOGIC_OP)
        GL.glLogicOp(GL.GL_XOR)
        GL.glLineWidth(2)
        GL.glColor3f(.5, .5, .5)
        GL.glBegin(GL.GL_LINES)
        x1 = self.v - 0.01
        x2 = self.v + 0.01
        GL.glVertex2f(float(x1), 1.)
        GL.glVertex2f(float(x1), 0.)
        GL.glVertex2f(float(x2), 0.)
        GL.glVertex2f(float(x2), 1.)
        GL.glEnd()
        GL.glDisable(GL.GL_COLOR_LOGIC_OP)
    def redraw(self):
        if __debug__:
         if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
        self.tk.call(self._w, 'makecurrent')

        GL.glDisable( GL.GL_DEPTH_TEST )
        GL.glDisable( GL.GL_LIGHTING )
        #GL.glPolygonMode(GL.GL_FRONT, GL.GL_FILL)
        GL.glBegin(GL.GL_QUADS)
        GL.glColor3f(0.,0.,0.)
        GL.glVertex2f(0., 1.); GL.glVertex2f(0., 0.)
        GL.glColor3f(float(self.rgbMax[0]),float(self.rgbMax[1]),float(self.rgbMax[2]))
        GL.glVertex2f( 1., 0.); GL.glVertex2f( 1., 1.)
        GL.glEnd()

        GL.glEnable(GL.GL_COLOR_LOGIC_OP)
        GL.glLogicOp(GL.GL_XOR)
        GL.glLineWidth(2)
        GL.glColor3f(.5,.5,.5)
        GL.glBegin(GL.GL_LINES)
        x1 = self.v-0.01
        x2 = self.v+0.01
        GL.glVertex2f(float(x1), 1.); GL.glVertex2f(float(x1), 0.)
        GL.glVertex2f(float(x2), 0.); GL.glVertex2f(float(x2), 1.)
        GL.glEnd()
        GL.glDisable(GL.GL_COLOR_LOGIC_OP)
示例#10
0
    def Draw(self):
        if __debug__:
         if hasattr(DejaVu, 'functionName'): DejaVu.functionName()

         GL.glEnable(GL.GL_AUTO_NORMAL)
         GL.glEnable(GL.GL_NORMALIZE)
         
         if self.theNurb is None:         
             self.theNurb = GLU.gluNewNurbsRenderer()

             GLU.gluNurbsProperty(self.theNurb, GLU.GLU_SAMPLING_TOLERANCE,
                                  25.0)
             GLU.gluNurbsProperty(self.theNurb, GLU.GLU_DISPLAY_MODE,
                                  GLU.GLU_OUTLINE_POLYGON)
             GLU.gluNurbsCallback(self.theNurb, GLU.GLU_ERROR, self.nurbsError)

         GLU.gluBeginSurface(self.theNurb)
         _glulib.gluNurbsSurface( self.theNurb,
                                  8, self.knots,
                                  8, self.knots,
                                  4*3,
                                  3,
                                  self.ctlpoints,
                                  4, 4,
                                  GL.GL_MAP2_VERTEX_3)

         GLU.gluEndSurface(self.theNurb)

         
         GL.glPointSize(5.0)
         GL.glDisable(GL.GL_LIGHTING)
         GL.glColor3f(1.0, 1.0, 0.0)
         GL.glBegin(GL.GL_POINTS)
         for i in range(4):
             for j in range(4):
                 GL.glVertex3fv(self.ctlpoints[i][j]) 

         GL.glEnd()
         GL.glDisable(GL.GL_AUTO_NORMAL)
         GL.glDisable(GL.GL_NORMALIZE)
示例#11
0
 def triangle(self):
     GL.glBegin(GL.GL_TRIANGLES)
     try:
         GL.glColor3f(1.0, 0.0, 0.0)
         GL.glVertex2f(5.0, 5.0)
         GL.glColor3f(0.0, 1.0, 0.0)
         GL.glVertex2f(25.0, 5.0)
         GL.glColor3f(0.0, 0.0, 1.0)
         GL.glVertex2f(5.0, 25.0)
     finally:
         GL.glEnd()
 def triangle(self):
    GL.glBegin( GL.GL_TRIANGLES)
    try:
        GL.glColor3f( 1.0, 0.0, 0.0)
        GL.glVertex2f( 5.0, 5.0)
        GL.glColor3f( 0.0, 1.0, 0.0)
        GL.glVertex2f( 25.0, 5.0)
        GL.glColor3f( 0.0, 0.0, 1.0)
        GL.glVertex2f( 5.0, 25.0)
    finally:
        GL.glEnd()
示例#13
0
 def test_0032(self ):
     import Tkinter
     root = Tkinter.Tk()
     vi = OGLTkWidget(root)
     GL.glBegin( GL.GL_TRIANGLES)
     GL.glColor3f( 1.0, 0.0, 0.0)
     GL.glVertex2f( 5.0, 5.0)
     GL.glColor3f( 0.0, 1.0, 0.0)
     GL.glVertex2f( 25.0, 5.0)
     GL.glColor3f( 0.0, 0.0, 1.0)
     GL.glVertex2f( 5.0, 25.0)
     GL.glEnd()
     root.after(500, root.quit )
     root.mainloop()
     root.destroy()
示例#14
0
 def redraw(self):
     GL.glColor3f( 0., 0., 0. )
     GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)