Esempio n. 1
1
    def initialize_enter(self):
        """
        Implements the GLNodeAdapter's initialize_enter method for an OpenGL Initialization operation.
        """
        GL.glClearColor(0.25, 0.28, 0.31, 1.0)
        GL.glClearDepth(1.0)

        # Polygon Rasterization
        GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL)

        # Polygon Anti-Aliasing
        GL.glEnable(GL.GL_POLYGON_SMOOTH)

        # Light Shading
        GL.glShadeModel(GL.GL_SMOOTH)

        # Enable Back Face Culling
        GL.glEnable(GL.GL_CULL_FACE)
        GL.glCullFace(GL.GL_BACK)

        # Enable Depth Testing
        GL.glEnable(GL.GL_DEPTH_TEST)
        GL.glDepthFunc(GL.GL_LEQUAL)
        GL.glDepthMask(GL.GL_TRUE)

        # Misc
        GL.glDisable(GL.GL_FOG)
        GL.glDisable(GL.GL_TEXTURE_2D)
Esempio n. 2
1
    def initializeGL(self):
        """Init"""
        self.qglClearColor(self.gl_bg_color.darker())

        #GL.glShadeModel(GL.GL_FLAT)
        GL.glEnable(GL.GL_DEPTH_TEST)

        GL.glClearDepth(1.0)

        #Fix up the lines to be cleaner...
        GL.glEnable(GL.GL_LINE_SMOOTH)
        GL.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_NICEST)
        GL.glLineWidth(0.1)
        GL.glEnable(GL.GL_BLEND)
        GL.glEnable(GL.GL_MULTISAMPLE)
        GL.glEnable(GL.GL_LIGHTING)
        GL.glEnable(GL.GL_LIGHT0)
        GL.glEnable(GL.GL_NORMALIZE)
        GL.glEnable(GL.GL_LIGHT1)

        GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)


        GL.glEnable(GL.GL_COLOR_MATERIAL)

        GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_DIFFUSE, [0.6, 0.6, 0.6, 1.0])
        GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT, [0.3, 0.3, 0.3, 1.0])
        GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SPECULAR, [0.5, 0.5, 0.5, 1.0])
        GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SHININESS, 10.0)
        GL.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE)
        GL.glLightModeli(
                GL.GL_LIGHT_MODEL_COLOR_CONTROL,
                GL.GL_SINGLE_COLOR
                )
        GL.glLightModeli(GL.GL_LIGHT_MODEL_TWO_SIDE, 1)
Esempio n. 3
1
    def display(self):
        GL.glClearColor(0.0, 0.0, 0.0, 0.0)
        GL.glClearDepth(1.0)
        GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)

        self.armature.draw(self)

        glfw.SwapBuffers()
Esempio n. 4
1
def initGL(window):
    gl.glClearColor(0.40,0.58,0.93,1.0) #cornflower blue

    gl.glClearDepth(1.0) #Enables Clearing Of The Depth Buffer
    gl.glDepthFunc(gl.GL_LESS) #The Type Of Depth Test To Do
    gl.glEnable(gl.GL_DEPTH_TEST) #Enables Depth Testing

    gl.glShadeModel(gl.GL_SMOOTH) #Enables Smooth Color Shading

    on_window_size(window, window_width, window_height)
Esempio n. 5
0
    def render(self, pickmode):
        GL.glViewport(0, 0, self.width, self.height)
        GL.glClearDepth(1.0)
        GL.glEnable(GL.GL_DEPTH_TEST)

        GL.glClearColor(0.3, 0.3, 0.3, 1.0)
        GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)

        perspective_m = self.create_perspective_matrix()
        camera_m = self.create_camera_matrix(True)
        view_m = perspective_m * camera_m

        program = self.shaders[1]
        program.bind()

        program.enableAttributeArray("qt_Vertex")
        program.enableAttributeArray("qt_Normal")
        program.setUniformValue("qt_ModelViewProjectionMatrix", view_m)
        program.setUniformValue("qt_NormalMatrix", camera_m.normalMatrix())

        program.enableAttributeArray("qt_Vertex")
        for render_item in self.render_items:
            self.draw_item(program, render_item)

        program.release()
Esempio n. 6
0
def initGL(window):
    global stars
    LoadTextures()

    gl.glEnable(gl.GL_TEXTURE_2D)
    gl.glShadeModel(gl.GL_SMOOTH) #Enables Smooth Color Shading

    gl.glClearColor(0.0,0.0,0.0,1.0) #black
    #gl.glClearColor(0.40,0.58,0.93,1.0) #cornflower blue
    gl.glClearDepth(1.0) #Enables Clearing Of The Depth Buffer

    gl.glHint(gl.GL_PERSPECTIVE_CORRECTION_HINT, gl.GL_NICEST) #Really Nice Perspective
    gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE) #Set The Blending Function For Translucency
    gl.glEnable(gl.GL_BLEND) #Enables Depth Testing

    for index in range(num):
        star = Star()
        star.angle = 0.0 #Start All The Stars At Angle Zero
        star.dist = (index / num) * 5.0
        star.r = random.randrange(1, 256, 1)
        star.g = random.randrange(1, 256, 1)
        star.b = random.randrange(1, 256, 1)
        stars.append(star)

    on_window_size(window, window_width, window_height)
Esempio n. 7
0
    def initialize_enter(self):
        """
        Implements the GLNodeAdapter's initialize_enter method for an OpenGL Initialization operation.
        """
        GL.glClearColor(0.25, 0.28, 0.31, 1.0)
        GL.glClearDepth(1.0)

        # Polygon Rasterization
        GL.glPolygonMode( GL.GL_FRONT_AND_BACK, GL.GL_FILL)

        # Polygon Anti-Aliasing
        GL.glEnable( GL.GL_POLYGON_SMOOTH )

        # Light Shading
        GL.glShadeModel( GL.GL_SMOOTH )

        # Enable Back Face Culling
        GL.glEnable( GL.GL_CULL_FACE )
        GL.glCullFace( GL.GL_BACK )

        # Enable Depth Testing
        GL.glEnable( GL.GL_DEPTH_TEST )
        GL.glDepthFunc( GL.GL_LEQUAL )
        GL.glDepthMask( GL.GL_TRUE )

        # Misc
        GL.glDisable( GL.GL_FOG )
        GL.glDisable( GL.GL_TEXTURE_2D )
Esempio n. 8
0
    def initializeGL(self):  # , width=1, height=1
        """ Initialization of the GL frame. """
        # TODO: glOrtho should set to size of the frame which would allow using
        # TODO: absolute coordinates in range/domain of original frame
        GL.glClearColor(0.0, 0.0, 0.0, 1.0)
        GL.glClearDepth(1.0)
        GL.glOrtho(0, 1, 1, 0, -1, 1)
        #glOrtho(0, width, height, 0, -1, 1)  # DOESN'T WORK!!
        GL.glMatrixMode(GL.GL_PROJECTION)

        # Enable rational alpha blending
        GL.glEnable(GL.GL_BLEND)
        GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)

        if self.anti_aliasing:
            # Points
            GL.glEnable(GL.GL_POINT_SMOOTH)
            GL.glHint(GL.GL_POINT_SMOOTH_HINT, GL.GL_NICEST)

            # Lines
            GL.glEnable(GL.GL_LINE_SMOOTH)
            GL.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_NICEST)

            # Polygons, but NOT GL_TRIANGLE_FAN
            GL.glEnable(GL.GL_POLYGON_SMOOTH)
            GL.glHint(GL.GL_POLYGON_SMOOTH_HINT, GL.GL_NICEST)

            # Not sure...
            GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST)
