Example #1
0
    def _draw_one(self, item):
        first, count = item.vert_range

        # Skip empty draws
        if count == 0:
            return

        item.vao.bind()

        material_uid = item.material_name
        if material_uid not in self._materials:
            LOG.error('unknown material: %r', material_uid)
            return

        material = self._materials[material_uid]
        with material.bind():
            material.bind_attributes(self._buffer_objects, item.attributes)
            uniforms = dict(item.uniforms)
            # TODO
            uniforms.update(self._uniforms)
            # TODO
            material.bind_uniforms(uniforms)

        with material.bind():
            glDrawArrays(item.primitive, first, count)
Example #2
0
    def plot(self):

        # Specify shader to be used
        glUseProgram(self.gls_pgr.program_id)

        # Bind VAO - this will automatically
        # bind all the vbo's saving us a bunch
        # of calls
        #glBindVertexArray(self.vao_id)

        glUniform4fv(self.gls_id_xy_color,1, self.plot_color)

        # Modern GL makes the draw call really simple
        # All the complexity has been pushed elsewhere


        glEnableVertexAttribArray(self.vertIndex)


        # set buffers
        glBindBuffer(GL_ARRAY_BUFFER, self.vertexBuffer)
        glVertexAttribPointer(self.vertIndex,2, GL_FLOAT, GL_FALSE, 0, None)

        glDrawArrays(GL_LINE_STRIP, 0, self.data_points-1)

        # Lets unbind the shader and vertex array state
        glUseProgram(0)
        # disable arrays
        glDisableVertexAttribArray(self.vertIndex)

        glBindVertexArray(0)
Example #3
0
    def _render_gridlines(self) -> None:
        """Render gridlines."""
        if self._vao_gridlines is None:
            return

        glBindVertexArray(self._vao_gridlines)
        glDrawArrays(GL_LINES, 0, self._count_gridlines)
Example #4
0
    def draw(self):
        '''Draw the mesh on screen (using display list if compiled)'''
        if self.list:
            glCallList(self.list)
            return

        glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT)
        glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT | GL_LIGHTING_BIT)
        glEnable(GL_CULL_FACE)
        glCullFace(GL_BACK)
        for group in self.groups:
            if group.material:
                group.material.apply()
            if group.array is None:
                if group.material and group.material.texture:
                    if group.material.texture.rectangle:
                        # texture is a rectangle texture
                        # that's mean we need to adjust the range of texture
                        # coordinate from original 0-1 to 0-width/0-height
                        group.vertices[0::8] = map(
                            lambda x: x * group.material.texture.width,
                            group.vertices[0::8])
                        group.vertices[1::8] = map(
                            lambda x: x * group.material.texture.height,
                            group.vertices[1::8])
                group.array = (GLfloat * len(group.vertices))(*group.vertices)
                group.triangles = len(group.vertices) / 8
            glInterleavedArrays(GL_T2F_N3F_V3F, 0, group.array)
            glDrawArrays(GL_TRIANGLES, 0, group.triangles)
            if group.material:
                group.material.unapply()
        glPopAttrib()
        glPopClientAttrib()
Example #5
0
    def draw(self):
        '''Draw the mesh on screen (using display list if compiled)'''
        if self.list:
            glCallList(self.list)
            return

        glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT)
        glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT | GL_LIGHTING_BIT)
        glEnable(GL_CULL_FACE)
        glCullFace(GL_BACK)
        for group in self.groups:
            if group.material:
                group.material.apply()
            if group.array is None:
                if group.material and group.material.texture:
                    if group.material.texture.rectangle:
                        # texture is a rectangle texture
                        # that's mean we need to adjust the range of texture
                        # coordinate from original 0-1 to 0-width/0-height
                        group.vertices[0::8] = map(
                            lambda x: x * group.material.texture.width,
                            group.vertices[0::8]
                        )
                        group.vertices[1::8] = map(
                            lambda x: x * group.material.texture.height,
                            group.vertices[1::8]
                        )
                group.array = (GLfloat * len(group.vertices))(*group.vertices)
                group.triangles = len(group.vertices) / 8
            glInterleavedArrays(GL_T2F_N3F_V3F, 0, group.array)
            glDrawArrays(GL_TRIANGLES, 0, group.triangles)
            if group.material:
                group.material.unapply()
        glPopAttrib()
        glPopClientAttrib()
Example #6
0
    def _draw(self, transformation_matrix: numpy.ndarray):
        glUseProgram(self._shader)
        glUniformMatrix4fv(
            self._transform_location,
            1,
            GL_FALSE,
            transformation_matrix.T.astype(numpy.float32),
        )
        glUniform1i(self._texture_location, 0)
        try:
            glBindVertexArray(self._vao)
        except GLError:  # There seems to be errors randomly when binding the VBO
            log.debug(
                f"Failed binding the OpenGL state for {self}. Trying to reload it."
            )
            self.unload()
            self._setup()
            glBindVertexArray(self._vao)
        glActiveTexture(GL_TEXTURE0)
        glBindTexture(GL_TEXTURE_2D, self._texture)

        glDrawArrays(self.draw_mode, self.draw_start, self.draw_count)

        glBindVertexArray(0)
        glUseProgram(0)
Example #7
0
    def draw_vertices(self):
        # Draw all the vbo defined in set_atoms
        if self.transparent:
            glEnable(GL_BLEND)
            glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
            glDepthMask(GL_FALSE)
        if self.wireframe:
            glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)

        glEnableClientState(GL_VERTEX_ARRAY)
        self._vbo_v.bind_vertexes(3, GL_FLOAT)
        
        glEnableClientState(GL_NORMAL_ARRAY)
        self._vbo_n.bind_normals(GL_FLOAT)
        
        glEnableClientState(GL_COLOR_ARRAY)
        self._vbo_c.bind_colors(4, GL_UNSIGNED_BYTE)
        
        glDrawArrays(GL_TRIANGLES, 0, self._n_triangles)
        
        self._vbo_v.unbind()
        self._vbo_n.unbind()
        self._vbo_c.unbind()

        if self.transparent:
            glDisable(GL_BLEND)
            #glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
            glDepthMask(GL_TRUE)
        if self.wireframe:
            glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
Example #8
0
    def paintGL(self):
        if self.crashFlag:      #run cleanup operations
            glUseProgram(0)
            glDisableVertexAttribArray(self.attrID)
            glDeleteBuffers(1,[self.vertexBuffer])
            glDeleteVertexArrays(1, [self.vertexArrayID])

        glLoadIdentity()
        gluPerspective(45, self.sizeX / self.sizeY, 0.1, 110.0)    #set perspective
        glTranslatef(0, 0, self.zoomLevel)
        glRotatef(self.rotateDegreeV + self.vOffset, 1, 0, 0)
        glRotatef(self.rotateDegreeH, 0, 0, 1)
        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)

        self.vertexData = [
            -1, 1, 0,
            0, -1, 0,
            1, 1, 0
        ]

        arrayType = GLfloat * len(self.vertexData)

        target = GL_ARRAY_BUFFER
        offset = 0
        size = len(self.vertexData) * ctypes.sizeof(ctypes.c_float)
        data = arrayType(*self.vertexData)
        glBufferSubData(target, offset, size, data)

        glDrawArrays(GL_TRIANGLES, 0, 3)
Example #9
0
    def plot(self):

        # Specify shader to be used
        glUseProgram(self.gls_pgr.program_id)

        # Bind VAO - this will automatically
        # bind all the vbo's saving us a bunch
        # of calls
        #glBindVertexArray(self.vao_id)

        glUniform4fv(self.gls_id_xy_color, 1, self.plot_color)

        # Modern GL makes the draw call really simple
        # All the complexity has been pushed elsewhere

        glEnableVertexAttribArray(self.vertIndex)

        # set buffers
        glBindBuffer(GL_ARRAY_BUFFER, self.vertexBuffer)
        glVertexAttribPointer(self.vertIndex, 2, GL_FLOAT, GL_FALSE, 0, None)

        glDrawArrays(GL_LINE_STRIP, 0, self.data_points - 1)

        # Lets unbind the shader and vertex array state
        glUseProgram(0)
        # disable arrays
        glDisableVertexAttribArray(self.vertIndex)

        glBindVertexArray(0)
Example #10
0
    def render(self, model, view_matrix, projection_matrix):
        glUseProgram(self.program)

        glEnableVertexAttribArray(self.texcoords)
        glEnableVertexAttribArray(self.vertices)

        glUniformMatrix4fv(
            self.model_view_matrix, 1, GL_TRUE,
            np.dot(view_matrix, model.matrix)
        )
        glUniformMatrix4fv(
            self.projection_matrix, 1, GL_TRUE, projection_matrix
        )

        for group in model.groups:
            glBindTexture(GL_TEXTURE_2D, group.material.texture)
            glUniform1i(self.texture, 0)
            glVertexAttribPointer(
                self.vertices, 3, GL_FLOAT, GL_FALSE, 0, group.vertex_buffer
            )
            glVertexAttribPointer(
                self.texcoords, 2, GL_FLOAT, GL_FALSE, 0, group.texcoord_buffer
            )

            glDrawArrays(GL_TRIANGLES, 0, len(group.vertex_buffer))

        glDisableVertexAttribArray(self.vertices)
        glDisableVertexAttribArray(self.texcoords)
