def createFramebufferObject(self, size): fmt = QOpenGLFramebufferObjectFormat() fmt.setAttachment(QOpenGLFramebufferObject.CombinedDepthStencil) self._fbo = QOpenGLFramebufferObject(size, fmt) # Clear any previous OpenGL error. This workarounds an issue on macOS # where the current context contains errors (due to Qt OpenGL # implementation). These errors need to be cleared before calling the # node.gl API otherwise node.gl will in turn error out. gl_funcs = QOpenGLFunctions(QOpenGLContext.currentContext()) gl_funcs.glGetError() if not self._context: self._context = ngl.Context() config_gl = ngl.ConfigGL(external=True, external_framebuffer=self._fbo.handle()) self._context.configure( backend=ngl.BACKEND_OPENGL, width=self._fbo.width(), height=self._fbo.height(), backend_config=config_gl, ) else: self._context.gl_wrap_framebuffer(self._fbo.handle()) return self._fbo
def __init__(self, parent=None): QOpenGLWidget.__init__(self, parent) QOpenGLFunctions.__init__(self) self.core = "--coreprofile" in QCoreApplication.arguments() self.xRot = 0 self.yRot = 0 self.zRot = 0 self.lastPos = 0 self.logo = Logo() self.vao = QOpenGLVertexArrayObject() self.logoVbo = QOpenGLBuffer() self.program = QOpenGLShaderProgram() self.projMatrixLoc = 0 self.mvMatrixLoc = 0 self.normalMatrixLoc = 0 self.lightPosLoc = 0 self.proj = QMatrix4x4() self.camera = QMatrix4x4() self.world = QMatrix4x4() self.transparent = "--transparent" in QCoreApplication.arguments() if self.transparent: fmt = self.format() fmt.setAlphaBufferSize(8) self.setFormat(fmt)
def prepareDraw(self, context: QOpenGLFunctions): ''' jscut work with the pathBuffer directly ... here we work with the vertexData List so we do not use the "self.m_gcodedrawer.pathBufferContent", but rather the self.m_gcodedrawer.m_triangles list ''' self.m_shader_program.bind() context.glUniform1f( self.m_shader_program.uniformLocation("resolution"), self.m_gcodedrawer.resolution) context.glUniform1f(self.m_shader_program.uniformLocation("pathScale"), self.m_gcodedrawer.pathScale) context.glUniform1f(self.m_shader_program.uniformLocation("pathMinZ"), self.m_gcodedrawer.pathMinZ) context.glUniform1f(self.m_shader_program.uniformLocation("pathTopZ"), self.m_gcodedrawer.pathTopZ) #context.glUniformMatrix4fv(self.m_shader_program.uniformLocation("rotate"), False, self.rotate) #context.glUniform1i(self.m_shader_program.uniformLocation("heightMap", 0) #context.glUniform1f(self.m_shader_program.uniformLocation("resolution"), self.m_gcodedrawer.resolution) #context.glUniform1f(self.m_shader_program.uniformLocation("pathScale"), self.m_gcodedrawer.pathScale) #context.glUniform1f(self.m_shader_program.uniformLocation("pathMinZ"), self.m_gcodedrawer.pathMinZ) #context.glUniform1f(self.m_shader_program.uniformLocation("pathTopZ"), self.m_gcodedrawer.pathTopZ) self.m_shader_program.setUniformValue("rotate", self.rotate) self.m_shader_program.setUniformValue("heightMap", 0)
def __init__(self): ''' ''' QOpenGLFunctions.__init__(self) self.m_needsUpdateGeometry = True self.m_visible = True self.m_lineWidth = 1.0 self.m_pointSize = 1.0 self.m_texture: QOpenGLTexture = None self.m_lines: List[VertexData] = [] self.m_points: List[VertexData] = [] self.m_triangles: List[VertexData] = [] self.m_vbo = QOpenGLBuffer(QOpenGLBuffer.VertexBuffer) self.m_vao = QOpenGLVertexArrayObject()
def __init__(self, parent, tag=None): QtOpenGLWidgets.QOpenGLWidget.__init__(self, parent) GL.__init__(self) self.__data = np.array([ -1.0, -1.0, 0.0, 0.0, 0.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, -1.0, 0.0, 1.0, 0.0 ], dtype=ctypes.c_float) self.tag = tag self.__mutex = threading.Lock() self._is_video = False self._is_video_playing = False self.__texture_generator = None self.__player = None self.__uniform_tex_bias = -1
def prepareDraw(self, context: QOpenGLFunctions): self.m_shader_program.bind() context.glUniform1f(self.m_shader_program.uniformLocation("resolution"), self.resolution) context.glUniform1f(self.m_shader_program.uniformLocation("cutterDia"), self.cutterDia) #context.glUniform2f(self.m_shader_program.uniformLocation("pathXYOffset"), pathXOffset, pathYOffset) context.glUniform1f(self.m_shader_program.uniformLocation("pathMinZ"), self.pathMinZ) ##context.glUniform1f(self.m_shader_program.uniformLocation("pathTopZ"), pathTopZ) context.glUniform1f(self.m_shader_program.uniformLocation("stopAtTime"), self.stopAtTime) #self.m_shader_program.setUniformValue("resolution", self.resolution) #self.m_shader_program.setUniformValue("cutterDia", self.cutterDia) # error: float! ??? self.m_shader_program.setUniformValue("pathXYOffset", self.pathXOffset, self.pathYOffset)