Python OpenGL.GL.glDisable() Examples

The following are 30 code examples of OpenGL.GL.glDisable(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module OpenGL.GL , or try the search function .
Example #1
Source File: ndwindow.py    From spectral with MIT License 7 votes vote down vote up
def draw_box(self, x0, y0, x1, y1):
        '''Draws a selection box in the 3-D window.
        Coordinates are with respect to the lower left corner of the window.
        '''
        import OpenGL.GL as gl
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glLoadIdentity()
        gl.glOrtho(0.0, self.size[0],
                   0.0, self.size[1],
                   -0.01, 10.0)

        gl.glLineStipple(1, 0xF00F)
        gl.glEnable(gl.GL_LINE_STIPPLE)
        gl.glLineWidth(1.0)
        gl.glColor3f(1.0, 1.0, 1.0)
        gl.glBegin(gl.GL_LINE_LOOP)
        gl.glVertex3f(x0, y0, 0.0)
        gl.glVertex3f(x1, y0, 0.0)
        gl.glVertex3f(x1, y1, 0.0)
        gl.glVertex3f(x0, y1, 0.0)
        gl.glEnd()
        gl.glDisable(gl.GL_LINE_STIPPLE)
        gl.glFlush()

        self.resize(*self.size) 
Example #2
Source File: camera.py    From GDMC with ISC License 6 votes vote down vote up
def _drawCeiling():
        lines = []
        minz = minx = -256
        maxz = maxx = 256
        for x in range(minx, maxx + 1, 16):
            lines.append((x, 0, minz))
            lines.append((x, 0, maxz))
        for z in range(minz, maxz + 1, 16):
            lines.append((minx, 0, z))
            lines.append((maxx, 0, z))

        GL.glColor(0.3, 0.7, 0.9)
        GL.glVertexPointer(3, GL.GL_FLOAT, 0, numpy.array(lines, dtype='float32'))

        GL.glEnable(GL.GL_DEPTH_TEST)
        GL.glDepthMask(False)
        GL.glDrawArrays(GL.GL_LINES, 0, len(lines))
        GL.glDisable(GL.GL_DEPTH_TEST)
        GL.glDepthMask(True) 
Example #3
Source File: hellovr_glfw.py    From pyopenvr with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def render_companion_window(self):
        GL.glDisable(GL.GL_DEPTH_TEST)
        GL.glViewport(0, 0, self.companion_width, self.companion_height)
        GL.glBindVertexArray(self.companion_window_vao)
        GL.glUseProgram(self.companion_window_program)
        # render left eye (first half of index array)
        i_size = sizeof(c_uint16)
        count = int(self.companion_window_index_size / 2)
        GL.glBindTexture(GL.GL_TEXTURE_2D, self.left_eye_desc.resolve_texture_id)
        GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE)
        GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE)
        GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR)
        GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR)
        GL.glDrawElements(GL.GL_TRIANGLES, count, GL.GL_UNSIGNED_SHORT, cast(0 * i_size, c_void_p))
        # render right eye (second half of index array)
        GL.glBindTexture(GL.GL_TEXTURE_2D, self.right_eye_desc.resolve_texture_id)
        GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE)
        GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE)
        GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR)
        GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR)
        GL.glDrawElements(GL.GL_TRIANGLES, count, GL.GL_UNSIGNED_SHORT, cast(count * i_size, c_void_p))
        GL.glBindVertexArray(0)
        GL.glUseProgram(0) 