Esempio n. 9
0
    def init_gl(width, height):
        """A general OpenGL initialization function.

        Sets all of the initial parameters.
        This is called right after our OpenGL window is created.
        :param width: window width
        :param height: window height
        """
        # This Will Clear The Background Color To Black
        gl.glClearColor(0.0, 0.0, 0.0, 0.0)

        # Enables Clearing Of The Depth Buffer
        gl.glClearDepth(1.0)

        # The Type Of Depth Test To Do
        gl.glDepthFunc(gl.GL_LESS)
        # Enables Depth Testing
        gl.glEnable(gl.GL_DEPTH_TEST)
        # Enables Smooth Color Shading
        gl.glShadeModel(gl.GL_SMOOTH)

        # Reset The Projection Matrix.
        gl.glMatrixMode(gl.GL_PROJECTION)

        # Calculate The Aspect Ratio Of The Window.
        gl.glLoadIdentity()
        glu.gluPerspective(45.0, float(width) / float(height), 0.1, 100.0)

        gl.glMatrixMode(gl.GL_MODELVIEW)
Esempio n. 10
0
    def initializeGL(self):  # , width=1, height=1
        """ Initialization of the GL frame. """
        # TODO: glOrtho should set to size of the frame which would allow using
        # TODO: absolute coordinates in range/domain of original frame
        GL.glClearColor(0.0, 0.0, 0.0, 1.0)
        GL.glClearDepth(1.0)
        GL.glOrtho(0, 1, 1, 0, -1, 1)
        #glOrtho(0, width, height, 0, -1, 1)  # DOESN'T WORK!!
        GL.glMatrixMode(GL.GL_PROJECTION)

        # Enable rational alpha blending
        GL.glEnable(GL.GL_BLEND)
        GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)

        if self.anti_aliasing:
            # Points
            GL.glEnable(GL.GL_POINT_SMOOTH)
            GL.glHint(GL.GL_POINT_SMOOTH_HINT, GL.GL_NICEST)

            # Lines
            GL.glEnable(GL.GL_LINE_SMOOTH)
            GL.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_NICEST)

            # Polygons, but NOT GL_TRIANGLE_FAN
            GL.glEnable(GL.GL_POLYGON_SMOOTH)
            GL.glHint(GL.GL_POLYGON_SMOOTH_HINT, GL.GL_NICEST)

            # Not sure...
            GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST)
Esempio n. 11
0
def resize(x,y):
    global sw, sh, sw2, sh2, screen
    screen = pygame.display.set_mode((x,y), DOUBLEBUF | RESIZABLE | OPENGL)
    sw=x
    sh=y
    sw2=x/2
    sh2=y/2
    GL.glViewport(0, 0, sw, sh)
    GL.glMatrixMode(GL.GL_PROJECTION)
    GL.glLoadIdentity()
    #gluPerspective(45, 1.0*sw/sh, 0.1, 2000.0)
    GL.glOrtho(-sw2,sw2,-sh2,sh2,-2000,2000)
    GL.glMatrixMode(GL.GL_MODELVIEW)
    GL.glLoadIdentity()

    GL.glShadeModel(GL.GL_SMOOTH)
    GL.glClearColor(0.5, 0.5, 0.5, 0.0)
    GL.glClearDepth(1.0)
    GL.glEnable(GL.GL_DEPTH_TEST)
    GL.glDepthFunc(GL.GL_LEQUAL)
    GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST)

    GL.glEnable(GL.GL_TEXTURE_2D)
    GL.glEnable(GL.GL_BLEND)
    GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)
    GL.glClear(GL.GL_COLOR_BUFFER_BIT|GL.GL_DEPTH_BUFFER_BIT)
Esempio n. 12
0
    def glinit(self,mode=None):
        if mode:
            self.rendermode = mode

        self.clear()
        #GL.glClearColor(*colors.RGBA(self.default.bgcolor))# Clear The Background Color
        GL.glClearDepth(1.0)	       # Enables Clearing Of The Depth Buffer
        GL.glDepthFunc(GL.GL_LESS)	       # The Type Of Depth Test To Do
        GL.glEnable(GL.GL_DEPTH_TEST)	       # Enables Depth Testing
        #GL.glEnable(GL.GL_CULL_FACE)
        

        # On initializing a rendering mode, we also set default lighting
        if self.rendermode == 'wireframe':
            glFlat()
            glLine()
            self.lighting = False
            self.glLight(False)

                
        elif self.rendermode.startswith('flat'):
            glFlat()
            glFill()
            self.lighting = False
            self.glLight(False)
               
        elif self.rendermode.startswith('smooth'):
            glSmooth()
            glFill()
            self.lighting = True
            self.glLight(True)
            
        else:
            raise RuntimeError,"Unknown rendering mode"
Esempio n. 13
0
    def __init__(self, lnkpath=None):
        self.logger = logging.getLogger(logger.name + "." + type(self).__name__)
        self.zoom = -7.0  # distance to camera (zoom)
        self.textures = []
        self.rd = [1.9, 0.0, -0.5]  # right delta
        self.ld = [-1.9, 0.0, -0.5]  # left delta
        self.t = 0  # for transitions between images
        self.s = 0  # for transitions between images
        self.ndx = 0  # start by showing the first image
        self._lastgame = None

        self.lnkpath = lnkpath

        self.lastgamepath = os.path.join(self.lnkpath, ".lastgame")
        self.gamelist = self.get_gamelist()
        self.logger.debug("Init CoverFlow with %d games" % self.gamecount())

        # opengl stuff
        gl.glEnable(gl.GL_TEXTURE_2D)
        self.load_textures()

        gl.glShadeModel(gl.GL_SMOOTH)
        gl.glClearColor(0.0, 0.0, 0.0, 0.0)
        gl.glClearDepth(1.0)
        gl.glEnable(gl.GL_DEPTH_TEST)
        gl.glDepthFunc(gl.GL_LEQUAL)
        gl.glHint(gl.GL_PERSPECTIVE_CORRECTION_HINT, gl.GL_NICEST)
        gl.glEnable(gl.GL_LIGHT1)
Esempio n. 14
0
    def __init__(self):
        pygame.init()
        pygame.display.gl_set_attribute(pygame.locals.GL_SWAP_CONTROL, 0)
        self.screen = pygame.display.set_mode((constants.sw, constants.sh),
                pygame.locals.OPENGL | pygame.locals.DOUBLEBUF)
        # Make certain our GL setup is clean to start out.
        GL.glLoadIdentity()
        GL.glPushMatrix()
        GL.glLoadIdentity()
        GL.glViewport(0, 0, constants.sw, constants.sh)
        GL.glMatrixMode(GL.GL_PROJECTION)
        GL.glLoadIdentity()
        GL.glOrtho(0, constants.sw, 0, constants.sh, 1, 0)
        GL.glMatrixMode(GL.GL_MODELVIEW)
        GL.glLoadIdentity()

        GL.glEnable(GL.GL_TEXTURE_2D)
        GL.glEnable(GL.GL_BLEND)
        GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)

        # Disable antialiasing -- our textures are already antialiased (blended
        # with transparent) and GL's interpolation just makes things look bad.
        GL.glDisable(GL.GL_LINE_SMOOTH)
        GL.glShadeModel(GL.GL_SMOOTH)
        GL.glClearColor(0, 0, 0, 1)
        GL.glClearDepth(1)
        GL.glEnable(GL.GL_DEPTH_TEST)
        GL.glDepthFunc(GL.GL_LEQUAL)
        GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST)

        self.splashSurface = pygame.image.load(os.path.join(constants.otherPath, 'splashscreen.png'))
        self.texture = self.makeTextureFromSurface(self.splashSurface)
        
        self.font = pygame.font.Font(os.path.join(constants.fontPath, 'MODENINE.TTF'), 18)
        self.messageTextureId = None
