def draw(self): """ Draw the vertex array as points. """ self.bind() GL.glDrawArrays(GL.GL_POINTS, 0, self._number_of_items) self.unbind()
def draw(self): """ Draw the vertex array as lines. """ if self._number_of_objects >= 2: self.bind() GL.glDrawArrays(GL.GL_LINE_STRIP_ADJACENCY, 0, self._number_of_objects +2) self.unbind()
def draw(self): """ Draw the vertex array as lines. """ if self._number_of_objects >= 2: self.bind() GL.glDrawArrays(GL.GL_LINES, 0, self._number_of_objects) self.unbind()
def paint(self): self._logger.info('') # Clear the buffer using white colour (white paper) GL.glClearColor(1, 1, 1, 1) GL.glClear(GL.GL_COLOR_BUFFER_BIT) if self._paint_page: self._paint_page_layout() self._paint_text()
def initializeGL(self): self._logger.debug('Initialise GL') super(GlWidget, self).initializeGL() GL.glEnable(GL.GL_POINT_SMOOTH) #compat# GL.glEnable(GL.GL_LINE_SMOOTH) #compat# self._init_shader() self._paint_page = False
def initializeGL(self): self.logger.debug('Initialise GL') super(GlWidget, self).initializeGL() # Require compatibility profile GL.glEnable(GL.GL_POINT_SMOOTH) GL.glEnable(GL.GL_LINE_SMOOTH) self._init_shader() self.create_vertex_array_objects()
def paint_grid(self): shader_program = self.shader_manager.fixed_shader_program shader_program.bind() GL.glLineWidth(1.) shader_program.uniforms.colour = (1., 1., 1.) self.grid_vertex_array.draw() GL.glLineWidth(10.) x = 150 GlFixedPipeline.draw_rectangle(-x, -x, x, x) shader_program.unbind()
def initializeGL(self): self.logger.debug('Initialise GL') super(GlWidget, self).initializeGL() GL.glEnable(GL.GL_POINT_SMOOTH) GL.glEnable(GL.GL_LINE_SMOOTH) # self.qglClearColor(QtCore.Qt.black) # GL.glPointSize(5.) # GL.glLineWidth(3.) self._init_shader() self.create_vertex_array_objects()
def paint(self): self.paint_grid() self.paint_textures() if LOG_GL_CALL: six.print_('\n', '='*100) for command in GL.called_commands(): six.print_('\n', '-'*50) # six.print_(str(command)) six.print_(command._command.prototype()) six.print_(command.help())
def draw(self, shader_program): # Freetype renders glyph as grayscale: white foreground on black background # If the LCD filter is enabled then the pixels on border are coloured. # black fragment should be discarded # # Blending equation for transparency: # O = (1-Sa)*D + Sa*S # if Sa = 1 then O = S overwrite # = 0 then O = D keep the value # # Grayscale case: # S = luminosity * colour grayscale = luminosity # Sa = average luminosity * alpha ??? # # LCD case: # white -> red : (1,1,1) -> (1,0,0) # Blending: O = Sf*S + Df*D # where S is the colour from the fragment shader and D the colour from the framebuffer # alpha: fully transparent = 0 and fully opaque = 1 # Sa = average luminosity * colour aplha # # Set (Sf, Df) for transparency: O = Sa*S + (1-Sa)*D GL.glEnable(GL.GL_BLEND) GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA) shader_program.bind() self._image_texture.bind() self.bind() shader_program.uniforms.font_atlas = 0 # shader_program.uniforms.gamma = 1. GL.glDrawArrays(GL.GL_POINTS, 0, self._number_of_items) self.unbind() self._image_texture.unbind() shader_program.unbind() GL.glDisable(GL.GL_BLEND)
def _create_texture(self, tile, key): self._logger.debug('Create Texture ' + str(key) + ' Tile position: {} {} {} {} {}'.format(tile.row, tile.column, tile.x, tile.y, tile.length)) position = Point(tile.x +.5, tile.y + tile.length +.5) image_dimension = Offset(tile.length, -tile.length) # row_inf, column_inf = 23600, 33800 # position = Point(tile.column -column_inf, tile.row +1 -row_inf +.5) # image_dimension = Offset(1, -1) self._glwidget.makeCurrent() #? with GL.error_checker(): image = tile.image self._paint_border(image) texture = Texture(key, position, image_dimension, image) texture.bind_to_shader(program_interfaces['texture_shader_program_interface'].attributes) self._texture_cache.add(texture, acquire=True) return texture
def update_painter_manager(self): self._logger.debug('') if self._ready: with GL.error_checker(): self._painter_manager.update()
def paint_lines(self): shader_program = self.shader_manager.fixed_shader_program shader_program.bind() GL.glLineWidth(1.) shader_program.uniforms.colour = (0., 0., 1.) self.simple_square_vertex_array.draw() # try: GL.glLineWidth(5.) shader_program.uniforms.colour = (0., 0., 1.) self.segment_vertex_array1.draw() # del self.segment_vertex_array1 # except: # pass GL.glLineWidth(2.) shader_program.uniforms.colour = (0., 1., 1.) self.segment_vertex_array2.draw() GL.glLineWidth(2.) shader_program.uniforms.colour = (1., 0., 0.) # six.print_('colour', shader_program.uniforms.colour) self.segment_vertex_array3.draw() shader_program = self.shader_manager.rectangle_shader_program shader_program.bind() GL.glLineWidth(2.) shader_program.uniforms.colour = (1., 0., 1.) self.rectangle_vertex_array.draw() shader_program = self.shader_manager.centred_rectangle_shader_program shader_program.bind() GL.glLineWidth(2.) shader_program.uniforms.colour = (8., 3., .5) self.centred_rectangle_vertex_array.draw() shader_program = self.shader_manager.wide_line_shader_program shader_program.bind() shader_program.uniforms.line_width = 2 shader_program.uniforms.colour = (1., 1., 1.) self.line_vertex_array1.draw() shader_program = self.shader_manager.stipple_line_shader_program shader_program.bind() shader_program.uniforms.line_width = 4 shader_program.uniforms.stipple_factor = 4 shader_program.uniforms.colour = (1., .8, .8) self.stipple_texture.bind() self.line_vertex_array2.draw() self.stipple_texture.unbind() shader_program.unbind()
def draw(self): self.bind() GL.glDrawArrays(GL.GL_POINTS, 0, self._number_of_items) self.unbind()
def paint_path(self): # Unbind shader /!\ # GL.glClearStencil(0) # GL.glClearColor(0,0,0,0) # # GL.glClear(GL.GL_COLOR_BUFFER_BIT) # GL.glStencilMask(~0) # GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT) filling = False # /!\ clear framebuffer even_odd = True stroking = True if filling: nvpath.glStencilFillPathNV(self.path_object, nvpath.GL_COUNT_UP_NV, 0x1F) GL.glEnable(GL.GL_STENCIL_TEST) if even_odd: GL.glStencilFunc(GL.GL_NOTEQUAL, 0, 0x1) else: GL.glStencilFunc(GL.GL_NOTEQUAL, 0, 0x1F) GL.glStencilOp(GL.GL_KEEP, GL.GL_KEEP, GL.GL_ZERO) GL.glColor3f(0,1,0) # green nvpath.glCoverFillPathNV(self.path_object, nvpath.GL_BOUNDING_BOX_NV) if stroking: nvpath.glStencilStrokePathNV(self.path_object, 0x1, ~0) GL.glColor3f(1,1,0) # yellow nvpath.glCoverStrokePathNV(self.path_object, nvpath.GL_CONVEX_HULL_NV)
def paint(self): if self._ready: with GL.error_checker(): self._painter_manager.paint()
def paint_object(self): GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL) GL.glEnable(GL.GL_POLYGON_OFFSET_FILL) GL.glPolygonOffset(1., 1.) # shader_program = self.shader_manager.basic_shader_program shader_program = self.shader_manager.lighting_shader_program # shader_program.light.Position = (0, 0, 100, 1) shader_program.bind() self.object_vertex_array.draw() GL.glDisable(GL.GL_POLYGON_OFFSET_FILL) GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE) GL.glLineWidth(1.) shader_program = self.shader_manager.fixed_colour_shader_program shader_program.bind() self.object_vertex_array.draw() shader_program.unbind()