Example #4
Source File: player.py    From MCEdit-Unified with ISC License 6 votes vote down vote up
def _drawToolMarkers(self):
        x, y, z = self.editor.level.playerSpawnPosition()
        
        GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)
        GL.glEnable(GL.GL_BLEND)
        
        color = config.selectionColors.black.get() + (0.35,)
        GL.glColor(*color)
        GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE)
        GL.glLineWidth(2.0)
        drawCube(FloatBox((x, y, z), (1, 1, 1)))
        GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL)
        drawCube(FloatBox((x, y, z), (1, 1, 1)))
        GL.glDisable(GL.GL_BLEND)
        
        GL.glEnable(GL.GL_DEPTH_TEST)
        GL.glColor(1.0, 1.0, 1.0, 1.0)
        self.drawCage(x, y, z)
        self.drawCharacterHead(x + 0.5, y + 0.5 + 0.125 * numpy.sin(self.editor.frames * 0.05), z + 0.5)
        GL.glDisable(GL.GL_DEPTH_TEST) 
Example #5
Source File: player.py    From MCEdit-Unified with ISC License 6 votes vote down vote up
def drawToolReticle(self):
        pos, direction = self.editor.blockFaceUnderCursor
        x, y, z = map(lambda p, d: p + d, pos, direction)

        color = (1.0, 1.0, 1.0, 0.5)
        if isinstance(self.editor.level, pymclevel.MCInfdevOldLevel) and self.spawnProtection:
            if not positionValid(self.editor.level, (x, y, z)):
                color = (1.0, 0.0, 0.0, 0.5)

        GL.glColor(*color)
        GL.glEnable(GL.GL_BLEND)
        self.drawCage(x, y, z)
        self.drawCharacterHead(x + 0.5, y + 0.5, z + 0.5)
        GL.glDisable(GL.GL_BLEND)

        GL.glEnable(GL.GL_DEPTH_TEST)
        self.drawCage(x, y, z)
        self.drawCharacterHead(x + 0.5, y + 0.5, z + 0.5)
        color2 = map(lambda a: a * 0.4, color)
        drawTerrainCuttingWire(BoundingBox((x, y, z), (1, 1, 1)), color2, color)
        GL.glDisable(GL.GL_DEPTH_TEST) 
Example #6
Source File: ndwindow.py    From spectral with MIT License 6 votes vote down vote up
def initgl(self):
        '''App-specific initialization for after GLUT has been initialized.'''
        import OpenGL.GL as gl
        self.gllist_id = gl.glGenLists(9)
        gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
        gl.glEnableClientState(gl.GL_COLOR_ARRAY)
        gl.glDisable(gl.GL_LIGHTING)
        gl.glDisable(gl.GL_TEXTURE_2D)
        gl.glDisable(gl.GL_FOG)
        gl.glDisable(gl.GL_COLOR_MATERIAL)
        gl.glEnable(gl.GL_DEPTH_TEST)
        gl.glShadeModel(gl.GL_FLAT)
        self.set_data(self.data, classes=self.classes, features=self.features)

        try:
            import OpenGL.GLUT as glut
            glut.glutInit()
            self._have_glut = True
        except:
            pass 
Example #7
Source File: player.py    From MCEdit-Unified with ISC License 6 votes vote down vote up
def drawToolReticle(self):
        if self.movingPlayer is None:
            return

        pos, direction = self.editor.blockFaceUnderCursor
        dim = self.editor.level.getPlayerDimension(self.movingPlayer)
        pos = (pos[0], pos[1] + 2, pos[2])

        x, y, z = pos

        # x,y,z=map(lambda p,d: p+d, pos, direction)
        GL.glEnable(GL.GL_BLEND)
        GL.glColor(1.0, 1.0, 1.0, 0.5)
        self.drawCharacterHead(x + 0.5, y + 0.75, z + 0.5, self.revPlayerPos[dim][self.movingPlayer], dim)
        GL.glDisable(GL.GL_BLEND)

        GL.glEnable(GL.GL_DEPTH_TEST)
        self.drawCharacterHead(x + 0.5, y + 0.75, z + 0.5, self.revPlayerPos[dim][self.movingPlayer], dim)
        drawTerrainCuttingWire(BoundingBox((x, y, z), (1, 1, 1)))
        drawTerrainCuttingWire(BoundingBox((x, y - 1, z), (1, 1, 1)))
        #drawTerrainCuttingWire( BoundingBox((x,y-2,z), (1,1,1)) )
        GL.glDisable(GL.GL_DEPTH_TEST) 