Example #11
0
    def render(self):
        "Override for custom drawing."
        # Clear the screen buffer
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        for shader in self.shaders:
            with shader.rendering():
                # Set view and perspective
                glUniformMatrix4fv(shader.uniforms['view'][0], 1, GL_FALSE,
                                   np.array(self.view.matrix))
                glUniformMatrix4fv(shader.uniforms['projection'][0], 1,
                                   GL_FALSE, np.array(self.projection))
                glUniform1f(shader.uniforms['light_ambient_weight'][0],
                            self.ambient_light)
                glUniform3f(shader.uniforms['light_ambient_color'][0],
                            *self.ambient_light_color)
                glUniform3f(shader.uniforms['light_pos'][0], *(2., 2., 2.))
                glUniform3f(shader.uniforms['light_color'][0], *(1, 1, 1))
                glUniform1f(shader.uniforms['light_glare'][0], 32.)

                # Draw models with shader
                for mdl, vao in shader._models_and_VAOs:
                    # Set the model's transform matrix uniform
                    vbo, mode = mdl.render_data
                    glUniformMatrix4fv(shader.uniforms['model'][0], 1,
                                       GL_FALSE, np.array(mdl.model_matrix))
                    vao.bind()
                    vbo.bind()
                    glDrawArrays(mode, 0, len(vbo))
                self.flaggo = False
        # TODO Apply postprocessing filters

        # Put it on the screen.
        pygame.display.flip()
Example #12
0
    def draw_vertices(self):
        # Draw all the vbo defined in set_atoms
        if self.transparent:
            glEnable(GL_BLEND)
            glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
            glDepthMask(GL_FALSE)
        if self.wireframe:
            glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)

        glEnableClientState(GL_VERTEX_ARRAY)
        self._vbo_v.bind_vertexes(3, GL_FLOAT)

        glEnableClientState(GL_NORMAL_ARRAY)
        self._vbo_n.bind_normals(GL_FLOAT)

        glEnableClientState(GL_COLOR_ARRAY)
        self._vbo_c.bind_colors(4, GL_UNSIGNED_BYTE)

        glDrawArrays(GL_TRIANGLES, 0, self._n_triangles)

        self._vbo_v.unbind()
        self._vbo_n.unbind()
        self._vbo_c.unbind()

        if self.transparent:
            glDisable(GL_BLEND)
            #glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
            glDepthMask(GL_TRUE)
        if self.wireframe:
            glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
Example #13
0
    def draw(self):
        """Draw test object."""

        glBindBuffer(GL_ARRAY_BUFFER, self.vbo)
        glEnableVertexAttribArray(0)
        glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, None)
        glDrawArrays(GL_TRIANGLES, 0, 6)
        glDisableVertexAttribArray(0)
        glBindBuffer(GL_ARRAY_BUFFER, 0)
Example #14
0
	def _render(self, stage, projection_matrix, modelCamera_matrix):
		# Run the pre-render
		shader = super(ImageActor, self)._prerender(stage, projection_matrix, modelCamera_matrix)
		
		# Render
		glDrawArrays(GL_TRIANGLES, 0, len(self.vbo) / 2)
		
		# Post render
		super(ImageActor, self)._postrender(stage, shader)
Example #15
0
 def draw(self):
     """Binds the vao, binds the texture, draws the vertices."""
     glBindVertexArray(self.vao)
     glBindTexture(GL_TEXTURE_2D, self.tex)
     if self.mat is not None:
         self.mat.bind(self.shader)
     glDrawArrays(self.shape, 0, self.leng)
     glBindTexture(GL_TEXTURE_2D, 0)
     glBindVertexArray(0)
Example #16
0
    def render(self):
        domain.enable_domains(self.program, self.domains.items())

        glEnable(GL_PROGRAM_POINT_SIZE)
        self.program.use()
        glBindVertexArray(self.vao)
        glDrawArrays(self.gl_mode, self.offset, self.length)
        glBindVertexArray(0)
        self.program.unuse()
Example #17
0
def draw_circle_memoized(p, n, r, sides=64):
    """Draw circle given point, normal vector, radius, and # sides.
    Uses the function compute_circle to generate points.
    """
    vertices, count = compute_circle(*p, *n, r, sides)

    # draw vertices
    glEnableClientState(GL_VERTEX_ARRAY)
    glVertexPointer(3, GL_FLOAT, 0, vertices)
    glDrawArrays(GL_LINE_STRIP, 0, count)
    glDisableClientState(GL_VERTEX_ARRAY)
Example #18
0
    def gl_draw(self):
        #if hasattr(self, 'highlight_bg_color') and self in self.get_root().find_widget(mouse.get_pos()).all_parents():
        #    color = self.highlight_bg_color
        #else:
        color = tuple(self.bg_color) + (1.0,)

        glEnable(GL_BLEND)
        glColor(color[0], color[1], color[2], color[3])
        glVertexPointer(2, GL_FLOAT, 0, array([-1, -1, -1, 1, 1, 1, 1, -1], dtype='float32'))
        glDrawArrays(GL_QUADS, 0, 4)
        glDisable(GL_BLEND)
Example #19
0
    def gl_draw(self):
        # if hasattr(self, 'highlight_bg_color') and self in self.get_root().find_widget(mouse.get_pos()).all_parents():
        #    color = self.highlight_bg_color
        # else:
        color = tuple(self.bg_color) + (1.0,)

        glEnable(GL_BLEND)
        glColor(color[0], color[1], color[2], color[3])
        glVertexPointer(2, GL_FLOAT, 0, array([-1, -1, -1, 1, 1, 1, 1, -1], dtype='float32'))
        glDrawArrays(GL_QUADS, 0, 4)
        glDisable(GL_BLEND)
Example #20
0
def draw_helix_memoized(p, n, r, pitch=1, turns=1.0, sides=64):
    """Draw helix given point, normal vector, radius, pitch, # turns, and # sides.
    Uses the function compute_helix to generate points.
    """
    vertices, count = compute_helix(*p, *n, r, pitch, turns, sides)

    # draw vertices
    glEnableClientState(GL_VERTEX_ARRAY)
    glVertexPointer(3, GL_FLOAT, 0, vertices)
    glDrawArrays(GL_LINE_STRIP, 0, count)
    glDisableClientState(GL_VERTEX_ARRAY)
def main():
    # Initialize the library
    if not glfw.init():
        return
    # Create a windowed mode window and its OpenGL context
    window = glfw.create_window(640, 480, "Triangle_test", None, None)
    if not window:
        glfw.terminate()
        return

    # Make the window's context current
    glfw.make_context_current(window)
    glfw.window_hint(
        glfw.CONTEXT_VERSION_MAJOR,
        3)  # didn't find it in docs, just in __init__.py of glfwpy in git.
    glfw.window_hint(glfw.CONTEXT_VERSION_MINOR,
                     2)  # works, ofc, well with 120 shaders and 330.
    glClearColor(0.85, 0.9, 0.85, 0)  # background color
    program = ShaderProgram(vertpath="test_vert.glsl",
                            fragpath="test_frag.glsl")
    vao_id = getTriangleVAO(program)
    vao_id1 = getTriangleVAO1(program)
    # Loop until the user closes the window
    while not glfw.window_should_close(window):
        # Render here, e.g. using pyOpenGL
        glClear(GL_COLOR_BUFFER_BIT)
        # use our shader program in this part -> make program object to be a part of a rendering process.
        glUseProgram(program.program_id)
        # use vao with coords and colors buffers for triangle
        glBindVertexArray(vao_id)
        # how to draw
        glDrawArrays(GL_TRIANGLES, 0, 3)
        # unbind shader program
        glUseProgram(0)
        # unbind vao
        glBindVertexArray(0)
        # here we can draw something another
        # some more objects in another vao.
        glUseProgram(program.program_id)
        # use vao with coords and colors buffers for triangle
        glBindVertexArray(vao_id1)
        # how to draw
        glDrawArrays(GL_TRIANGLES, 0, 3)
        # unbind shader program
        glUseProgram(0)
        # unbind vao
        glBindVertexArray(0)
        # Swap front and back buffers
        glfw.swap_buffers(window)
        # Poll for and process events
        glfw.poll_events()

    glfw.terminate()
