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 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 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_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()
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)