Example #8
Source File: player.py    From GDMC with ISC License 6 votes vote down vote up
def _drawToolMarkers(self):
        x, y, z = self.editor.level.playerSpawnPosition()
        
        GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
        GL.glEnable(GL.GL_BLEND);
        
        color = config.selectionColors.black.get() + (0.35,)
        GL.glColor(*color)
        GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE)
        GL.glLineWidth(2.0)
        drawCube(FloatBox((x, y, z), (1, 1, 1)))
        GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL)
        drawCube(FloatBox((x, y, z), (1, 1, 1)))
        GL.glDisable(GL.GL_BLEND)
        
        GL.glEnable(GL.GL_DEPTH_TEST)
        GL.glColor(1.0, 1.0, 1.0, 1.0)
        self.drawCage(x, y, z)
        self.drawCharacterHead(x + 0.5, y + 0.5 + 0.125 * numpy.sin(self.editor.frames * 0.05), z + 0.5)
        GL.glDisable(GL.GL_DEPTH_TEST) 
Example #9
Source File: camera.py    From MCEdit-Unified with ISC License 6 votes vote down vote up
def _drawCeiling():
        lines = []
        minz = minx = -256
        maxz = maxx = 256
        append = lines.append
        for x in xrange(minx, maxx + 1, 16):
            append((x, 0, minz))
            append((x, 0, maxz))
        for z in xrange(minz, maxz + 1, 16):
            append((minx, 0, z))
            append((maxx, 0, z))

        GL.glColor(0.3, 0.7, 0.9)
        GL.glVertexPointer(3, GL.GL_FLOAT, 0, numpy.array(lines, dtype='float32'))

        GL.glEnable(GL.GL_DEPTH_TEST)
        GL.glDepthMask(False)
        GL.glDrawArrays(GL.GL_LINES, 0, len(lines))
        GL.glDisable(GL.GL_DEPTH_TEST)
        GL.glDepthMask(True) 
Example #10
Source File: mceutils.py    From MCEdit-Unified with ISC License 6 votes vote down vote up
def drawTerrainCuttingWire(box,
                           c0=(0.75, 0.75, 0.75, 0.4),
                           c1=(1.0, 1.0, 1.0, 1.0)):
    # glDepthMask(False)
    GL.glEnable(GL.GL_DEPTH_TEST)

    GL.glDepthFunc(GL.GL_LEQUAL)
    GL.glColor(*c1)
    GL.glLineWidth(2.0)
    drawCube(box, cubeType=GL.GL_LINE_STRIP)

    GL.glDepthFunc(GL.GL_GREATER)
    GL.glColor(*c0)
    GL.glLineWidth(1.0)
    drawCube(box, cubeType=GL.GL_LINE_STRIP)

    GL.glDepthFunc(GL.GL_LEQUAL)
    GL.glDisable(GL.GL_DEPTH_TEST)
    # glDepthMask(True) 
Example #11
Source File: mceutils.py    From GDMC with ISC License 6 votes vote down vote up
def drawTerrainCuttingWire(box,
                           c0=(0.75, 0.75, 0.75, 0.4),
                           c1=(1.0, 1.0, 1.0, 1.0)):
    # glDepthMask(False)
    GL.glEnable(GL.GL_DEPTH_TEST)

    GL.glDepthFunc(GL.GL_LEQUAL)
    GL.glColor(*c1)
    GL.glLineWidth(2.0)
    drawCube(box, cubeType=GL.GL_LINE_STRIP)

    GL.glDepthFunc(GL.GL_GREATER)
    GL.glColor(*c0)
    GL.glLineWidth(1.0)
    drawCube(box, cubeType=GL.GL_LINE_STRIP)

    GL.glDepthFunc(GL.GL_LEQUAL)
    GL.glDisable(GL.GL_DEPTH_TEST)
    # glDepthMask(True) 