Example #22
0
	def _render(self, stage, projection_matrix, modelCamera_matrix):
		# Run the pre-render
		shader = super(TextActor, self)._prerender(stage, projection_matrix, modelCamera_matrix)
		
		# Update the values in the VBO
		a = self._getVertexData()
		self.vbo.set_array(array(a, 'f'))
		
		# Render
		glDrawArrays(GL_TRIANGLES, 0, len(self.vbo) / 4)
		
		# Post render
		super(TextActor, self)._postrender(stage, shader)
Example #23
0
 def draw_detector(self):
     glUseProgram(self.shader)
     try:
         self.dom_positions_vbo.bind()
         try:
             glEnableClientState(GL_VERTEX_ARRAY)
             glVertexPointerf(self.dom_positions_vbo)
             glPointSize(2)
             glDrawArrays(GL_POINTS, 0, len(self.dom_positions)*3)
         finally:
             self.dom_positions_vbo.unbind()
             glDisableClientState(GL_VERTEX_ARRAY)
     finally:
         glUseProgram(0)
Example #24
0
    def draw(self, spaces):
        glBindVertexArray(self._vao)
        if self._points.bind(0) and self._chars.bind(1):
            self._program.activate()
            self._program.set_uniform('projection_view',
                                      spaces.projection_view)
            self._program.set_uniform('model', spaces.model.m)
            self._program.set_uniform('color', spaces.tint)
            # self._program.set_uniform('size', 8)
            self._program.set_uniform('sprite_texture', 0)

            glDrawArrays(GL_POINTS, 0, len(self._points))

        glBindVertexArray(0)
Example #25
0
    def draw(self, program):
        if self.cull_face:
            glDisable(GL_CULL_FACE)

        program.setInt("diffuseTexture", 0)
        glActiveTexture(GL_TEXTURE0)
        glBindTexture(GL_TEXTURE_2D, self.texture)

        glBindVertexArray(self.VAO)
        glDrawArrays(GL_TRIANGLES, 0, self.__indicesLen)
        glBindVertexArray(0)

        if self.cull_face:
            glEnable(GL_CULL_FACE)
Example #26
0
    def paint_rgb24(self, img_data, x, y, width, height, rowstride):
        # OpenGL begin
        if not self.gldrawable.gl_begin(self.glcontext):
            log.error("OUCH")
            return False

        # Upload texture
        if not self.texture:
            self.texture = glGenTextures(1)

        glBindTexture(GL_TEXTURE_RECTANGLE_ARB, self.texture)
        glEnable(GL_TEXTURE_RECTANGLE_ARB)
        glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)
        glPixelStorei(GL_UNPACK_ROW_LENGTH, rowstride/3)
        glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, img_data);

        vtxarrays=1
        if vtxarrays == 1:
            texcoords = [ [ 0, 0 ],
                          [ 0, height],
                          [ width, height],
                          [ width, 0] ]
            vtxcoords = texcoords

            glVertexPointeri(vtxcoords)
            glTexCoordPointeri(texcoords)
            glDrawArrays(GL_QUADS, 0, 4);
        else:
            glBegin(GL_QUADS);
            glTexCoord2i(0, 0);
            glVertex2i(0, 0);

            glTexCoord2i(0, height);
            glVertex2i(0, height);

            glTexCoord2i(width, height);
            glVertex2i(width, height);

            glTexCoord2i(width, 0);
            glVertex2i(width, 0);
            glEnd()

        # OpenGL end
#self.gldrawable.swap_buffers()
#       self.gldrawable.swap_buffers()
        glFinish()
        self.gldrawable.gl_end()
Example #27
0
    def paint_rgb24(self, img_data, x, y, width, height, rowstride):
        # OpenGL begin
        if not self.gldrawable.gl_begin(self.glcontext):
            log.error("OUCH")
            return False

        # Upload texture
        if not self.texture:
            self.texture = glGenTextures(1)

        glBindTexture(GL_TEXTURE_RECTANGLE_ARB, self.texture)
        glEnable(GL_TEXTURE_RECTANGLE_ARB)
        glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
                        GL_NEAREST)
        glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
                        GL_NEAREST)
        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)
        glPixelStorei(GL_UNPACK_ROW_LENGTH, rowstride / 3)
        glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, width, height, 0,
                     GL_RGB, GL_UNSIGNED_BYTE, img_data)

        vtxarrays = 1
        if vtxarrays == 1:
            texcoords = [[0, 0], [0, height], [width, height], [width, 0]]
            vtxcoords = texcoords

            glVertexPointeri(vtxcoords)
            glTexCoordPointeri(texcoords)
            glDrawArrays(GL_QUADS, 0, 4)
        else:
            glBegin(GL_QUADS)
            glTexCoord2i(0, 0)
            glVertex2i(0, 0)

            glTexCoord2i(0, height)
            glVertex2i(0, height)

            glTexCoord2i(width, height)
            glVertex2i(width, height)

            glTexCoord2i(width, 0)
            glVertex2i(width, 0)
            glEnd()

        # OpenGL end
#self.gldrawable.swap_buffers()
#       self.gldrawable.swap_buffers()
        glFinish()
        self.gldrawable.gl_end()
Example #28
0
    def on_render(self, area, *args):
        area.attach_buffers()

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        glUseProgram(self.shaderContent.shader_prog)
        self.timer()
        glUniform1f(self.time_l, self.time)
        glBindVertexArray(self.vertex_array_object)
        glDrawArrays(GL_TRIANGLES, 0, 6)
        glBindVertexArray(0)

        glUseProgram(0)
        glFlush()
        self.shaderContent.queue_render()
        return True
Example #29
0
    def render(self) -> None:
        """Render colored axes and arrows."""
        if self._quadric is None:
            return

        glBindVertexArray(self._vao_axes)
        glDrawArrays(GL_LINES, 0, 6)
        glBindVertexArray(self._vao_arrows[0])
        glMultiDrawArrays(GL_TRIANGLE_FAN, (0, 17, 34), (17, 17, 17), 3)
        glFrontFace(GL_CW)
        glBindVertexArray(self._vao_arrows[1])
        glMultiDrawArrays(GL_TRIANGLE_FAN, (0, 17, 34), (17, 17, 17), 3)
        glFrontFace(GL_CCW)

        glBindVertexArray(0)
Example #30
0
def draw_points():
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    glEnableClientState(GL_VERTEX_ARRAY)
    # glVertexPointer(3, GL_FLOAT, 24, points)
    # glColorPointer(3, GL_INT, 24, points+12)
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 24, points)
    glEnableVertexAttribArray(0)
    glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 24, points + 12)
    glEnableVertexAttribArray(1)

    glDrawArrays(GL_POINTS, 0, imgnp.shape[0] * imgnp.shape[1])

    glDisableVertexAttribArray(0)
    glDisableVertexAttribArray(1)
    glutSwapBuffers()
Example #31
0
    def _render_highlighted(self) -> None:
        """Render cube outline on face that is hovered."""
        if not self._hovered:
            return

        glDisable(GL_DEPTH_TEST)
        glLineWidth(2.0)
        glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)

        glBindVertexArray(self._vao_outline)
        glDrawArrays(GL_QUADS, self._hover_id * 4, 4)

        glEnable(GL_DEPTH_TEST)
        glLineWidth(1.0)
        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
Example #32
0
    def Render(self, mode):
        """Render the geometry for the scene."""

        shaders.glUseProgram(self.shader)
        try:
            self.vbo.bind()
            try:
                glEnableClientState(GL_VERTEX_ARRAY)
                GLVertexPointer(self.vbo)
                glDrawArrays(GL_TRIANGLES, 0, 9)
            finally:
                self.vbo.unbind()
                glDisableClientState(GL_VERTEX_ARRAY)
        finally:
            shaders.glUseProgram(0)
Example #33
0
    def draw_vertices(self):
        # Draw all the vbo defined in set_atoms
        glEnableClientState(GL_VERTEX_ARRAY)
        self._vbo_v.bind_vertexes(3, GL_FLOAT)

        glEnableClientState(GL_NORMAL_ARRAY)
        self._vbo_n.bind_normals(GL_FLOAT)

        glEnableClientState(GL_COLOR_ARRAY)
        self._vbo_c.bind_colors(4, GL_UNSIGNED_BYTE)

        glDrawArrays(GL_TRIANGLES, 0, self._n_triangles)

        self._vbo_v.unbind()
        self._vbo_n.unbind()
        self._vbo_c.unbind()
Example #34
0
    def draw(self):
        glDisable(GL_LIGHTING)

        glLineWidth(self._width)
        glColor(*self._color)

        glEnableClientState(GL_VERTEX_ARRAY)

        if self._vbo:
            with self._vbo:
                glVertexPointerf(self._vbo)
                glDrawArrays(GL_LINE_STRIP, 0, len(self._vbo))

        glDisableClientState(GL_VERTEX_ARRAY)

        glEnable(GL_LIGHTING)