Esempio n. 15
0
def glInit(): 
  OGLUT.glutInit()  # initialize the GLUT library.
  OGLUT.glutInitDisplayMode(OGLUT.GLUT_DOUBLE | OGLUT.GLUT_RGB |OGLUT.GLUT_DEPTH) # initial display mode
  OGL.glShadeModel(OGL.GL_SMOOTH) # Enable Smooth Shading
  OGL.glClearColor(0.0, 0.0, 0.0, 0.0) # Black Background
	
  OGL.glClearDepth(1.0) # Depth Buffer Setup
  OGL.glEnable(OGL.GL_DEPTH_TEST) # Enables Depth Testing
  OGL.glDepthFunc(OGL.GL_LEQUAL) # The Type Of Depth Testing To Do
  OGL.glHint(OGL.GL_PERSPECTIVE_CORRECTION_HINT, OGL.GL_NICEST) # Really Nice Perspective Calculations
	
  objCamera.Position_Camera(10, 4, 12,   9, 4, 12,   0, 1, 0) # Set Camera Position
	
  LoadVertices()
	
  OGL.glViewport(0,0,SCREEN_SIZE[0],SCREEN_SIZE[1]) # Reset The Current Viewport
  OGL.glMatrixMode(OGL.GL_PROJECTION)
  OGL.glLoadIdentity()
	
  # Calculate The Aspect Ratio Of The Window
  OGLU.gluPerspective(45.0, SCREEN_SIZE[0]/SCREEN_SIZE[1], 0.1, 100.0)
  OGL.glMatrixMode(OGL.GL_MODELVIEW)
	
  OGL.glCullFace(OGL.GL_BACK) # Don't draw the back sides of polygons
  OGL.glEnable(OGL.GL_CULL_FACE) # Turn on culling
Esempio n. 16
0
def main():    
    GLUT.glutInit(argv)
    GLUT.glutInitDisplayMode(GLUT.GLUT_DOUBLE | GLUT.GLUT_RGBA | GLUT.GLUT_DEPTH | GLUT.GLUT_MULTISAMPLE)
    larguraTela = GLUT.glutGet(GLUT.GLUT_SCREEN_WIDTH)
    alturaTela = GLUT.glutGet(GLUT.GLUT_SCREEN_HEIGHT)
    larguraJanela = round(2 * larguraTela / 3)
    alturaJanela = round(2 * alturaTela / 3)
    GLUT.glutInitWindowSize(larguraJanela, alturaJanela)
    GLUT.glutInitWindowPosition(round((larguraTela - larguraJanela) / 2), round((alturaTela - alturaJanela) / 2))
    GLUT.glutCreateWindow(janela)
    GLUT.glutDisplayFunc(draw)
    load()
    GL.glEnable(GL.GL_MULTISAMPLE)
    GL.glEnable(GL.GL_DEPTH_TEST)
    GL.glEnable(GL.GL_TEXTURE_2D)
    GL.glClearColor(*corFundo)
    GL.glClearDepth(1.0)
    GL.glDepthFunc(GL.GL_LESS)
    GL.glShadeModel(GL.GL_SMOOTH)
    GL.glMatrixMode(GL.GL_PROJECTION)
    GLU.gluPerspective(-45, larguraJanela / alturaJanela, 0.1, 100.0)
    GL.glTranslatef(0.0, 0.0, -10)
    GL.glMatrixMode(GL.GL_MODELVIEW)
    GLUT.glutTimerFunc(10, timer, 1)
    GLUT.glutMainLoop()
Esempio n. 17
0
    def initgl(self):
        """Initialize OpenGL for use in the window."""
        import OpenGL.GL as gl
        import OpenGL.GLU as glu
        self.load_textures()
        gl.glEnable(gl.GL_TEXTURE_2D)
        gl.glClearColor(0.0, 0.0, 0.0, 0.0)
                        # This Will Clear The Background Color To Black
        gl.glClearDepth(
            1.0)                    # Enables Clearing Of The Depth Buffer
        gl.glDepthFunc(
            gl.GL_LESS)                      # The Type Of Depth Test To Do
        gl.glEnable(gl.GL_DEPTH_TEST)                   # Enables Depth Testing
        gl.glShadeModel(
            gl.GL_SMOOTH)                   # Enables Smooth Color Shading

        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glLoadIdentity()                     # Reset The Projection Matrix
        # Calculate The Aspect Ratio Of The Window
        (width, height) = self.canvas.GetClientSize()
        glu.gluPerspective(45.0, float(width) / float(height), 0.1, 100.0)

        gl.glMatrixMode(gl.GL_MODELVIEW)

        gl.glLightfv(gl.GL_LIGHT0, gl.GL_AMBIENT, (0.5, 0.5, 0.5,
                     1.0))  # Setup The Ambient Light
        gl.glLightfv(gl.GL_LIGHT0, gl.GL_DIFFUSE, (1.0, 1.0, 1.0,
                     1.0))  # Setup The Diffuse Light
        gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, (0.0, 0.0, 2.0,
                     1.0))        # Position The Light
        gl.glEnable(gl.GL_LIGHT0)
Esempio n. 18
0
def initGL(window):
    global lightAmbient, lightDiffuse, lightPosition
    LoadTextures()

    gl.glEnable(gl.GL_TEXTURE_2D)
    gl.glShadeModel(gl.GL_SMOOTH) #Enables Smooth Color Shading

    gl.glClearColor(0.40,0.58,0.93,1.0) #cornflower blue
    gl.glClearDepth(1.0) #Enables Clearing Of The Depth Buffer

    gl.glEnable(gl.GL_DEPTH_TEST) #Enables Depth Testing
    gl.glDepthFunc(gl.GL_LEQUAL) #The Type Of Depth Test To Do
    gl.glHint(gl.GL_PERSPECTIVE_CORRECTION_HINT, gl.GL_NICEST) #Really Nice Perspective

    gl.glEnable(gl.GL_LIGHTING)
    gl.glEnable(gl.GL_LIGHT1)

    gl.glLightfv(gl.GL_LIGHT1, gl.GL_AMBIENT, lightAmbient) #Setup The Ambient Light
    gl.glLightfv(gl.GL_LIGHT1, gl.GL_DIFFUSE, lightDiffuse) #Setup The Diffuse Light
    gl.glLightfv(gl.GL_LIGHT1, gl.GL_POSITION, lightPosition) #Position The Light

    gl.glColor4f(1.0,1.0,1.0,0.5) #Full Brightness, 50% Alpha
    gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE) #Blending Function For Translucency Based On Source Alpha 

    on_window_size(window, window_width, window_height)
Esempio n. 19
0
    def InitGL( self ):
        gl.glMatrixMode(gl.GL_PROJECTION)
        # camera frustrum setup
        gl.glFrustum(-0.5, 0.5, -0.5, 0.5, 1, 10.0)
        gl.glMaterial(gl.GL_FRONT, gl.GL_AMBIENT, [0.2, 0.2, 0.2, 1.0])
        gl.glMaterial(gl.GL_FRONT, gl.GL_DIFFUSE, [0.8, 0.8, 0.8, 1.0])
        gl.glMaterial(gl.GL_FRONT, gl.GL_SPECULAR, [1.0, 0.0, 1.0, 1.0])
        gl.glMaterial(gl.GL_FRONT, gl.GL_SHININESS, 50.0)
        gl.glLight(gl.GL_LIGHT0, gl.GL_AMBIENT, [1.0, 1.0, 1.0, 1.0])
        gl.glLight(gl.GL_LIGHT0, gl.GL_DIFFUSE, [1.0, 1.0, 1.0, 1.0])
        gl.glLight(gl.GL_LIGHT0, gl.GL_SPECULAR, [1.0, 1.0, 1.0, 1.0])
        gl.glLight(gl.GL_LIGHT0, gl.GL_POSITION, [1.0, 1.0, 1.0, 0.0])
        gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, [0.2, 0.2, 0.2, 1.0])
        gl.glEnable(gl.GL_LIGHTING)
        gl.glEnable(gl.GL_LIGHT0)
        gl.glDepthFunc(gl.GL_LESS)

        gl.glClearDepth(1.0) # enables clearing of the depth buffer?
        gl.glShadeModel(gl.GL_SMOOTH)

        gl.glEnable(gl.GL_DEPTH_TEST)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
        # position viewer
        gl.glMatrixMode(gl.GL_MODELVIEW)
        # position viewer
        gl.glTranslate(0.0, 0.0, -3.0);
        #
        glut.glutInit(sys.argv)