Example #12
Source File: render_scene.py    From holistic_scene_parsing with MIT License 6 votes vote down vote up
def __init__(self, obj_info, color=None, swapyz=False):
        """Loads a Wavefront OBJ file. """
        self.vertices = obj_info.vertices
        self.normals = obj_info.normals
        self.texcoords = obj_info.texcoords
        self.faces = obj_info.faces
        self.color = color

        self.gl_list = GL.glGenLists(1)
        GL.glNewList(self.gl_list, GL.GL_COMPILE)
        # GL.glEnable(GL.GL_TEXTURE_2D)
        GL.glFrontFace(GL.GL_CCW)
        # GL.glDisable(GL.GL_LIGHT0)
        # GL.glDisable(GL.GL_LIGHTING)
        for face in self.faces:
            vertices, normals, _, _ = face
            GL.glColor3f(self.color[0], self.color[1], self.color[2])
            GL.glBegin(GL.GL_POLYGON)
            for i in range(len(vertices)):
                # if normals[i] > 0:
                #     GL.glNormal3fv(self.normals[normals[i] - 1])
                GL.glVertex3fv(self.vertices[vertices[i] - 1])
            GL.glEnd()
        GL.glDisable(GL.GL_TEXTURE_2D)
        GL.glEndList() 
Example #13
Source File: player.py    From GDMC with ISC License 6 votes vote down vote up
def drawToolReticle(self):
        if self.movingPlayer is None:
            return

        pos, direction = self.editor.blockFaceUnderCursor
        dim = self.editor.level.getPlayerDimension(self.movingPlayer)
        pos = (pos[0], pos[1] + 2, pos[2])

        x, y, z = pos

        # x,y,z=map(lambda p,d: p+d, pos, direction)
        GL.glEnable(GL.GL_BLEND)
        GL.glColor(1.0, 1.0, 1.0, 0.5)
        self.drawCharacterHead(x + 0.5, y + 0.75, z + 0.5, self.revPlayerPos[dim][self.movingPlayer], dim)
        GL.glDisable(GL.GL_BLEND)

        GL.glEnable(GL.GL_DEPTH_TEST)
        self.drawCharacterHead(x + 0.5, y + 0.75, z + 0.5, self.revPlayerPos[dim][self.movingPlayer], dim)
        drawTerrainCuttingWire(BoundingBox((x, y, z), (1, 1, 1)))
        drawTerrainCuttingWire(BoundingBox((x, y - 1, z), (1, 1, 1)))
        #drawTerrainCuttingWire( BoundingBox((x,y-2,z), (1,1,1)) )
        GL.glDisable(GL.GL_DEPTH_TEST) 
Example #14
Source File: render_scene.py    From holistic_scene_parsing with MIT License 6 votes vote down vote up
def __init__(self, obj_info, obj_color=None, swapyz=False):
        """Loads a Wavefront OBJ file. """
        self.vertices = obj_info.vertices
        self.normals = obj_info.normals
        self.texcoords = obj_info.texcoords
        self.faces = obj_info.faces

        self.gl_list = GL.glGenLists(1)
        GL.glNewList(self.gl_list, GL.GL_COMPILE)
        for face in self.faces:
            vertices, normals, _, texture_coords = face
            GL.glBegin(GL.GL_POLYGON)
            for i in range(len(vertices)):
                GL.glVertex3fv(self.vertices[vertices[i] - 1])
            GL.glEnd()
        # GL.glDisable(GL.GL_TEXTURE_2D)
        GL.glEndList() 