Example #35
0
    def draw_vertices(self):
        # Draw all the vbo defined in set_atoms
        glEnableClientState(GL_VERTEX_ARRAY)
        self._vbo_v.bind_vertexes(3, GL_FLOAT)

        glEnableClientState(GL_NORMAL_ARRAY)
        self._vbo_n.bind_normals(GL_FLOAT)

        glEnableClientState(GL_COLOR_ARRAY)
        self._vbo_c.bind_colors(4, GL_UNSIGNED_BYTE)

        glDrawArrays(GL_TRIANGLES, 0, self._n_triangles)

        self._vbo_v.unbind()
        self._vbo_n.unbind()
        self._vbo_c.unbind()
Example #36
0
    def paintGL(self):
        """
        Drawing routing
        """
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        glLoadIdentity()

        #Draw spiral in 'immediate mode'
        #WARNING: You should not be doing the spiral calculation inside the loop
        #even if you are using glBegin/glEnd, sin/cos are fairly expensive functions
        #For now left here to make code simpler
        radius = 1.0
        x = radius * math.sin(0)
        y = radius * math.cos(0)
        glColor(0.0, 1.0, 0.0)

        glBegin(GL_LINE_STRIP)
        for deg in range(1000):
            glVertex(x, y, 0.0)
            rad = math.radians(deg)
            radius -= 0.001
            x = radius * math.sin(rad)
            y = radius * math.cos(rad)
        glEnd()

        glEnableClientState(GL_VERTEX_ARRAY)

        #TODO: Use list comprehension
        spiral_array = []

        #Second spiral using "array immediate mode" (i.e vertex arrays)
        radius = 0.8
        x = radius * math.sin(0)
        y = radius * math.cos(0)

        glColor(1.0, 0.0, 0.0)
        for deg in range(820):
            spiral_array.append([x, y])
            rad = math.radians(deg)
            radius -= 0.001
            x = radius * math.sin(rad)
            y = radius * math.cos(rad)

        glVertexPointerf(spiral_array)
        glDrawArrays(GL_LINE_STRIP, 0, len(spiral_array))
        glFlush()
Example #37
0
    def display(self):
        self.world.drawGL()

        glDisable(GL_LIGHTING)
        glLineWidth(2.0)

        glEnableClientState(GL_VERTEX_ARRAY)

        for (color, vbo) in self.trace_vbos:
            glColor(*color)
            with vbo:
                glVertexPointerf(vbo)
                glDrawArrays(GL_LINE_STRIP, 0, len(vbo))

        glDisableClientState(GL_VERTEX_ARRAY)

        glEnable(GL_LIGHTING)
    def _do_render(self, **kwargs):

        if 'objects' not in kwargs.keys():
            return

        instances = kwargs['objects']

        for instance in instances:
            glBindVertexArray(instance.vao_id)
            glEnableVertexAttribArray(0)
            glEnableVertexAttribArray(1)

            glDrawArrays(instance.get_draw_mode(), 0, instance.vertex_count)

            glDisableVertexAttribArray(0)
            glDisableVertexAttribArray(1)
            glBindVertexArray(0)
Example #39
0
    def render(self):
        """Render game world."""

        for vbo in self.vbos:

            if vbo.render:

                glBindBuffer(GL_ARRAY_BUFFER, vbo.name)
                glEnableVertexAttribArray(0)
                glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, None)

                glDrawArrays(
                    GL_TRIANGLES,
                    0,
                    vbo.vertexes_count)
                glDisableVertexAttribArray(0)
                glBindBuffer(GL_ARRAY_BUFFER, 0)
Example #40
0
File: Ray.py Project: meuns/Sandbox
def display_lines(resources, view_projection, iteration):

    glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT)
    glEnable(GL_BLEND)
    glBlendEquation(GL_FUNC_ADD)
    glBlendFunc(GL_ONE, GL_ONE)
    glBindVertexArray(resources.display_vertex_array)
    glUseProgram(resources.display_program)
    update_view_projection(view_projection)
    glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, _select_input_buffer(resources, iteration))
    glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, _select_output_buffer(resources, iteration))
    glDrawArrays(GL_LINES, 0, RAY_COUNT << 1)
    glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, 0)
    glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, 0)
    glUseProgram(0)
    glBindVertexArray(0)
    glDisable(GL_BLEND)
Example #41
0
 def render_frame(self, x_position, y_position, vx, vy, vz, asize):
     glClear(GL_COLOR_BUFFER_BIT)
     with self.shader:
         x_position = x_position * 0.89
         y_position = y_position * 0.67
         glUniform1f(self.xpos, x_position)
         glUniform1f(self.ypos, y_position)
         glUniform1f(self.vdir_x, vx)
         glUniform1f(self.vdir_y, vy)
         glUniform1f(self.vdir_z, vz)
         glUniform1f(self.arrow_size, asize)
         glUniform3f(self.res_loc, self.width, self.height, 1.0)
         glEnableVertexAttribArray(0)
         glVertexAttribPointer(0, 2, GL_FLOAT, False, 0, VERTEX_POSITIONS)
         glDrawArrays(GL_TRIANGLE_STRIP, 0, 4)
     img_buf = glReadPixels(0, 0, self.width, self.height, GL_RGB, GL_UNSIGNED_BYTE)
     img = np.frombuffer(img_buf, np.uint8).reshape(self.height, self.width, 3)[::-1]
     return img
Example #42
0
def draw_circle_trig(p, n, r, sides=36):
    """Draw circle given point, normal vector, radius, and # sides."""
    a, b, n = rotate_basis(*n)
    tau = 6.28318530717958647692

    count = sides + 1
    vertices = np.empty(count * 3)
    for i in range(count):
        vertices[i * 3] = p[0] + r * (a[0] * math.cos(i * tau / sides) +
                                      b[0] * math.sin(i * tau / sides))
        vertices[i * 3 + 1] = p[1] + r * (a[1] * math.cos(i * tau / sides) +
                                          b[1] * math.sin(i * tau / sides))
        vertices[i * 3 + 2] = p[2] + r * (a[2] * math.cos(i * tau / sides) +
                                          b[2] * math.sin(i * tau / sides))

    # draw vertices
    glEnableClientState(GL_VERTEX_ARRAY)
    glVertexPointer(3, GL_FLOAT, 0, vertices)
    glDrawArrays(GL_LINE_STRIP, 0, count)
    glDisableClientState(GL_VERTEX_ARRAY)
Example #43
0
    def render_image(self):
        drawable = self.glarea.get_gl_drawable()
        context = self.glarea.get_gl_context()
        w, h = self.get_size()
        if not drawable.gl_begin(context):
            raise Exception("** Cannot create OpenGL rendering context!")
        texcoords = [ [ 0, 0 ],
                      [ 0, h ],
                      [ w, h ],
                      [ w, 0 ] ]
        vtxcoords = texcoords

        if self.current_mode == GLClientWindow.MODE_RGB:
            glVertexPointeri(vtxcoords)
            glTexCoordPointeri(texcoords)
            glDrawArrays(GL_QUADS, 0, 4);
        elif self.current_mode == GLClientWindow.MODE_YUV:
            glEnable(GL_FRAGMENT_PROGRAM_ARB)
            glBegin(GL_QUADS);
            glMultiTexCoord2i(GL_TEXTURE0, 0, 0);
            glMultiTexCoord2i(GL_TEXTURE1, 0, 0);
            glMultiTexCoord2i(GL_TEXTURE2, 0, 0);
            glVertex2i(0, 0);

            glMultiTexCoord2i(GL_TEXTURE0, 0, h);
            glMultiTexCoord2i(GL_TEXTURE1, 0, h/2);
            glMultiTexCoord2i(GL_TEXTURE2, 0, h/2);
            glVertex2i(0, h);

            glMultiTexCoord2i(GL_TEXTURE0, w, h);
            glMultiTexCoord2i(GL_TEXTURE1, w/2, h/2);
            glMultiTexCoord2i(GL_TEXTURE2, w/2, h/2);
            glVertex2i(w, h);

            glMultiTexCoord2i(GL_TEXTURE0, w, 0);
            glMultiTexCoord2i(GL_TEXTURE1, w/2, 0);
            glMultiTexCoord2i(GL_TEXTURE2, w/2, 0);
            glVertex2i(w, 0);
            glEnd()
        drawable.swap_buffers()
        drawable.gl_end()
