Exemple #1
0
 def configShader(self):
     """Set uniforms in current GPU program"""
     if self.bayer:
         shader = gpu.getProgram()
         h = gpu.getUniform(shader, "sourceSize")
         glUniform4f(h, self.vid.w, self.vid.h, 1.0/self.vid.w, 1.0/self.vid.h)
         h = gpu.getUniform(shader, "firstRed")
         # This is the RGGB ordering that works with Elphel
         glUniform2f(h, 1, 0)
Exemple #2
0
 def draw(self):
     # First actual frame has arrived?
     if not self.checkLive():
         return
     # App allows display?
     if not self.visible:
         return
     # App has changed shaders?
     if gpu.getProgram() != self.prog:
         self.configShader()
         self.prog = gpu.getProgram()
     # Animated slide to new position?
     self.slide()
     # Just rect with texture coords
     glBindTexture(GL_TEXTURE_2D, self.texID)
     glEnable(GL_TEXTURE_2D)
     glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE)
     glEnableClientState(GL_TEXTURE_COORD_ARRAY)
     verts = (
         self.box.x, self.box.y + self.box.h,    # Upper left
         self.box.x, self.box.y,                 # Lower left
         self.box.x + self.box.w, self.box.y + self.box.h,   # Upper right
         self.box.x + self.box.w, self.box.y,                # Lower right
     )
     # GStreamer has image origin at top left
     texCoords = (
         0, 0,
         0, self.tex.h,
         self.tex.w, 0,
         self.tex.w, self.tex.h,
     )
     glVertexPointer(2, GL_FLOAT, 0, verts)
     glTexCoordPointer(2, GL_FLOAT, 0, texCoords)
     glDrawArrays(GL_TRIANGLE_STRIP, 0, 4)
     glDisable(GL_TEXTURE_2D)
     glDisableClientState(GL_TEXTURE_COORD_ARRAY)