Example #15
Source File: player.py    From MCEdit-Unified with ISC License 5 votes vote down vote up
def drawCage(self, x, y, z):
        cageTexVerts = numpy.array(pymclevel.MCInfdevOldLevel.materials.blockTextures[52, 0])

        pixelScale = 0.5 if self.editor.level.materials.name in ("Pocket", "Alpha") else 1.0
        texSize = 16 * pixelScale
        cageTexVerts = cageTexVerts.astype(float) * pixelScale

        cageTexVerts = numpy.array(
            [((tx, ty), (tx + texSize, ty), (tx + texSize, ty + texSize), (tx, ty + texSize)) for (tx, ty) in
             cageTexVerts], dtype='float32')
        GL.glEnable(GL.GL_ALPHA_TEST)

        drawCube(BoundingBox((x, y, z), (1, 1, 1)), texture=pymclevel.alphaMaterials.terrainTexture,
                 textureVertices=cageTexVerts)
        GL.glDisable(GL.GL_ALPHA_TEST) 
Example #16
Source File: select.py    From MCEdit-Unified with ISC License 5 votes vote down vote up
def selectionPointsFromDragResize(self):
        point = self.dragResizePoint()
        # glColor(1.0, 1.0, 0.0, 1.0)
        #        glPointSize(9.0)
        #        glBegin(GL_POINTS)
        #        glVertex3f(*point)
        #        glEnd()
        #

        #        facebox = BoundingBox(box.origin, box.size)
        #        facebox.origin[dim] = self.dragResizePosition
        #        facebox.size[dim] = 0
        #        glEnable(GL_BLEND)
        #
        #        drawFace(facebox, dim * 2)
        #
        #        glDisable(GL_BLEND)
        #
        side = self.dragResizeFace & 1
        dragdim = self.dragResizeFace >> 1
        box = self.selectionBox()

        o, m = list(box.origin), list(box.maximum)
        (m, o)[side][dragdim] = int(numpy.floor(point[dragdim] + 0.5))
        m = map(lambda a: a - 1, m)
        return o, m 
Example #17
Source File: editortool.py    From GDMC with ISC License 5 votes vote down vote up
def drawTerrainPreview(self, origin):
        if self.previewRenderer is None:
            return
        self.previewRenderer.origin = map(lambda a, b: a - b, origin, self.level.bounds.origin)

        GL.glPolygonOffset(DepthOffset.ClonePreview, DepthOffset.ClonePreview)
        GL.glEnable(GL.GL_POLYGON_OFFSET_FILL)
        self.previewRenderer.draw()
        GL.glDisable(GL.GL_POLYGON_OFFSET_FILL) 
Example #18
Source File: blockview.py    From MCEdit-Unified with ISC License 5 votes vote down vote up
def _gl_draw(self):
        blockInfo = self.blockInfo
        if blockInfo.ID is 0:
            return

        GL.glColor(1.0, 1.0, 1.0, 1.0)
        GL.glEnable(GL.GL_TEXTURE_2D)
        GL.glEnable(GL.GL_ALPHA_TEST)
        self.materials.terrainTexture.bind()
        pixelScale = 0.5 if self.materials.name in ("Pocket", "Alpha") else 1.0
        texSize = 16 * pixelScale

        GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY)
        GL.glVertexPointer(2, GL.GL_FLOAT, 0, array([-1, -1,
                                                     - 1, 1,
                                                     1, 1,
                                                     1, -1, ], dtype='float32'))
        # hack to get end rod to render properly
        # we really should use json models?
        if blockInfo.ID == 198:
            texOrigin = array([17*16, 20*16])
        else:
            texOrigin = array(self.materials.blockTextures[blockInfo.ID, blockInfo.blockData, 0])
        texOrigin = texOrigin.astype(float) * pixelScale

        GL.glTexCoordPointer(2, GL.GL_FLOAT, 0, array([texOrigin[0], texOrigin[1] + texSize,
                                                       texOrigin[0], texOrigin[1],
                                                       texOrigin[0] + texSize, texOrigin[1],
                                                       texOrigin[0] + texSize, texOrigin[1] + texSize],
                                                      dtype='float32'))

        GL.glDrawArrays(GL.GL_QUADS, 0, 4)

        GL.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY)
        GL.glDisable(GL.GL_ALPHA_TEST)
        GL.glDisable(GL.GL_TEXTURE_2D) 
