Beispiel #1
0
    def _update(self):
        """ Actual upload of data to GPU memory  """

        log.debug("GPU: Updating %s" % self.name)

        # Check active status (mandatory)
        #        if not self._active:
        #            raise RuntimeError("Attribute variable is not active")
        #        if self._data is None:
        #            raise RuntimeError("Attribute variable data is not set")

        # Generic vertex attribute (all vertices receive the same value)
        if self._generic:
            if self._handle >= 0:
                gl.glDisableVertexAttribArray(self._handle)
                self._afunction(self._handle, *self._data)

        # Regular vertex buffer
        elif self.handle >= 0:
            #if self._need_update:
            #    self.data._update()
            #    self._need_update = False

            # Get relevant information from gl_typeinfo
            size, gtype, dtype = gl_typeinfo[self._gtype]
            stride = self.data.stride

            # Make offset a pointer, or it will be interpreted as a small array
            offset = ctypes.c_void_p(self.data.offset)
            gl.glEnableVertexAttribArray(self.handle)
            gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self.data.handle)
            gl.glVertexAttribPointer(self.handle, size, gtype, gl.GL_FALSE,
                                     stride, offset)
Beispiel #2
0
    def _update(self):
        """ Actual upload of data to GPU memory  """

        log.debug("GPU: Updating %s" % self.name)

        # Check active status (mandatory)
#        if not self._active:
#            raise RuntimeError("Attribute variable is not active")
#        if self._data is None:
#            raise RuntimeError("Attribute variable data is not set")

        # Generic vertex attribute (all vertices receive the same value)
        if self._generic:
            if self._handle >= 0:
                gl.glDisableVertexAttribArray(self._handle)
                self._afunction(self._handle, *self._data)

        # Regular vertex buffer
        elif self.handle >= 0:
            #if self._need_update:
            #    self.data._update()
            #    self._need_update = False

            # Get relevant information from gl_typeinfo
            size, gtype, dtype = gl_typeinfo[self._gtype]
            stride = self.data.stride

            # Make offset a pointer, or it will be interpreted as a small array
            offset = ctypes.c_void_p(self.data.offset)
            gl.glEnableVertexAttribArray(self.handle)
            gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self.data.handle)
            gl.glVertexAttribPointer(self.handle, size, gtype,  gl.GL_FALSE, stride, offset)
Beispiel #3
0
 def _deactivate(self):
     if isinstance(self.data, VertexBuffer):
         self.data.deactivate()
         if self.handle >= 0:
             gl.glDisableVertexAttribArray(self.handle)
     elif isinstance(self.data, VertexArray):
         self.data.deactivate()
Beispiel #4
0
 def _deactivate(self):
     if isinstance(self.data,VertexBuffer):
         self.data.deactivate()
         if self.handle > 0:
             gl.glDisableVertexAttribArray(self.handle)
     elif isinstance(self.data,VertexArray):
         self.data.deactivate()