Example #44
0
    def paint(self):
        """
        For all of the known terrain, render whatever faces are exposed.
        """
        if self._texture is None:
            self._texture = self._createTexture()

        glBindTexture(GL_TEXTURE_2D, self._texture)
        glEnableClientState(GL_VERTEX_ARRAY)
        glEnableClientState(GL_TEXTURE_COORD_ARRAY)
        for surface in self._vbos:
            vbo = surface.update
            length = surface.important
            vbo.bind()
            glVertexPointer(3, GL_FLOAT, 4 * 5, vbo)
            glTexCoordPointer(2, GL_FLOAT, 4 * 5, vbo + (4 * 3))
            glDrawArrays(GL_TRIANGLES, 0, length)
            vbo.unbind()
        glDisableClientState(GL_VERTEX_ARRAY)
        glDisableClientState(GL_TEXTURE_COORD_ARRAY)
        glBindTexture(GL_TEXTURE_2D, 0)
Example #45
0
File: graph.py Project: reims/wesen
 def Draw(self):
     """draw a curve of all previous data,
     up to a certain point (self.resolution)"""
     self.vbo.bind()
     self.vbo.copy_data()
     glEnableClientState(GL_VERTEX_ARRAY)
     glVertexPointer(2, GL_FLOAT, 0, self.vbo)
     if self.buffer_full:
         if self.previous_index != self.size - 1:
             glPushMatrix()
             glTranslatef(-1 * (self.previous_index + 1), 0.0, 0.0)
             glDrawArrays(GL_LINE_STRIP,
                          (self.previous_index + 1),
                          (self.size - self.previous_index - 1))
             glPopMatrix()
         glPushMatrix()
         glTranslatef(self.size - self.previous_index - 1, 0.0, 0.0)
         glDrawArrays(GL_LINE_STRIP, 0,
                      (self.previous_index + 1))
         glPopMatrix()
     else:
         glDrawArrays(GL_LINE_STRIP, 0,
                      (self.previous_index + 1))
     glDisableClientState(GL_VERTEX_ARRAY)
     self.vbo.unbind()
Example #46
0
File: map.py Project: reims/wesen
 def Draw(self, descriptor=[]):
     """Draws a map with all objects in the world,
     according to the descriptor."""
     GuiObject.Draw(self)
     # TODO get rid of any frame mechanism parts here
     frame = self._getFrameData()["frame"]
     glTranslatef(frame, 2 * frame, 0.0)
     # moving away from the frame
     blockSize = (1 - 2 * frame) / self.worldLength
     scaleFactor = blockSize
     # data = narray(reduce(lambda a,b: a + b,
     # 		     map(self.__descToArray,
     # 			 descriptor)),
     # 	      "f");
     if len(descriptor) > 0:
         # valuesPerObject = len(self.__descToArray(descriptor[0]))
         if self._vbo is None:
             self._BuildData(descriptor)
         for _id, obj in self._dirty_objects.items():
             self._UpdateObject(_id, obj)
         self._dirty_objects = {}
         glTranslatef(frame, 2 * frame, 0.0)
         # moving away from the frame
         glScale(scaleFactor, scaleFactor, 1.0)
         self._vbo.bind()
         self._vbo.copy_data()
         try:
             glEnableClientState(GL_VERTEX_ARRAY)
             glEnableClientState(GL_COLOR_ARRAY)
             # 2 coordinates with 4 color values with 4 bytes each in
             # between
             glVertexPointer(2, GL_FLOAT, 24, self._vbo)
             # 4 color values with 2 coordinates with 4 bytes each in
             # between
             glColorPointer(4, GL_FLOAT, 24, self._vbo + 8)
             glDrawArrays(GL_TRIANGLES, 0, 3 * 2 * (self._max_index + 1))
         finally:
             self._vbo.unbind()
             glDisableClientState(GL_VERTEX_ARRAY)
             glDisableClientState(GL_COLOR_ARRAY)
Example #47
0
    glBindBuffer(GL_ARRAY_BUFFER, 0)
    glBindVertexArray(0)

    running = True

    while running:
        glClear(GL_COLOR_BUFFER_BIT)

        # Specify shader to be used
        glUseProgram(program.program_id)

        # Bind VAO - this will automatically
        # bind all the vbo's saving us a bunch
        # of calls
        glBindVertexArray(vao_id)

        # Modern GL makes the draw call really simple
        # All the complexity has been pushed elsewhere
        glDrawArrays(GL_TRIANGLES, 0, 3)

        # Lets unbind the shader and vertex array state
        glUseProgram(0)
        glBindVertexArray(0)

        # Now lets show our master piece on the screen
        SwapBuffers()

        # If the user has closed the window in anger
        # then terminate this program
        running = running and GetWindowParam(OPENED)
Example #48
0
def drawsphere_worker(params):
    """
    Draw a sphere.  Receive parameters through a sequence so that this function
    and its parameters can be passed to another function for deferment.  Right
    now this is only ColorSorter.schedule (see below)
    """

    (pos, radius, detailLevel, n) = params
    del n

    # KLUGE: the detailLevel can be a tuple, (vboLevel, detailLevel).
    # The only for reason for this is that drawsphere_worker is used
    # in ProteinChunks (I added a comment there saying why that's bad)
    # and I don't have time to clean that up now. Ideally, vboLevel
    # would just be another parameter, or we'd combine it with detailLevel
    # in some other way not constrained by backward compatibility of
    # this internal worker function's API. [bruce 090304]
    if type(detailLevel) == type(()):
        (vboLevel, detailLevel) = detailLevel

    ## vboLevel = drawing_globals.use_drawing_variant

    glPushMatrix()
    glTranslatef(pos[0], pos[1], pos[2])
    glScale(radius,radius,radius)

    if vboLevel == 0:  # OpenGL 1.0 - glBegin/glEnd tri-strips vertex-by-vertex.
        glCallList(drawing_globals.sphereList[detailLevel])

    else:                             # OpenGL 1.1/1.5 - Array/VBO/IBO variants.
        glEnableClientState(GL_VERTEX_ARRAY)
        glEnableClientState(GL_NORMAL_ARRAY)

        size = len(drawing_globals.sphereArrays[detailLevel])
        GLIndexType = drawing_globals.sphereGLIndexTypes[detailLevel]

        if vboLevel == 1:               # DrawArrays from CPU RAM.
            verts = drawing_globals.sphereCArrays[detailLevel]
            glVertexPointer(3, GL_FLOAT, 0, verts)
            glNormalPointer(GL_FLOAT, 0, verts)
            glDrawArrays(GL_TRIANGLE_STRIP, 0, size)

        elif vboLevel == 2:             # DrawElements from CPU RAM.
            verts = drawing_globals.sphereCElements[detailLevel][1]
            glVertexPointer(3, GL_FLOAT, 0, verts)
            glNormalPointer(GL_FLOAT, 0, verts)
            # Can't use the C index in sphereCElements yet, fatal PyOpenGL bug.
            index = drawing_globals.sphereElements[detailLevel][0]
            glDrawElements(GL_TRIANGLE_STRIP, size, GLIndexType, index)

        elif vboLevel == 3:             # DrawArrays from graphics RAM VBO.
            vbo = drawing_globals.sphereArrayVBOs[detailLevel]
            vbo.bind()
            glVertexPointer(3, GL_FLOAT, 0, None)
            glNormalPointer(GL_FLOAT, 0, None)
            glDrawArrays(GL_TRIANGLE_STRIP, 0, vbo.size)
            vbo.unbind()

        elif vboLevel == 4: # DrawElements from index in CPU RAM, verts in VBO.
            vbo = drawing_globals.sphereElementVBOs[detailLevel][1]
            vbo.bind()              # Vertex and normal data comes from the vbo.
            glVertexPointer(3, GL_FLOAT, 0, None)
            glNormalPointer(GL_FLOAT, 0, None)
            # Can't use the C index in sphereCElements yet, fatal PyOpenGL bug.
            index = drawing_globals.sphereElements[detailLevel][0]
            glDrawElements(GL_TRIANGLE_STRIP, size, GLIndexType, index)
            vbo.unbind()

        elif vboLevel == 5: # VBO/IBO buffered DrawElements from graphics RAM.
            (ibo, vbo) = drawing_globals.sphereElementVBOs[detailLevel]
            vbo.bind()              # Vertex and normal data comes from the vbo.
            glVertexPointer(3, GL_FLOAT, 0, None)
            glNormalPointer(GL_FLOAT, 0, None)
            ibo.bind()              # Index data comes from the ibo.
            glDrawElements(GL_TRIANGLE_STRIP, size, GLIndexType, None)
            vbo.unbind()
            ibo.unbind()
            pass

        glDisableClientState(GL_VERTEX_ARRAY)
        glDisableClientState(GL_NORMAL_ARRAY)
        pass

    glPopMatrix()
    return
 def drawpiece(self,piece):
     try:
         glDrawArrays(*self.tnv['pieces'][piece])
     except IndexError:
         pass    # that piece isn't there!
    def OnPaint(self, event):
#         startTime = time.time()
        if not self.init:
            self.context = GLContext(self)
            self.SetCurrent(self.context)
            glEnable(GL_DEPTH_TEST);
            self.init = True
            
        if self._refreshAll:  
            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
            glLoadIdentity()