Example #19
Source File: renderer.py    From MCEdit-Unified with ISC License 5 votes vote down vote up
def callMasterLists(self):
            for renderstate in self.chunkCalculator.renderstates:
                if renderstate not in self.masterLists:
                    continue

                if self.alpha != 0xff and renderstate is not ChunkCalculator.renderstateLowDetail:
                    GL.glEnable(GL.GL_BLEND)
                renderstate.bind()

                GL.glCallLists(self.masterLists[renderstate])

                renderstate.release()
                if self.alpha != 0xff and renderstate is not ChunkCalculator.renderstateLowDetail:
                    GL.glDisable(GL.GL_BLEND) 
Example #20
Source File: renderer.py    From MCEdit-Unified with ISC License 5 votes vote down vote up
def bind(cls):
            GL.glDisable(GL.GL_DEPTH_TEST)
            # GL.glDisable(GL.GL_CULL_FACE)
            GL.glDisable(GL.GL_TEXTURE_2D)
            GL.glEnable(GL.GL_BLEND) 
Example #21
Source File: renderer.py    From MCEdit-Unified with ISC License 5 votes vote down vote up
def release(cls):
            GL.glDisable(GL.GL_ALPHA_TEST) 
Example #22
Source File: renderer.py    From MCEdit-Unified with ISC License 5 votes vote down vote up
def release(cls):
            GL.glDisable(GL.GL_BLEND) 
Example #23
Source File: select.py    From MCEdit-Unified with ISC License 5 votes vote down vote up
def drawToolReticle(self):
        GL.glPolygonOffset(DepthOffset.SelectionReticle, DepthOffset.SelectionReticle)
        pos, direction = self.editor.blockFaceUnderCursor

        # draw a selection-colored box for the cursor reticle
        selectionColor = map(lambda a: a * a * a * a, self.selectionColor)
        r, g, b = selectionColor
        alpha = 0.3

        try:
            bt = self.editor.level.blockAt(*pos)
            if bt:
                # #                textureCoords = materials[bt][0]
                alpha = 0.12
        except (EnvironmentError, pymclevel.ChunkNotPresent):
            pass

        # cube sides
        GL.glColor(r, g, b, alpha)
        GL.glDepthMask(False)
        GL.glEnable(GL.GL_BLEND)
        GL.glEnable(GL.GL_DEPTH_TEST)
        drawCube(BoundingBox(pos, (1, 1, 1)))
        GL.glDepthMask(True)
        GL.glDisable(GL.GL_DEPTH_TEST)

        drawTerrainCuttingWire(BoundingBox(pos, (1, 1, 1)),
                               (r, g, b, 0.4),
                               (1., 1., 1., 1.0)
                               )

        GL.glDisable(GL.GL_BLEND) 
Example #24
Source File: renderer.py    From MCEdit-Unified with ISC License 5 votes vote down vote up
def drawFaceVertices(self, buf):
        if not len(buf):
            return
        stride = elementByteLength

        GL.glVertexPointer(3, GL.GL_FLOAT, stride, (buf.ravel()))
        GL.glTexCoordPointer(2, GL.GL_FLOAT, stride, (buf.ravel()[3:]))
        GL.glColorPointer(4, GL.GL_UNSIGNED_BYTE, stride, (buf.view(dtype=numpy.uint8).ravel()[20:]))

        GL.glDepthMask(False)

        GL.glDisable(GL.GL_CULL_FACE)

        with gl.glEnable(GL.GL_DEPTH_TEST):
            GL.glDrawArrays(GL.GL_QUADS, 0, len(buf) * 4)

        GL.glEnable(GL.GL_CULL_FACE)

        GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE)

        GL.glLineWidth(1.0)
        GL.glDrawArrays(GL.GL_QUADS, 0, len(buf) * 4)
        GL.glLineWidth(2.0)
        with gl.glEnable(GL.GL_DEPTH_TEST):
            GL.glDrawArrays(GL.GL_QUADS, 0, len(buf) * 4)
        GL.glLineWidth(1.0)

        GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL)
        GL.glDepthMask(True) 
