예제 #1
0
def GetTextureData(tex_ptr,channels=[0,1,2]):
    global tmp_capture_mem
    sz=int2type()
    ret=libc.GetTextureSize2(tex_ptr,pointer(sz))
    req_mem_sz=sz[0]*sz[1]*4# (RGBA)
    if len(tmp_capture_mem)<req_mem_sz:
        tmp_capture_mem=np.zeros(req_mem_sz,'uint8')
    ptr=tmp_capture_mem.ctypes.data_as(c_void_p)
    libc.GetTextureData(tex_ptr,ptr,req_mem_sz)
    return tmp_capture_mem[:req_mem_sz].reshape((sz[1],sz[0],4))[:,:,channels]
예제 #2
0
 def GetTextureData16f(tex_ptr,channels=[0,1,2],verbose=0):
     global tmp_capture_memf
     sz=int2type()
     ret=libc.GetTextureSize2(tex_ptr,pointer(sz))
     req_mem_sz=sz[0]*sz[1]*4# (RGBA)
     if len(tmp_capture_memf)<req_mem_sz:
         tmp_capture_memf=np.zeros(req_mem_sz,'float16')
     ptr=tmp_capture_memf.ctypes.data_as(c_void_p)
     if libc.GetTextureDataf(tex_ptr,ptr,req_mem_sz*2,verbose)==0:
         return None
     if verbose:
         stats_data=tmp_capture_memf[tmp_capture_memf!=65504.0]
         print('GetTextureData16f stats maxmin',stats_data.max(),stats_data.min())
     return tmp_capture_memf[:req_mem_sz].reshape((sz[1],sz[0],4))[:,:,channels]