#             prepareTime = time.time() - startTime
            if self.dataNum == 0:
                self.SwapBuffers()
                return
            
            eyePos = self.eyeDistance
            ex = 0.0
            ey = 0.0
            ez = 0.0
            dx = 0.0
            dy = 0.0
            dz = 0.0
            ux = 0.0
            uy = 0.0
            uz = 0.0
            xLen = max(abs(self.xMax), abs(self.xMin)) * 2
            yLen = max(abs(self.yMax), abs(self.yMin)) * 2
            zLen = max(abs(self.zMax), abs(self.zMin)) * 2
#             print 'transX, transY:', self.transX, self.transY
            if self.is3D:
                r2s = max(xLen, yLen, zLen) / self.size.width
                tX = self.transX * r2s
                tY = self.transY * r2s
                if not zLen == 0:
                    z = zLen / 2
                    if yLen / zLen > self.size.width / self.size.height:
                        z = yLen * self.size.height / self.size.width / 2
                    z *= 1.5
                    usedAngle = pi / 2 - viewPosAngle
                    cfovy1 = (eyePos - z * cos(usedAngle)) / sqrt(eyePos * eyePos + z * z - 2 * eyePos * z * cos(usedAngle))
                    cfovy2 = (eyePos - z * cos(pi - usedAngle)) / sqrt(eyePos * eyePos + z * z - 2 * eyePos * z * cos(pi - usedAngle))
                    fovy1 = degrees(acos(cfovy1))
                    fovy2 = degrees(acos(cfovy2))
                    self.fovy = 3 * max(fovy1, fovy2)
                angleX = viewPosAngle + radians(self.angleHorizontal)
                angleZ = viewPosAngle + radians(self.angleVertical)
                ex = eyePos * cos(angleZ) * cos(angleX)
                ey = eyePos * cos(angleZ) * sin(angleX)
                ez = eyePos * sin(angleZ)
                ux = 0.0
                uy = cos(pi / 2 - radians(self.angleFlat))
                uz = sin(pi / 2 - radians(self.angleFlat))
                flatAngle = radians(self.angleFlat)
                dx = -tX * cos(flatAngle) * sin(angleX) - tX * sin(flatAngle) * sin(angleZ) * sin(angleX)
                dx += tY * sin(flatAngle) * sin(angleX) - tY * cos(flatAngle) * sin(angleZ) * cos(angleX)
                dy = tX * cos(flatAngle) * cos(angleX) - tX * sin(flatAngle) * sin(angleZ) * cos(angleX)
                dy += -tY * sin(flatAngle) * cos(angleX) - tY * cos(flatAngle) * sin(angleZ) * sin(angleX)
                dz = tX * sin(flatAngle) * cos(angleZ)
                dz += tY * cos(flatAngle) * cos(angleZ)
            else:
                r2s = xLen / self.size.width
                dx = self.transX * r2s
                dy = self.transY * r2s
                dz = 0.0
                y = yLen / 2
                if xLen / yLen > self.size.width / self.size.height:
                    y = xLen * self.size.height / self.size.width / 2
                y += yLen / 10
                self.fovy = 2 * degrees(atan(y / eyePos))
                ez = eyePos
                ux = sin(radians(self.angleFlat))
                uy = cos(radians(self.angleFlat))
                uz = 0.0
            scale = 1
            if self.size != None:
                scale = float(self.size.width) / self.size.height               
#             userCalculationTime = time.time() - startTime - prepareTime
        
            glMatrixMode(GL_PROJECTION)
            glLoadIdentity()
            if self.is3D:
                gluPerspective(self.fovy * self.scaleFactor, scale, 0.1, self.eyeDistance * 2)
            else:
                gluPerspective(self.fovy * self.scaleFactor, scale,
                               self.eyeDistance - self.zMax - 10, self.eyeDistance - self.zMin + 10)
            glMatrixMode(GL_MODELVIEW)
            glLoadIdentity()
            gluLookAt(ex, ey, ez, -dx, -dy, -dz, ux, uy, uz)
            self._startPointIdx = 0
            
        if self.isDragging:
            # draw the frame instead of all data
            glLineWidth(1.0)
            glColor3f(0.0, 0.5, 0.0)
            glBegin(GL_LINES)
            glVertex3f(self.xMin, self.yMin, self.zMin)  # 1
            glVertex3f(self.xMax, self.yMin, self.zMin)  # 2
            
            glVertex3f(self.xMax, self.yMin, self.zMin)  # 2
            glVertex3f(self.xMax, self.yMax, self.zMin)  # 3
            
            glVertex3f(self.xMax, self.yMax, self.zMin)  # 3
            glVertex3f(self.xMin, self.yMax, self.zMin)  # 4
            
            glVertex3f(self.xMin, self.yMax, self.zMin)  # 4
            glVertex3f(self.xMin, self.yMin, self.zMin)  # 1
            
            glVertex3f(self.xMin, self.yMin, self.zMin)  # 1
            glVertex3f(self.xMin, self.yMin, self.zMax)  # 5
            
            glVertex3f(self.xMin, self.yMin, self.zMax)  # 5
            glVertex3f(self.xMax, self.yMin, self.zMax)  # 6
            
            glVertex3f(self.xMax, self.yMin, self.zMax)  # 6
            glVertex3f(self.xMax, self.yMax, self.zMax)  # 7
            
            glVertex3f(self.xMax, self.yMax, self.zMax)  # 7
            glVertex3f(self.xMin, self.yMax, self.zMax)  # 8
            
            glVertex3f(self.xMin, self.yMax, self.zMax)  # 8
            glVertex3f(self.xMin, self.yMin, self.zMax)  # 5
            
            glVertex3f(self.xMax, self.yMin, self.zMin)  # 2
            glVertex3f(self.xMax, self.yMin, self.zMax)  # 6
            
            glVertex3f(self.xMax, self.yMax, self.zMin)  # 3
            glVertex3f(self.xMax, self.yMax, self.zMax)  # 7
            
            glVertex3f(self.xMin, self.yMax, self.zMin)  # 4
            glVertex3f(self.xMin, self.yMax, self.zMax)  # 8
            
            glEnd()
            glFlush()
            self.SwapBuffers()
            return
            
        glEnableClientState(GL_VERTEX_ARRAY)
        if self.colorsNum >= self.dataNum:
            glEnableClientState(GL_COLOR_ARRAY)
            
        glDrawBuffer(GL_FRONT_AND_BACK)
                
        if self._startPointIdx + self._drawnPointsNum >= self.dataNum:
            glDrawArrays(GL_POINTS, self._startPointIdx, self.dataNum - self._startPointIdx)
            if self.displaySelected:
                selNum = len(self.displayedSelPoints)
                if selNum >= 2:
                    glLineWidth(2.0)
                    glColor3f(0.0, 1.0, 0.0)
                    glBegin(GL_LINES)
                    for i in xrange(1, selNum):
                        glVertex3f(self.displayedSelPoints[i - 1][0],
                                   self.displayedSelPoints[i - 1][1],
                                   self.displayedSelPoints[i - 1][2])
                        glVertex3f(self.displayedSelPoints[i][0],
                                   self.displayedSelPoints[i][1],
                                   self.displayedSelPoints[i][2])
                    glVertex3f(self.displayedSelPoints[selNum - 1][0],
                               self.displayedSelPoints[selNum - 1][1],
                               self.displayedSelPoints[selNum - 1][2])
                    glVertex3f(self.displayedSelPoints[0][0],
                               self.displayedSelPoints[0][1],
                               self.displayedSelPoints[0][2])
                    glEnd()
            self._refreshAll = True
        else:
            glDrawArrays(GL_POINTS, self._startPointIdx, self._drawnPointsNum)
            self._refreshAll = False
            self._isFront = not self._isFront
            self._startPointIdx += self._drawnPointsNum if self._isFront else 0
            
        glDisableClientState(GL_VERTEX_ARRAY)
        if self.colorsNum >= self.dataNum:
            glDisableClientState(GL_COLOR_ARRAY)
        glFlush()
        self.SwapBuffers()
#         drawingTime = time.time() - startTime - prepareTime - userCalculationTime
#         print "preparation time:", str(prepareTime), "user calculation time:",\
#             str(userCalculationTime), "drawing time:", str(drawingTime)
        if not self._refreshAll:
            PostEvent(self, PaintEvent())
        event.Skip()