Example #25
Source File: renderer.py    From MCEdit-Unified with ISC License 5 votes vote down vote up
def bind(cls):
            GL.glDisable(GL.GL_CULL_FACE)
            GL.glEnable(GL.GL_ALPHA_TEST) 
Example #26
Source File: leveleditor.py    From MCEdit-Unified with ISC License 5 votes vote down vote up
def drawWireCubeReticle(self, color=(1.0, 1.0, 1.0, 1.0), position=None):
        GL.glPolygonOffset(DepthOffset.TerrainWire, DepthOffset.TerrainWire)
        GL.glEnable(GL.GL_POLYGON_OFFSET_FILL)

        blockPosition, faceDirection = self.blockFaceUnderCursor
        blockPosition = position or blockPosition

        mceutils.drawTerrainCuttingWire(pymclevel.BoundingBox(blockPosition, (1, 1, 1)), c1=color)

        GL.glDisable(GL.GL_POLYGON_OFFSET_FILL) 
Example #27
Source File: leveleditor.py    From MCEdit-Unified with ISC License 5 votes vote down vote up
def drawConstructionCube(self, box, color, texture=None):
        if texture is None:
            texture = self.sixteenBlockTex
        # textured cube faces

        GL.glEnable(GL.GL_BLEND)
        GL.glEnable(GL.GL_DEPTH_TEST)
        GL.glDepthMask(False)

        # edges within terrain
        GL.glDepthFunc(GL.GL_GREATER)
        try:
            GL.glColor(color[0], color[1], color[2], max(color[3], 0.35))
        except IndexError:
            raise
        GL.glLineWidth(1.0)
        mceutils.drawCube(box, cubeType=GL.GL_LINE_STRIP)

        # edges on or outside terrain
        GL.glDepthFunc(GL.GL_LEQUAL)
        GL.glColor(color[0], color[1], color[2], max(color[3] * 2, 0.75))
        GL.glLineWidth(2.0)
        mceutils.drawCube(box, cubeType=GL.GL_LINE_STRIP)

        GL.glDepthFunc(GL.GL_LESS)
        GL.glColor(color[0], color[1], color[2], color[3])
        GL.glDepthFunc(GL.GL_LEQUAL)
        mceutils.drawCube(box, texture=texture, selectionBox=True)
        GL.glDepthMask(True)

        GL.glDisable(GL.GL_BLEND)
        GL.glDisable(GL.GL_DEPTH_TEST) 