Esempio n. 20
0
    def glinit(self,mode=None):
        if mode:
            self.rendermode = mode
	GL.glClearColor(*colors.RGBA(self.bgcolor))# Clear The Background Color
	GL.glClearDepth(1.0)	       # Enables Clearing Of The Depth Buffer
	GL.glDepthFunc(GL.GL_LESS)	       # The Type Of Depth Test To Do
	GL.glEnable(GL.GL_DEPTH_TEST)	       # Enables Depth Testing
        if self.rendermode == 'wireframe':
            GL.glShadeModel(GL.GL_FLAT)      # Enables Flat Color Shading
            GL.glDisable(GL.GL_LIGHTING)
        elif self.rendermode == 'flat':
            GL.glShadeModel(GL.GL_FLAT)      # Enables Flat Color Shading
            GL.glDisable(GL.GL_LIGHTING)
        elif self.rendermode == 'smooth':
            GL.glShadeModel(GL.GL_SMOOTH)    # Enables Smooth Color Shading
            GL.glEnable(GL.GL_LIGHTING)
            for l,i in zip(['light0','light1'],[GL.GL_LIGHT0,GL.GL_LIGHT1]):
                key = 'render/%s' % l
                light = GD.cfg.get(key,self.default_light)
                GD.debug("  set up %s %s" % (l,light))
                GL.glLightModel(GL.GL_LIGHT_MODEL_AMBIENT,rgba(GD.cfg['render/ambient']))
                GL.glLightModel(GL.GL_LIGHT_MODEL_TWO_SIDE, GL.GL_TRUE)
                GL.glLightModel(GL.GL_LIGHT_MODEL_LOCAL_VIEWER, 0)
                GL.glLightfv(i,GL.GL_AMBIENT,rgba(light['ambient']))
                GL.glLightfv(i,GL.GL_DIFFUSE,rgba(light['diffuse']))
                GL.glLightfv(i,GL.GL_SPECULAR,rgba(light['specular']))
                GL.glLightfv(i,GL.GL_POSITION,rgba(light['position']))
                GL.glEnable(i)
            GL.glMaterialfv(GL.GL_FRONT_AND_BACK,GL.GL_SPECULAR,rgba(GD.cfg['render/specular']))
            GL.glMaterialfv(GL.GL_FRONT_AND_BACK,GL.GL_EMISSION,rgba(GD.cfg['render/emission']))
            GL.glMaterialfv(GL.GL_FRONT_AND_BACK,GL.GL_SHININESS,GD.cfg['render/shininess'])
            GL.glColorMaterial(GL.GL_FRONT_AND_BACK,GL.GL_AMBIENT_AND_DIFFUSE)
            GL.glEnable(GL.GL_COLOR_MATERIAL)
        else:
            raise RuntimeError,"Unknown rendering mode"
Esempio n. 21
0
    def gl_initialize(self):
        r, g, b = self.viewer.img_bg
        gl.glClearColor(r, g, b, 1.0)
        gl.glClearDepth(1.0)

        gl.glDisable(gl.GL_CULL_FACE)
        gl.glFrontFace(gl.GL_CCW)
        gl.glDisable(gl.GL_LIGHTING)
        gl.glShadeModel(gl.GL_FLAT)
        #gl.glShadeModel(gl.GL_SMOOTH)

        self.setup_3D(self.mode3d)

        gl.glEnable(gl.GL_TEXTURE_2D)
        gl.glPixelStorei(gl.GL_UNPACK_ALIGNMENT, 1)
        self.tex_id = gl.glGenTextures(1)
        gl.glBindTexture(gl.GL_TEXTURE_2D, self.tex_id)
        ## gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S,
        ##                    gl.GL_CLAMP)
        ## gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T,
        ##                    gl.GL_CLAMP)
        gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER,
                           gl.GL_NEAREST)
        gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER,
                           gl.GL_NEAREST)
Esempio n. 22
0
    def initializeGL(self):
        """Init"""
        self.qglClearColor(self.gl_bg_color.darker())

        #GL.glShadeModel(GL.GL_FLAT)
        GL.glEnable(GL.GL_DEPTH_TEST)

        GL.glClearDepth(1.0)

        #Fix up the lines to be cleaner...
        GL.glEnable(GL.GL_LINE_SMOOTH)
        GL.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_NICEST)
        GL.glLineWidth(0.1)
        GL.glEnable(GL.GL_BLEND)
        GL.glEnable(GL.GL_MULTISAMPLE)
        GL.glEnable(GL.GL_LIGHTING)
        GL.glEnable(GL.GL_LIGHT0)
        GL.glEnable(GL.GL_NORMALIZE)
        GL.glEnable(GL.GL_LIGHT1)

        GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)

        GL.glEnable(GL.GL_COLOR_MATERIAL)

        GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_DIFFUSE,
                        [0.6, 0.6, 0.6, 1.0])
        GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT,
                        [0.3, 0.3, 0.3, 1.0])
        GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SPECULAR,
                        [0.5, 0.5, 0.5, 1.0])
        GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SHININESS, 10.0)
        GL.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE)
        GL.glLightModeli(GL.GL_LIGHT_MODEL_COLOR_CONTROL, GL.GL_SINGLE_COLOR)
        GL.glLightModeli(GL.GL_LIGHT_MODEL_TWO_SIDE, 1)
Esempio n. 23
0
    def __init__(self, args):
        os.environ["SDL_VIDEO_CENTERED"] = "1"

        pygame.init()

        self._font = pygame.font.Font(os.path.join(ROOT_DIR, "..", "..", "assets", "VeraMono.ttf"), 14)
        self._font.set_bold(True)

        self._running = True
        self._screen = pygame.display.set_mode(VIEWPORT_SIZE, pygame.OPENGL | pygame.DOUBLEBUF)
        self._clock = pygame.time.Clock()
        self._image = GL.glGenTextures(1)

        GL.glClearDepth(1.)
        GL.glClearColor(0., 0., 0., 1.)
        GL.glViewport(0, 0, VIEWPORT_SIZE[0], VIEWPORT_SIZE[1])

        GL.glMatrixMode(GL.GL_PROJECTION)
        GL.glLoadIdentity()
        GL.glOrtho(0, VIEWPORT_SIZE[0], VIEWPORT_SIZE[1], 0, -1, 1)

        GL.glMatrixMode(GL.GL_MODELVIEW)
        GL.glLoadIdentity()
        GL.glDisable(GL.GL_LIGHTING)
        GL.glEnable(GL.GL_TEXTURE_2D)
Esempio n. 24
0
    def draw_with_transform(self, transform):
        program_handler = ProgramHandler(self.get_vert_sources(),
                                         self.get_frag_sources())
        program = program_handler.compile()

        GL.glClearColor(0.0, 0.0, 0.0, 0.0)
        GL.glClearDepth(1.0)
        GL.glDepthFunc(GL.GL_LESS)
        GL.glEnable(GL.GL_DEPTH_TEST)
        GL.glShadeModel(GL.GL_SMOOTH)

        GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)

        GL.glUseProgram(program)

        do_transpose = OpenGL.GL.GL_TRUE
        uniform_loc = GL.glGetUniformLocation(program, 'transform')
        GL.glUniformMatrix4fv(uniform_loc, 1, do_transpose, transform)

        GL.glBegin(GL.GL_QUADS)
        GL.glVertex2f(-1.0, 1.0)
        GL.glVertex2f(1.0, 1.0)
        GL.glVertex2f(1.0, -1.0)
        GL.glVertex2f(-1.0, -1.0)
        GL.glEnd()