Example #51
0
def drawsphere_worker(params):
    """
    Draw a sphere.  Receive parameters through a sequence so that this function
    and its parameters can be passed to another function for deferment.  Right
    now this is only ColorSorter.schedule (see below)
    """

    (pos, radius, detailLevel) = params

    vboLevel = drawing_globals.use_drawing_variant

    glPushMatrix()
    glTranslatef(pos[0], pos[1], pos[2])
    glScale(radius,radius,radius)

    if vboLevel == 0:
        glCallList(drawing_globals.sphereList[detailLevel])
    else:                               # Array variants.
        glEnableClientState(GL_VERTEX_ARRAY)
        glEnableClientState(GL_NORMAL_ARRAY)

        size = len(drawing_globals.sphereArrays[detailLevel])
        GLIndexType = drawing_globals.sphereGLIndexTypes[detailLevel]

        if vboLevel == 1:               # DrawArrays from CPU RAM.
            verts = drawing_globals.sphereCArrays[detailLevel]
            glVertexPointer(3, GL_FLOAT, 0, verts)
            glNormalPointer(GL_FLOAT, 0, verts)
            glDrawArrays(GL_TRIANGLE_STRIP, 0, size)

        elif vboLevel == 2:             # DrawElements from CPU RAM.
            verts = drawing_globals.sphereCElements[detailLevel][1]
            glVertexPointer(3, GL_FLOAT, 0, verts)
            glNormalPointer(GL_FLOAT, 0, verts)
            # Can't use the C index in sphereCElements yet, fatal PyOpenGL bug.
            index = drawing_globals.sphereElements[detailLevel][0]
            glDrawElements(GL_TRIANGLE_STRIP, size, GLIndexType, index)

        elif vboLevel == 3:             # DrawArrays from graphics RAM VBO.
            vbo = drawing_globals.sphereArrayVBOs[detailLevel]
            vbo.bind()
            glVertexPointer(3, GL_FLOAT, 0, None)
            glNormalPointer(GL_FLOAT, 0, None)
            glDrawArrays(GL_TRIANGLE_STRIP, 0, vbo.size)
            vbo.unbind()

        elif vboLevel == 4: # DrawElements from index in CPU RAM, verts in VBO.
            vbo = drawing_globals.sphereElementVBOs[detailLevel][1]
            vbo.bind()              # Vertex and normal data comes from the vbo.
            glVertexPointer(3, GL_FLOAT, 0, None)
            glNormalPointer(GL_FLOAT, 0, None)
            # Can't use the C index in sphereCElements yet, fatal PyOpenGL bug.
            index = drawing_globals.sphereElements[detailLevel][0]
            glDrawElements(GL_TRIANGLE_STRIP, size, GLIndexType, index)
            vbo.unbind()

        elif vboLevel == 5: # VBO/IBO buffered DrawElements from graphics RAM.
            (ibo, vbo) = drawing_globals.sphereElementVBOs[detailLevel]
            vbo.bind()              # Vertex and normal data comes from the vbo.
            glVertexPointer(3, GL_FLOAT, 0, None)
            glNormalPointer(GL_FLOAT, 0, None)
            ibo.bind()              # Index data comes from the ibo.
            glDrawElements(GL_TRIANGLE_STRIP, size, GLIndexType, None)
            vbo.unbind()
            ibo.unbind()
            pass

        glDisableClientState(GL_VERTEX_ARRAY)
        glDisableClientState(GL_NORMAL_ARRAY)
        pass

    glPopMatrix()
    return
Example #52
0
def render_thing(thing, position_location, normal_location, color_location, modelview_location, context_matrix):
    try:
        translate = np.array(matrix_translate(thing["position"]), 'f')
    except:
        print "render_thing can't translate thing: ", thing
        exit()
    #print "render_thing type: ", thing["type"], thing["position"]
    context_matrix = np.dot(context_matrix, translate)

    rotates = thing["rotates"]
    if len(rotates) == 2:
        rotate0 = np.array(matrix_rotate_ortho(rotates[0]["angle"], rotates[0]["axis"]), 'f')
        tmp_matrix = np.dot(context_matrix, rotate0)
        rotate1 = np.array(matrix_rotate_ortho(rotates[1]["angle"], rotates[1]["axis"]), 'f')
        context_matrix = np.dot(tmp_matrix, rotate1)
    #print "render_thing:\n {}\n{}\n{}".format(translate, rotate0, rotate1)
    #print "context_matrix:\n", context_matrix
    glUniformMatrix4fv(modelview_location, 1, True, context_matrix)
    geometry = thing["geometry"]

    if geometry != None:
        if geometry["static"]:
            key = int(float(geometry["id"]))
            #print "thing type: {}, key: {}".format(thing["type"], key)
            if not key in vbos:
                vertices = geometry["vertices"]
                #print "adding geometry:\n{}".format(vertices[0])
                #vbos[key] = (vbo.VBO(np.array(vertices, 'f')), len(vertices))
                vbos[key] = (vbo.VBO(vertices), len(vertices))
            buffer_object, buffer_size = vbos[key]
        else:
            vertices = geometry["vertices"]
            buffer_object = vbo.VBO(vertices)
            buffer_size = len(vertices)
        #print "rendering type: {}, size: {}".format(buffer_object, buffer_size)
        #pdb.set_trace()
        buffer_object.bind()
        try:
            glEnableVertexAttribArray( position_location )
            glEnableVertexAttribArray( normal_location )
            glEnableVertexAttribArray( color_location )
            stride = 10*4
            glVertexAttribPointer(
                position_location,
                3, GL_FLOAT,False, stride, buffer_object
            )
            glVertexAttribPointer(
                normal_location,
                3, GL_FLOAT,False, stride, buffer_object+12
            )
            glVertexAttribPointer(
                color_location,
                4, GL_FLOAT,False, stride, buffer_object+24
            )
            glDrawArrays(GL_TRIANGLES, 0, buffer_size)
            #print 'buffer size: ', buffer_size

        finally:
            buffer_object.unbind()
            glDisableVertexAttribArray( position_location )
            glDisableVertexAttribArray( color_location )
    else:
        for child in thing["children"]:
            render_thing(child, position_location, normal_location, color_location, modelview_location, context_matrix)
Example #53
0
    def paint_yuv420(self, img_data, x, y, width, height, rowstrides):
        #import time
        #before=time.time()

        # OpenGL begin
        if not self.gldrawable.gl_begin(self.glcontext):
            log.error("OUCH")
            return False

        # Upload texture
        if self.textures[0] == 0:
            self.textures = glGenTextures(3)

        glEnable(GL_FRAGMENT_PROGRAM_ARB)

        if not self.yuv420_shader:
            self.yuv420_shader = [ 1 ]
            glGenProgramsARB(1, self.yuv420_shader)
            glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, self.yuv420_shader[0])