Example #28
Source File: hellovr_glfw.py    From pyopenvr with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def render_stereo_targets(self):
        GL.glClearColor(0, 0, 0, 1)
        GL.glEnable(GL.GL_MULTISAMPLE)
        # Left Eye
        GL.glBindFramebuffer(GL.GL_FRAMEBUFFER, self.left_eye_desc.render_framebuffer_id)
        GL.glViewport(0, 0, self.render_width, self.render_height)
        self.render_scene(openvr.Eye_Left)
        GL.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0)
        GL.glDisable(GL.GL_MULTISAMPLE)
        GL.glBindFramebuffer(GL.GL_READ_FRAMEBUFFER, self.left_eye_desc.render_framebuffer_id)
        GL.glBindFramebuffer(GL.GL_DRAW_FRAMEBUFFER, self.left_eye_desc.resolve_framebuffer_id)
        GL.glBlitFramebuffer(
            0, 0, self.render_width, self.render_height,
            0, 0, self.render_width, self.render_height,
            GL.GL_COLOR_BUFFER_BIT, GL.GL_LINEAR)
        GL.glBindFramebuffer(GL.GL_READ_FRAMEBUFFER, 0)
        GL.glBindFramebuffer(GL.GL_DRAW_FRAMEBUFFER, 0)
        # Right Eye
        GL.glEnable(GL.GL_MULTISAMPLE)
        GL.glBindFramebuffer(GL.GL_FRAMEBUFFER, self.right_eye_desc.render_framebuffer_id)
        GL.glViewport(0, 0, self.render_width, self.render_height)
        self.render_scene(openvr.Eye_Right)
        GL.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0)
        GL.glDisable(GL.GL_MULTISAMPLE)
        GL.glBindFramebuffer(GL.GL_READ_FRAMEBUFFER, self.right_eye_desc.render_framebuffer_id)
        GL.glBindFramebuffer(GL.GL_DRAW_FRAMEBUFFER, self.right_eye_desc.resolve_framebuffer_id)
        GL.glBlitFramebuffer(
            0, 0, self.render_width, self.render_height,
            0, 0, self.render_width, self.render_height,
            GL.GL_COLOR_BUFFER_BIT, GL.GL_LINEAR)
        GL.glBindFramebuffer(GL.GL_READ_FRAMEBUFFER, 0)
        GL.glBindFramebuffer(GL.GL_DRAW_FRAMEBUFFER, 0) 
Example #29
Source File: LicModel.py    From lic with GNU General Public License v3.0 5 votes vote down vote up
def paintGL(self, dx, dy, rotation=[0.0, 0.0, 0.0], scaling=1.0, color=None):

        LicGLHelpers.pushAllGLMatrices()

        dr = SubmodelPreview.defaultRotation if self.isSubmodel else PLI.defaultRotation
        ds = SubmodelPreview.defaultScale if self.isSubmodel else PLI.defaultScale

        dx += self.center.x() * scaling
        dy += self.center.y() * scaling

        if color is not None:  # Color means we're drawing a PLIItem, so apply PLI specific scale & rotation
            ds *= self.pliScale

        LicGLHelpers.rotateToView(dr, ds * scaling, dx, dy, 0.0)
        LicGLHelpers.rotateView(*rotation)

        if color is not None:

            LicGLHelpers.rotateView(*self.pliRotation)
            
        
        #First paint edge
        if color is not None and color.edgeRgba is not None:
            GL.glColor4fv(color.edgeRgba)
            
        GL.glPushAttrib(GL_ENABLE_BIT)
        GL.glDisable(GL_LIGHTING)
        
        GL.glCallList(self.glEdgeDispID)
        
        GL.glPopAttrib()
        
        #Than paint contents
        if color is not None:
            GL.glColor4fv(color.rgba)

        GL.glCallList(self.glDispID)
        LicGLHelpers.popAllGLMatrices() 
Example #30
Source File: LicModel.py    From lic with GNU General Public License v3.0 5 votes vote down vote up
def __callPreviousGLDisplayLists(self, isCurrent=False):

        # Call all previous step's CSI display list
        prevStep = self.parentItem().getPrevStep()
        if prevStep:
            # if prevStep.csi.glDispID == LicGLHelpers.UNINIT_GL_DISPID:
            prevStep.csi.__callPreviousGLDisplayLists(False)
            # else:
            #    GL.glCallList(prevStep.csi.glDispID)

        # Draw all the parts in this CSI
        # First their edges
        GL.glPushAttrib(GL.GL_CURRENT_BIT | GL_ENABLE_BIT)
        GL.glColor4f(0.0, 0.0, 0.0, 1.0)
        GL.glDisable(GL_LIGHTING)
        
        for partItem in self.parts:
            for part in partItem.parts:
                part.callGLDisplayList(isCurrent, True)
                
        GL.glPopAttrib()
        
        # Than their contents
        for partItem in self.parts:
            for part in partItem.parts:
                part.callGLDisplayList(isCurrent, False)