Esempio n. 25
0
    def glinit(self,mode="wireframe"):
	GL.glClearColor(*RGBA(self.bgcolor))# Clear The Background Color
	GL.glClearDepth(1.0)	       # Enables Clearing Of The Depth Buffer
	GL.glDepthFunc(GL.GL_LESS)	       # The Type Of Depth Test To Do
	GL.glEnable(GL.GL_DEPTH_TEST)	       # Enables Depth Testing
        if mode == "wireframe":
            self.wireframe = True
            GL.glShadeModel(GL.GL_FLAT)      # Enables Flat Color Shading
            GL.glDisable(GL.GL_LIGHTING)
        elif mode == "render":
            self.wireframe = False
            GL.glShadeModel(GL.GL_SMOOTH)    # Enables Smooth Color Shading
            #print "set up lights"
            GL.glLightModel(GL.GL_LIGHT_MODEL_AMBIENT,(0.5,0.5,0.5,1))
            GL.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, (1.0, 1.0, 1.0, 1.0))
            GL.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, (1.0, 1.0, 1.0, 1.0))
            GL.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, (1.0, 1.0, 1.0, 1.0))
            GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, (-1.0, -1.0, 5.0))
            GL.glEnable(GL.GL_LIGHT0)
            GL.glLightfv(GL.GL_LIGHT1, GL.GL_AMBIENT, (0.0, 0.0, 0.0, 1.0))
            GL.glLightfv(GL.GL_LIGHT1, GL.GL_DIFFUSE, (1.0, 1.0, 1.0, 1.0))
            GL.glLightfv(GL.GL_LIGHT1, GL.GL_SPECULAR, (1.0, 1.0, 1.0, 1.0))
            GL.glLightfv(GL.GL_LIGHT1, GL.GL_POSITION, (1.0, 1.0, 1.0))
            GL.glEnable(GL.GL_LIGHT1)
            GL.glEnable(GL.GL_LIGHTING)
            #print "set up materials"
            GL.glEnable(GL.GL_COLOR_MATERIAL)
            GL.glColorMaterial ( GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE )
Esempio n. 26
0
 def initializeGL(self):
     gl.glShadeModel(gl.GL_SMOOTH)
     gl.glClearColor(BGCOL[0], BGCOL[1], BGCOL[2], 0)
     gl.glClearDepth(1.0)
     gl.glEnable(gl.GL_DEPTH_TEST)
     gl.glDepthFunc(gl.GL_LEQUAL)
     gl.glHint(gl.GL_PERSPECTIVE_CORRECTION_HINT, gl.GL_NICEST)
Esempio n. 27
0
 def init_gl(self):
     gl.glClearColor(0,0,0,0)
     gl.glClearDepth(1.0)
     gl.glViewport(0,0,WND_SIZE[0], WND_SIZE[1])
     gl.glMatrixMode(gl.GL_PROJECTION)
     gl.glEnable(gl.GL_TEXTURE_2D)
     gl.glLoadIdentity()
Esempio n. 28
0
def init() :
    gl.glClearColor(0.0, 0.0, 0.0, 0.0)
    gl.glClearDepth(1.0)
    gl.glShadeModel(gl.GL_FLAT)
    gl.glShadeModel(gl.GL_SMOOTH)
    gl.glEnable(gl.GL_LIGHTING)
    gl.glEnable(gl.GL_LIGHT0)
    gl.glEnable(gl.GL_DEPTH_TEST)
Esempio n. 29
0
    def initializeGL(self):
        self._background_color = [0.0, 0.0, 0.0, 1.0]
        GL.glEnable(GL.GL_MULTISAMPLE)

        GL.glClearColor(*self._background_color)
        GL.glClearDepth(1.0)

        self._setup_renderers()
Esempio n. 30
0
    def initializeGL(self):
        '''
		 Sets up the OpenGL rendering context, defines display lists, etc. 
		 Gets called once before the first time resizeGL() or paintGL() is called.
		'''
        GL.glClearDepth(1.0)
        GL.glClearColor(0, 0, 0, 1.0)
        GL.glEnable(GL.GL_DEPTH_TEST)
Esempio n. 31
0
 def initializeGL(self):
     '''
      Sets up the OpenGL rendering context, defines display lists, etc. 
      Gets called once before the first time resizeGL() or paintGL() is called.
     '''
     GL.glClearDepth(1.0)
     GL.glClearColor(0, 0, 0, 1.0)
     GL.glEnable(GL.GL_DEPTH_TEST)
Esempio n. 32
0
def initGL():
    GL.glEnable(GL.GL_CULL_FACE)
    GL.glEnable(GL.GL_DEPTH_TEST)
    GL.glEnable(GL.GL_MULTISAMPLE)
    GL.glDepthFunc(GL.GL_GREATER)
    #GL.glDepthFunc(GL.GL_LESS)
    GL.glDepthRange(0, 1)
    GL.glClearDepth(0)
    GL.glClearColor(0, 0, 0, 0)
Esempio n. 33
0
 def initializeGL(self):
     GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
     GL.glClearColor(0.1, 0.1, 0.15, 1.0)
     GL.glClearDepth(1.0)
     GL.glColor3ub(58, 90, 41)
     GL.glMatrixMode(GL.GL_PROJECTION)
     GL.glLoadIdentity()
     GLU.gluOrtho2D(0, self.width, 0, self.height)
     GL.glFlush()
Esempio n. 34
0
    def initializeGL(self):

        if self.background == 'black':
            GL.glClearColor(0.0, 0.0, 0.0, 1.0)  # Black / White toggle switch
        if self.background == 'white': GL.glClearColor(1.0, 1.0, 1.0, 1.0)

        GL.glClearDepth(10.0)  # same as default
        GL.glEnable(
            GL.GL_DEPTH_TEST
        )  # display points according to occlusion, not order of plotting
        #GL.glEnable(GL.GL_POINT_SMOOTH) # doesn't seem to work right, proper way to antialiase?
        #GL.glEnable(GL.GL_LINE_SMOOTH) # works better
        #GL.glPointSize(1.5) # truncs to the nearest pixel if antialiasing is off
        #glShadeModel(GL_FLAT)
        #glEnable(GL_CULL_FACE) # only useful for solids

        if self.initial_call:
            GL.glTranslate(0, 750, -3000)  # init camera distance from origin

        #Modded transparency: blends colours in order they were plotted; otherwise need to use compiled shaders
        GL.glEnable(GL.GL_BLEND)
        GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)

        #Lighting, not alwasy used
        #GL.glEnable(GL.GL_LIGHTING)
        #GL.glEnable(GL.GL_LIGHT0)

        #lightpos = [1000.,0.,0., 1.]
        #GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, lightpos)

        #GL.glDepthMask(GL.GL_TRUE);
        #GL.glDepthFunc(GL.GL_LEQUAL);

        #LightAmbient=[0.2, 0.2, 0.2, 1.0]
        #LightDiffuse=[1.0, 1.0, 1.0, 1.0]
        #LightSpecular= [1.0, 1.0, 1.0, 1.0]
        #LightPosition= [1000.0, 1.0, 1.0]

        #GL.glEnable(GL.GL_LIGHT0)
        #GL.glEnable(GL.GL_LIGHTING)
        #GL.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, LightAmbient)
        #GL.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, LightDiffuse)
        #GL.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, LightSpecular)

        #GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, LightPosition)

        #GL.glEnable ( GL.GL_COLOR_MATERIAL )
        #GL.glColorMaterial ( GL.GL_FRONT, GL.GL_AMBIENT_AND_DIFFUSE )

        #white = [0.8, 0.8, 0.8, 1.0]
        #cyan = [0., .8, .8, 1.]
        ##GL.glMaterialfv(GL.GL_FRONT, GL.GL_DIFFUSE, cyan)
        #GL.glMaterialfv(GL.GL_FRONT, GL.GL_SPECULAR, white)
        #shininess = [100,100,100,100]
        #GL.glMaterialfv(GL.GL_FRONT, GL.GL_SHININESS, shininess)

        GL.glShadeModel(GL.GL_SMOOTH)
