Commits

Leonard Ritter committed 32ded74

support for glBufferSubData

  • Participants
  • Parent commits a132041

Comments (0)

Files changed (1)

File gl/corearb.py

         ptr = _array(type_, data)
         _glBufferData(target, _ffi.sizeof(ptr), ptr, usage)
         return ptr
+
+# providing our own until ffi has it
+CData = type(_ffi.cast("int", 0))
+CType = type(_ffi.typeof("int"))
+
+def glBufferSubData(target, type_, offset, data):
+    bytesize = _ffi.sizeof(type_)
+    if isinstance(data, CData):
+        ptr = data
+    else:
+        ptr = _array(type_, data)
+    _glBufferSubData(target, offset * bytesize, _ffi.sizeof(ptr), ptr)
+    return ptr
     
 def glVertexAttribPointer(index, size, typeid, normalized, stride, data):
     if isinstance(data, int):
 
 glGetUniformLocation = _glGetUniformLocation
 
-# providing our own until ffi has it
-CData = type(_ffi.cast("int", 0))
-CType = type(_ffi.typeof("int"))
-
 def _wrap_texture_data(type, data):
     if isinstance(data, CData):
         return data