# The following fragprog is:
# * MIT X11 license, Copyright (c) 2007 by:
# *      Michael Dominic K. <*****@*****.**>
#http://www.mdk.org.pl/2007/11/17/gl-colorspace-conversions
            prog = """!!ARBfp1.0
# cgc version 3.1.0010, build date Feb 10 2012
# command line args: -profile arbfp1
# source file: yuv.cg
#vendor NVIDIA Corporation
#version 3.1.0.10
#profile arbfp1
#program main
#semantic main.IN
#var float2 IN.texcoord1 : $vin.TEXCOORD0 : TEX0 : 0 : 1
#var float2 IN.texcoord2 : $vin.TEXCOORD1 : TEX1 : 0 : 1
#var float2 IN.texcoord3 : $vin.TEXCOORD2 : TEX2 : 0 : 1
#var samplerRECT IN.texture1 : TEXUNIT0 : texunit 0 : 0 : 1
#var samplerRECT IN.texture2 : TEXUNIT1 : texunit 1 : 0 : 1
#var samplerRECT IN.texture3 : TEXUNIT2 : texunit 2 : 0 : 1
#var float4 IN.color : $vin.COLOR0 : COL0 : 0 : 1
#var float4 main.color : $vout.COLOR0 : COL : -1 : 1
#const c[0] = 1.1643835 2.017231 0 0.5
#const c[1] = 0.0625 1.1643835 -0.3917616 -0.81296802
#const c[2] = 1.1643835 0 1.5960271
PARAM c[3] = { { 1.1643835, 2.017231, 0, 0.5 },
        { 0.0625, 1.1643835, -0.3917616, -0.81296802 },
        { 1.1643835, 0, 1.5960271 } };
TEMP R0;
TEMP R1;
TEX R0.x, fragment.texcoord[2], texture[2], RECT;
ADD R1.z, R0.x, -c[0].w;
TEX R1.x, fragment.texcoord[0], texture[0], RECT;
TEX R0.x, fragment.texcoord[1], texture[1], RECT;
ADD R1.x, R1, -c[1];
ADD R1.y, R0.x, -c[0].w;
DP3 result.color.z, R1, c[0];
DP3 result.color.y, R1, c[1].yzww;
DP3 result.color.x, R1, c[2];
MOV result.color.w, fragment.color.primary;
END
# 10 instructions, 2 R-regs

                    """
            glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, len(prog), prog)
            log.error(glGetString(GL_PROGRAM_ERROR_STRING_ARB))

        glEnable(GL_FRAGMENT_PROGRAM_ARB)

        glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, self.yuv420_shader[0])

        glActiveTexture(GL_TEXTURE0);
        glBindTexture(GL_TEXTURE_RECTANGLE_ARB, self.textures[0])
        glEnable(GL_TEXTURE_RECTANGLE_ARB)
        glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glPixelStorei(GL_UNPACK_ROW_LENGTH, rowstrides[0])
        glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE, width, height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, img_data[0]);

        glActiveTexture(GL_TEXTURE1);
        glBindTexture(GL_TEXTURE_RECTANGLE_ARB, self.textures[1])
        glEnable(GL_TEXTURE_RECTANGLE_ARB)
        glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glPixelStorei(GL_UNPACK_ROW_LENGTH, rowstrides[1])
        glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE, width/2, height/2, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, img_data[1]);

        glActiveTexture(GL_TEXTURE2);
        glBindTexture(GL_TEXTURE_RECTANGLE_ARB, self.textures[2])
        glEnable(GL_TEXTURE_RECTANGLE_ARB)
        glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glPixelStorei(GL_UNPACK_ROW_LENGTH, rowstrides[2])
        glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE, width/2, height/2, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, img_data[2]);

        vtxarrays=0
        if vtxarrays == 1:
            texcoords = [ [ 0, 0 ],
                          [ 0, height],
                          [ width, height],
                          [ width, 0] ]
            vtxcoords = texcoords
            texcoords_half = [ [ 0, 0 ],
                          [ 0, height/2],
                          [ width/2, height/2],
                          [ width/2, 0] ]

            glVertexPointeri(vtxcoords)

            glActiveTexture(GL_TEXTURE0);
            glClientActiveTexture(GL_TEXTURE0)
            glEnableClientState(GL_TEXTURE_COORD_ARRAY);
            glTexCoordPointeri(texcoords)

            glActiveTexture(GL_TEXTURE1);
            glClientActiveTexture(GL_TEXTURE1)
            glEnableClientState(GL_TEXTURE_COORD_ARRAY);
            glTexCoordPointeri(texcoords_half)

            glActiveTexture(GL_TEXTURE2);
            glClientActiveTexture(GL_TEXTURE2)
            glEnableClientState(GL_TEXTURE_COORD_ARRAY);
            glTexCoordPointeri(texcoords_half)

            glDrawArrays(GL_QUADS, 0, 4);

        else:
            glBegin(GL_QUADS);
            glMultiTexCoord2i(GL_TEXTURE0, 0, 0);
            glMultiTexCoord2i(GL_TEXTURE1, 0, 0);
            glMultiTexCoord2i(GL_TEXTURE2, 0, 0);
            glVertex2i(0, 0);

            glMultiTexCoord2i(GL_TEXTURE0, 0, height);
            glMultiTexCoord2i(GL_TEXTURE1, 0, height/2);
            glMultiTexCoord2i(GL_TEXTURE2, 0, height/2);
            glVertex2i(0, height);

            glMultiTexCoord2i(GL_TEXTURE0, width, height);
            glMultiTexCoord2i(GL_TEXTURE1, width/2, height/2);
            glMultiTexCoord2i(GL_TEXTURE2, width/2, height/2);
            glVertex2i(width, height);

            glMultiTexCoord2i(GL_TEXTURE0, width, 0);
            glMultiTexCoord2i(GL_TEXTURE1, width/2, 0);
            glMultiTexCoord2i(GL_TEXTURE2, width/2, 0);
            glVertex2i(width, 0);
            glEnd()

        # OpenGL end
#self.gldrawable.swap_buffers()
#       self.gldrawable.swap_buffers()
        glFinish()
        self.gldrawable.gl_end()
Example #54
0
def drawHeightfield(color, w, h, textureReady, opacity,
                    SOLID = False, pickCheckOnly = False, hf = None):
    """
    Draw a heighfield using vertex and normal arrays. Optionally, it could be
    texture mapped.

    @pickCheckOnly This is used to draw the geometry only, used for OpenGL pick
      selection purpose.
    """        

    if not hf:
        # Return if heightfield is not provided
        return
    
    glEnable(GL_COLOR_MATERIAL)
    glEnable(GL_LIGHTING)

    # Don't use opacity, otherwise the heighfield polygons should be sorted
    # - something to implement later...
    ## glColor3v(list(color))
    
    if textureReady:
        # For texturing, use white color (to be modulated by the texture)
        glColor3f(1,1,1)
    else:
        glColor3fv(list(color))
        
    glPushMatrix()
    glScalef(w, h, 1.0)

    if SOLID:
        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
    else:
        glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
    
    glDisable(GL_CULL_FACE) 
    
    if not pickCheckOnly:
        glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

        if textureReady:
            glEnable(GL_TEXTURE_2D)  
            glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)

    glEnableClientState(GL_VERTEX_ARRAY)
    glEnableClientState(GL_NORMAL_ARRAY)
    glEnableClientState(GL_TEXTURE_COORD_ARRAY)

    for tstrip_vert, tstrip_norm, tstrip_tex in hf:
        glVertexPointer(3, GL_FLOAT, 0, tstrip_vert)
        glNormalPointer(GL_FLOAT, 0, tstrip_norm)
        glTexCoordPointer(2, GL_FLOAT, 0, tstrip_tex)
        glDrawArrays(GL_TRIANGLE_STRIP, 0, len(tstrip_vert))
        
    glDisableClientState(GL_VERTEX_ARRAY)
    glDisableClientState(GL_NORMAL_ARRAY)
    glDisableClientState(GL_TEXTURE_COORD_ARRAY)

    glDisable(GL_COLOR_MATERIAL)
    
    if not pickCheckOnly:
        if textureReady:
            glDisable(GL_TEXTURE_2D)

        glDepthMask(GL_TRUE) 

    glEnable(GL_CULL_FACE)
    if not SOLID:
        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)

    glPopMatrix()
    glEnable(GL_LIGHTING)
    
    return
Example #55
0
def drawHeightfield(color, w, h, textureReady, opacity,
                    SOLID=False, pickCheckOnly=False, hf=None):
    """
    Draw a heighfield using vertex and normal arrays. Optionally, it could be
    texuture mapped.

    @pickCheckOnly This is used to draw the geometry only, used for OpenGL pick
      selection purpose.
    """        

    from OpenGL.GL import glTexEnvf
    from OpenGL.GL import GL_TEXTURE_ENV
    from OpenGL.GL import GL_TEXTURE_ENV_MODE
    from OpenGL.GL import GL_MODULATE
    from OpenGL.GL import glVertexPointer
    from OpenGL.GL import glNormalPointer
    from OpenGL.GL import glTexCoordPointer
    from OpenGL.GL import glDrawArrays
    from OpenGL.GL import glEnableClientState
    from OpenGL.GL import GL_VERTEX_ARRAY
    from OpenGL.GL import GL_NORMAL_ARRAY
    from OpenGL.GL import GL_TEXTURE_COORD_ARRAY
        
    glEnable(GL_COLOR_MATERIAL)
    glEnable(GL_LIGHTING)

    ### glColor4fv(list(color) + [opacity])
    ### glColor3fv(list(color))
    glColor3f(1.0, 1.0, 1.0)
    
    glPushMatrix()
    glScalef(w, h, 1.0)

    if SOLID:
        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
    else:
        glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
    
    glDisable(GL_CULL_FACE) 
    
    if not pickCheckOnly:
        glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

        if textureReady:
            glEnable(GL_TEXTURE_2D)  
            glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)

    glEnableClientState(GL_VERTEX_ARRAY)
    glEnableClientState(GL_NORMAL_ARRAY)
    glEnableClientState(GL_TEXTURE_COORD_ARRAY)

    for tstrip_vert, tstrip_norm, tstrip_tex in hf:
        glVertexPointer(3, GL_FLOAT, 0, tstrip_vert)
        glNormalPointer(GL_FLOAT, 0, tstrip_norm)
        glTexCoordPointer(2, GL_FLOAT, 0, tstrip_tex)
        glDrawArrays(GL_TRIANGLE_STRIP, 0, len(tstrip_vert))
        
    glDisableClientState(GL_VERTEX_ARRAY)
    glDisableClientState(GL_NORMAL_ARRAY)
    glDisableClientState(GL_TEXTURE_COORD_ARRAY)

    glDisable(GL_COLOR_MATERIAL)
    
    if not pickCheckOnly:
        if textureReady:
            glDisable(GL_TEXTURE_2D)

        glDepthMask(GL_TRUE) 

    glEnable(GL_CULL_FACE)
    if not SOLID:
        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)

    glPopMatrix()
    glEnable(GL_LIGHTING)
    
    return