Esempio n. 35
0
    def initializeGL(self):
        print(self.getOpenglInfo())

        gl.glClearColor(0.0, 0.0, 0.0, 1.0)
        gl.glClearDepth(1.0)
        gl.glEnable(gl.GL_DEPTH_TEST)
        gl.glDepthFunc(gl.GL_LEQUAL)
        gl.glShadeModel(gl.GL_SMOOTH)
        gl.glHint(gl.GL_PERSPECTIVE_CORRECTION_HINT, gl.GL_NICEST)
Esempio n. 36
0
 def initializeGL(self):
     GL.glClearColor(0.0, 0.0, 0.0, 1.0) # same as default
     GL.glClearDepth(1.0) # same as default
     GL.glEnable(GL.GL_DEPTH_TEST) # display points according to occlusion, not order of plotting
     #GL.glEnable(GL.GL_POINT_SMOOTH) # doesn't seem to work right, proper way to antialiase?
     #GL.glEnable(GL.GL_LINE_SMOOTH) # works better
     #GL.glPointSize(1.5) # truncs to the nearest pixel if antialiasing is off
     #GL.glShadeModel(GL.GL_FLAT)
     #GL.glEnable(GL.GL_CULL_FACE) # only useful for solids
     GL.glTranslate(0, 0, -3) # init camera distance from origin
 def initializeGL(self):
     GL.glClearDepth(1.0)
     GL.glDepthFunc(GL.GL_LESS)
     GL.glEnable(GL.GL_DEPTH_TEST)
     GL.glMatrixMode(GL.GL_PROJECTION)
     GL.glLoadIdentity()
     GLU.gluPerspective(45, 800 / 600, 0.1, 400.0)
     GL.glTranslatef(-3.0, -3.0, -80)
     GL.glMatrixMode(GL.GL_MODELVIEW)
     GL.glEnable(GL.GL_COLOR_MATERIAL)
Esempio n. 38
0
    def initializeGL(self):
        
        if self.background=='black': GL.glClearColor(0.0, 0.0, 0.0, 1.0) # Black / White toggle switch
        if self.background=='white': GL.glClearColor(1.0, 1.0, 1.0, 1.0)

        GL.glClearDepth(10.0) # same as default
        GL.glEnable(GL.GL_DEPTH_TEST) # display points according to occlusion, not order of plotting
        #GL.glEnable(GL.GL_POINT_SMOOTH) # doesn't seem to work right, proper way to antialiase?
        #GL.glEnable(GL.GL_LINE_SMOOTH) # works better
        #GL.glPointSize(1.5) # truncs to the nearest pixel if antialiasing is off
        #glShadeModel(GL_FLAT)
        #glEnable(GL_CULL_FACE) # only useful for solids
        
        if self.initial_call: GL.glTranslate(0, 750, -3000) # init camera distance from origin

        #Modded transparency: blends colours in order they were plotted; otherwise need to use compiled shaders 
        GL.glEnable (GL.GL_BLEND)
        GL.glBlendFunc (GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);

        #Lighting, not alwasy used
        #GL.glEnable(GL.GL_LIGHTING)
        #GL.glEnable(GL.GL_LIGHT0)
        
        #lightpos = [1000.,0.,0., 1.]
        #GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, lightpos)

        #GL.glDepthMask(GL.GL_TRUE);
        #GL.glDepthFunc(GL.GL_LEQUAL);


        #LightAmbient=[0.2, 0.2, 0.2, 1.0]
        #LightDiffuse=[1.0, 1.0, 1.0, 1.0]
        #LightSpecular= [1.0, 1.0, 1.0, 1.0]
        #LightPosition= [1000.0, 1.0, 1.0]

        #GL.glEnable(GL.GL_LIGHT0)
        #GL.glEnable(GL.GL_LIGHTING)
        #GL.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, LightAmbient)
        #GL.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, LightDiffuse)
        #GL.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, LightSpecular)

        #GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, LightPosition)
         
        #GL.glEnable ( GL.GL_COLOR_MATERIAL )
        #GL.glColorMaterial ( GL.GL_FRONT, GL.GL_AMBIENT_AND_DIFFUSE )


        #white = [0.8, 0.8, 0.8, 1.0]
        #cyan = [0., .8, .8, 1.]
        ##GL.glMaterialfv(GL.GL_FRONT, GL.GL_DIFFUSE, cyan)
        #GL.glMaterialfv(GL.GL_FRONT, GL.GL_SPECULAR, white)
        #shininess = [100,100,100,100]
        #GL.glMaterialfv(GL.GL_FRONT, GL.GL_SHININESS, shininess)

        GL.glShadeModel(GL.GL_SMOOTH)
Esempio n. 39
0
 def initializeGL(self):
     GL.glClearColor(0.0, 0.0, 0.0, 1.0)  # same as default
     GL.glClearDepth(1.0)  # same as default
     # display points according to occlusion, not order of plotting:
     GL.glEnable(GL.GL_DEPTH_TEST)
     #GL.glEnable(GL.GL_POINT_SMOOTH) # doesn't seem to work right, proper way to antialiase?
     #GL.glEnable(GL.GL_LINE_SMOOTH) # works better
     #GL.glPointSize(1.5) # truncs to the nearest pixel if antialiasing is off
     #GL.glShadeModel(GL.GL_FLAT)
     #GL.glEnable(GL.GL_CULL_FACE) # only useful for solids
     GL.glTranslate(0, 0, -3)  # init camera distance from origin
Esempio n. 40
0
    def initializeGL(self):
        print(self.getOpenglInfo())

        self.setClearColor(self.trolltechPurple.darker())
        self.object = self.makeObject()
        gl.glShadeModel(gl.GL_FLAT)
        gl.glEnable(gl.GL_DEPTH_TEST)
        gl.glClearDepth(1.0)
        #gl.glEnable(gl.GL_CULL_FACE)
        gl.glEnable(gl.GL_BLEND)
        gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
Esempio n. 41
0
 def init_gl(self):
     gl.glClearColor(*self.bgColor)
     gl.glClearDepth(1.0)
     gl.glEnable(gl.GL_TEXTURE_2D)
     gl.glViewport(0,0,self.width, self.height)
     print '-'*40
     print 'GL INFO'
     print '-'*40
     print gl.glGetString(gl.GL_VERSION)
     print gl.glGetString(gl.GL_SHADING_LANGUAGE_VERSION)
     print '-'*40
Esempio n. 42
0
    def initializeGL(self):
        """Initialize the GL environment we want"""
        self.makeCurrent()

	GL.glClearColor(0.0, 0.0, 0.0, 0.0);
	GL.glClearDepth(1.0);
	GL.glDepthFunc(GL.GL_LESS);
	GL.glDisable(GL.GL_DEPTH_TEST);
	GL.glEnable(GL.GL_BLEND);
	GL.glBlendFunc (GL.GL_SRC_ALPHA, GL.GL_ONE);
	GL.glEnable(GL.GL_POINT_SMOOTH);
	GL.glEnable(GL.GL_LINE_SMOOTH);
Esempio n. 43
0
def InitGL(Width, Height):
    gl.glClearColor(0.0, 0.0, 0.0, 0.0)
    gl.glClearDepth(1.0)
    gl.glDepthFunc(gl.GL_LESS)
    gl.glEnable(gl.GL_DEPTH_TEST)
    gl.glShadeModel(gl.GL_SMOOTH)
    gl.glMatrixMode(gl.GL_PROJECTION)
    gl.glLoadIdentity()
    gl.glPerspective(45.0, float(Width) / float(Height), 0.1, 50.0)
    gl.glTranslatef(0.0, -6.0, -45.0)
    gl.glRotatef(0.0, 0.0, 0.0, 0.0)
    gl.glMatrixMode(gl.GL_MODELVIEW)
    def initializeGL(self):
        GL.glClearDepth(1.0)
        GL.glClearColor(0, 0, 0, 1.0)
        GL.glShadeModel(GL.GL_SMOOTH)
        GL.glEnable(GL.GL_DEPTH_TEST)
        GL.glEnable(GL.GL_LIGHTING)
        GL.glEnable(GL.GL_LIGHT0)
        GL.glEnable(GL.GL_COLOR_MATERIAL)

        GL.glEnable(GL.GL_LINE_SMOOTH)
        GL.glEnable(GL.GL_POLYGON_SMOOTH)
        GL.glHint(GL.GL_POLYGON_SMOOTH_HINT, GL.GL_NICEST)
Esempio n. 45
0
def main():
    GLUT.glutInit(sys.argv)
    GLUT.glutInitDisplayMode(GLUT.GLUT_SINGLE | GLUT.GLUT_RGBA
                             | GLUT.GLUT_DEPTH)
    GLUT.glutInitWindowSize(400, 400)
    GLUT.glutInitWindowPosition(200, 200)

    GLUT.glutCreateWindow("Grafica 2")
    """
    GL.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, [0.2, 0.2, 0.2, 1.0])
    GL.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, [1.0, 1.0, 1.0, 1.0])
    GL.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, [1.0, 1.0, 1.0, 1.0])
    GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, [1.0, 1.0, 1.0, 0.0])

    GL.glEnable(GL.GL_NORMALIZE)
    GL.glEnable(GL.GL_LIGHTING)
    GL.glEnable(GL.GL_LIGHT0)
    """

    GL.glDepthFunc(GL.GL_LEQUAL)
    GL.glEnable(GL.GL_DEPTH_TEST)
    GL.glClearDepth(1.0)
    GL.glClearColor(0.650, 0.780, 0.8, 0)
    GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
    GL.glMatrixMode(GL.GL_PROJECTION)
    GL.glLoadIdentity()
    #GL.glOrtho(-20, 20, -20, 20, -20, 20)
    GL.glMatrixMode(GL.GL_MODELVIEW)

    GLU.gluPerspective(100, 1.0, 1.0, 100.0)
    GL.glTranslatef(0.0, 0.0, 0.0)
    GLU.gluLookAt(0, 10, 10, 0, 0, 0, 0, 1, 0)

    grid = GR.grid_gen()
    #grid.show()

    kid.morph(youngold, 100, True)

    while True:
        GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
        grid.plot()

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

        kid.morph(youngold, 100)

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

        GL.glFlush()
        GLUT.glutPostRedisplay()
        input("Pause")

    GLUT.glutMainLoop()
Esempio n. 46
0
    def initializeGL(self):
        """Initialize the GL environment we want"""
        self.makeCurrent()

        GL.glClearColor(0.0, 0.0, 0.0, 0.0)
        GL.glClearDepth(1.0)
        GL.glDepthFunc(GL.GL_LESS)
        GL.glDisable(GL.GL_DEPTH_TEST)
        GL.glEnable(GL.GL_BLEND)
        GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE)
        GL.glEnable(GL.GL_POINT_SMOOTH)
        GL.glEnable(GL.GL_LINE_SMOOTH)
Esempio n. 47
0
    def glinit(self,mode=None):
        if mode:
            self.rendermode = mode


        ## if self.settings.bgcolor2 is not None self.settings.bgcolor != self.settings.bgcolor2:
        self.setBgColor(self.settings.bgcolor,self.settings.bgcolor2)

        self.clear()
        #GL.glClearColor(*colors.RGBA(self.default.bgcolor))# Clear The Background Color
        GL.glClearDepth(1.0)	       # Enables Clearing Of The Depth Buffer
        GL.glDepthFunc(GL.GL_LESS)	       # The Type Of Depth Test To Do
        GL.glEnable(GL.GL_DEPTH_TEST)	       # Enables Depth Testing
        #GL.glEnable(GL.GL_CULL_FACE)
        

        # On initializing a rendering mode, we also set default lighting
        if self.rendermode == 'wireframe':
            if self.background:
                glSmooth()
                glFill()
            else:
                #glFlat()
                glLine()
            self.lighting = False
            self.glLight(False)

                
        elif self.rendermode.startswith('flat'):
            if self.background:
                glSmooth()
            else:
                glFlat()
            glFill()
            self.lighting = False
            self.glLight(False)
               
        elif self.rendermode.startswith('smooth'):
            glSmooth()
            glFill()
            self.lighting = True
            self.glLight(True)
            
        else:
            raise RuntimeError,"Unknown rendering mode"


        if self.rendermode.endswith('wire'):
            GL.glEnable(GL.GL_POLYGON_OFFSET_FILL)
            GL.glPolygonOffset(1.0,1.0) 
        else:
            GL.glDisable(GL.GL_POLYGON_OFFSET_FILL)
Esempio n. 48
0
    def initializeGL(self):
        '''
        Initialize GL
        '''

        # set viewing projection
        GL.glClearColor(0.0, 0.0, 0.0, 1.0)
        GL.glClearDepth(1.0)

        GL.glMatrixMode(GL.GL_PROJECTION)
        GL.glLoadIdentity()
        GLU.gluPerspective(40.0, 1.0, 1.0, 30.0)
        self.timer.start(20)
Esempio n. 49
0
   def initGL (self, wWidth, wHeight):
      gl.glClearColor(0.0, 0.0, 0.25, 0.0)	# This Will Clear The Background Color To Black
      gl.glClearDepth(1.0)			# Enables Clearing Of The Depth Buffer
      gl.glDepthFunc(gl.GL_LESS)		# The Type Of Depth Test To Do
      gl.glEnable(gl.GL_DEPTH_TEST)		# Enables Depth Testing
      gl.glShadeModel(gl.GL_SMOOTH)		# Enables Smooth Color Shading

      gl.glMatrixMode(gl.GL_PROJECTION)
      gl.glLoadIdentity()			# Reset The Projection Matrix
						# Calculate The Aspect Ratio Of The Window
      glu.gluPerspective(45.0, float(wWidth)/float(wHeight), 0.1, 100.0)

      gl.glMatrixMode(gl.GL_MODELVIEW)
Esempio n. 50
0
    def display(self):
        GL.glClearColor(0,0,0,0)
        GL.glClearDepth(1.0)
        GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)

        GL.glUseProgram(self.shader)
        GL.glBindVertexArray(self.vao)
        z_offset = self.calc_z_offset()
        GL.glUniform3f(self.offset_location,0.0,0.0,z_offset)
        GL.glDrawElements(GL.GL_TRIANGLES,len(self.indices),GL.GL_UNSIGNED_SHORT,None)

        GL.glBindVertexArray(0)
        GL.glUseProgram(0)
Esempio n. 51
0
 def initializeGL(self):
     GL.glShadeModel(GL.GL_SMOOTH)
     GL.glClearColor(BGCOL[0], BGCOL[1], BGCOL[2], 0)
     GL.glClearDepth(1.0)
     GL.glEnable(GL.GL_DEPTH_TEST)
     GL.glDepthFunc(GL.GL_LEQUAL)
     GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST)
     # Ready to start
     print '--- Start ---'
     print 'MAX_FRAME_COUNT:', MAX_FRAME_COUNT
     print 'FPS:', FPS
     self.time_start = time.time()
     self.timer.start(1000/FPS, self)
Esempio n. 52
0
 def init_opengl(self):  # We call this right after our OpenGL window is created.
     gl.glClearColor(0.0, 0.0, 0.0, 1.0)  # This Will Clear The Background Color To Black
     gl.glClearDepth(1.0)  # Enables Clearing Of The Depth Buffer
     gl.glDepthFunc(gl.GL_LEQUAL)  # The Type Of Depth Test To Do
     gl.glEnable(gl.GL_DEPTH_TEST)  # Enables Depth Testing
     gl.glShadeModel(gl.GL_SMOOTH)
     # Really Nice Perspective Calculations:
     gl.glHint(gl.GL_PERSPECTIVE_CORRECTION_HINT, gl.GL_NICEST)
     gl.glEnable(gl.GL_LIGHT0)
     gl.glEnable(gl.GL_LIGHTING)
     gl.glEnable(gl.GL_COLOR_MATERIAL)
     gl.glEnable(gl.GL_NORMALIZE)  # important since we rescale the modelview matrix
     return True
Esempio n. 53
0
def init_environment(width, height):
    '''initialize OpenGL environment'''
    # black background
    gl.glClearColor(.9, .9, .9, 0)
    # enable depth buffer clearing
    gl.glClearDepth(1.0)
    # set depth test type and enable depth testing
    gl.glDepthFunc(gl.GL_LESS)
    gl.glEnable(gl.GL_DEPTH_TEST)
    # use smooth color shading
    gl.glShadeModel(gl.GL_SMOOTH)

    set_projection_matrix(width, height)
Esempio n. 54
0
 def glsetup(self):
     GLUT.glutInit()
     if self.settings.get("view_shadow"):
         GL.glShadeModel(GL.GL_FLAT)
     else:
         GL.glShadeModel(GL.GL_SMOOTH)
     bg_col = self.settings.get("color_background")
     GL.glClearColor(bg_col[0], bg_col[1], bg_col[2], 0.0)
     GL.glClearDepth(1.)
     GL.glEnable(GL.GL_DEPTH_TEST)
     GL.glDepthFunc(GL.GL_LEQUAL)
     GL.glDepthMask(GL.GL_TRUE)
     GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST)
     GL.glMatrixMode(GL.GL_MODELVIEW)
     #GL.glMaterial(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT,
     #        (0.1, 0.1, 0.1, 1.0))
     GL.glMaterial(GL.GL_FRONT_AND_BACK, GL.GL_SPECULAR,
             (0.1, 0.1, 0.1, 1.0))
     #GL.glMaterial(GL.GL_FRONT_AND_BACK, GL.GL_SHININESS, (0.5))
     if self.settings.get("view_polygon"):
         GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL)
     else:
         GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE)
     GL.glMatrixMode(GL.GL_MODELVIEW)
     GL.glLoadIdentity()
     GL.glMatrixMode(GL.GL_PROJECTION)
     GL.glLoadIdentity()
     GL.glViewport(0, 0, self.area.allocation.width,
             self.area.allocation.height)
     # lighting
     # Setup The Ambient Light
     GL.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, (0.3, 0.3, 0.3, 3.))
     # Setup The Diffuse Light
     GL.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, (1., 1., 1., .0))
     # Setup The SpecularLight
     GL.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, (.3, .3, .3, 1.0))
     GL.glEnable(GL.GL_LIGHT0)
     # Enable Light One
     if self.settings.get("view_light"):
         GL.glEnable(GL.GL_LIGHTING)
     else:
         GL.glDisable(GL.GL_LIGHTING)
     GL.glEnable(GL.GL_NORMALIZE)
     GL.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE)
     #GL.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_SPECULAR)
     #GL.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_EMISSION)
     GL.glEnable(GL.GL_COLOR_MATERIAL)
     # enable blending/transparency (alpha) for colors
     GL.glEnable(GL.GL_BLEND)
     # see http://wiki.delphigl.com/index.php/glBlendFunc
     GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)
Esempio n. 55
0
 def initializeGL(self):
     # these are the defaults anyway, but just to be thorough:
     GL.glClearColor(0.0, 0.0, 0.0, 1.0)
     GL.glClearDepth(1.0)
     # display points according to occlusion, not order of plotting:
     GL.glEnable(GL.GL_DEPTH_TEST)
     # doesn't seem to work right, proper way to antialiase?:
     # GL.glEnable(GL.GL_POINT_SMOOTH)
     GL.glEnable(GL.GL_LINE_SMOOTH)  # works better, makes lines thicker
     # GL.glPointSize(1.5) # truncs to the nearest pixel if antialiasing is off
     # set initial position and orientation of camera
     GL.glTranslate(0, 0, -VIEWDISTANCE)
     GL.glRotate(-45, 0, 0, 1)
     GL.glRotate(-45, 0, 1, 0)
Esempio n. 56
0
    def initializeGL(self):
        def hex_to_rgb(value):
            value = value.lstrip("#")
            lv = len(value)
            return tuple(int(value[i : i + lv // 3], 16) for i in range(0, lv, lv // 3))

        r, g, b = hex_to_rgb(self.main_window.viewer_palette["viewer_background"])

        self.add_shaders()
        gl.glEnable(gl.GL_DEPTH_TEST)
        gl.glDepthFunc(gl.GL_LESS)
        gl.glClearDepth(1.0)
        gl.glClearColor(float(r) / 255.0, float(g) / 255.0, float(b) / 255.0, 1.0)
        gl.glEnable(gl.GL_MULTISAMPLE)
Esempio n. 57
0
    def initializeGL(self):
        Drawer._load_ortho()

        self._texture_id = self.bindTexture(self._image)
        self._init_call_list()

        GL.glClearColor(0, 0, 0, 0)
        GL.glClearDepth(1)
        GL.glEnable(GL.GL_BLEND)
        GL.glEnable(GL.GL_LINE_SMOOTH)
        GL.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_NICEST)
        GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)
        GL.glFrontFace(GL.GL_CCW)
        GL.glCullFace(GL.GL_BACK)
Esempio n. 58
0
 def initializeGL(self):
     # these are the defaults anyway, but just to be thorough:
     GL.glClearColor(0.0, 0.0, 0.0, 1.0)
     GL.glClearDepth(1.0)
     # display points according to occlusion, not order of plotting:
     GL.glEnable(GL.GL_DEPTH_TEST)
     # doesn't seem to work right, proper way to antialiase?:
     #GL.glEnable(GL.GL_POINT_SMOOTH)
     GL.glEnable(GL.GL_LINE_SMOOTH)  # works better, makes lines thicker
     #GL.glPointSize(1.5) # truncs to the nearest pixel if antialiasing is off
     # set initial position and orientation of camera
     GL.glTranslate(0, 0, -VIEWDISTANCE)
     GL.glRotate(-45, 0, 0, 1)
     GL.glRotate(-45, 0, 1, 0)
Esempio n. 59
-1
    def __initOpenGL(self):
        '''
        Initialize OpenGL
        '''
        # Setup depth test
        gl.glEnable(gl.GL_DEPTH_TEST)
        gl.glDepthFunc(gl.GL_LESS)
        gl.glClearDepth(1.0)

        # Setup cull face
        gl.glEnable(gl.GL_CULL_FACE)

        # Setup alpha blending
        gl.glEnable(gl.GL_BLEND)
        gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)

        # Create shader program
        self.shaderProgram.init("Vertex.vert", "Fragment.frag")
        gl.glUseProgram(self.shaderProgram.getProgramObject())

        # Create texture objects
        gl.glActiveTexture(gl.GL_TEXTURE0)
        tex_ids = gl.glGenTextures(TEXT_COUNT)
        for i in range(TEXT_COUNT):
            self.textures.append(Texture(tex_ids[i]))

        # Initialize some shader uniforms
        gl.glUniform1i(TEXTURE_SAMPLER_LOCATION, 0)
        gl.glUniform1i(TEXTURE_FLAG_LOCATION, 0)
        gl.glUniform1i(LIGHTING_FLAG_LOCATION, 0)