Load Half-Life 2 textures!
This goes with VTFLib. If anyone wants to compile a module, that would be useful.
This goes with VTFLib. If anyone wants to compile a module, that would be useful.
Global VTF_HLIB Global vlInitialize() Global vlCreateImage:Int(imageformat:Byte Ptr) Global vlBindImage:Int(vtfimage:Int) Global vlImageLoad:Int(file$z,headeronly:Int) Global vlImageGetWidth:Int() Global vlImageGetHeight:Int() Global vlImageGetFormat:Int() Global vlImageGetData:Int(Frame:Int,Face:Int,MipmapLevel:Int) Global vlImageConvertToRGBA8888(Source:Int,Dest:Byte Ptr,Width:Int,Height:Int,SourceFormat:Int) Global vlDeleteImage(vtfimage:Int) Global vlShutdown() Function VTFInit() If VTF_HLIB Return VTF_HLIB VTF_HLIB=LoadLibraryA(CurrentDir()+""+"VTFLib.dll") If VTF_HLIB vlInitialize=getprocaddress(VTF_HLIB,"vlInitialize") vlCreateImage=getprocaddress(VTF_HLIB,"vlCreateImage") vlBindImage=getprocaddress(VTF_HLIB,"vlBindImage") vlImageLoad=getprocaddress(VTF_HLIB,"vlImageLoad") vlImageGetWidth=getprocaddress(VTF_HLIB,"vlImageGetWidth") vlImageGetHeight=getprocaddress(VTF_HLIB,"vlImageGetHeight") vlImageGetFormat=getprocaddress(VTF_HLIB,"vlImageGetFormat") vlImageGetData=getprocaddress(VTF_HLIB,"vlImageGetData") vlImageConvertToRGBA8888=getprocaddress(VTF_HLIB,"vlImageConvertToRGBA8888") vlDeleteImage=getprocaddress(VTF_HLIB,"vlDeleteImage") vlShutdown=getprocaddress(VTF_HLIB,"vlShutdown") vlInitialize() EndIf Return VTF_HLIB EndFunction Function LoadVTF:tpixmap(file$) If Not VTFInit() Return Local vtfimage If vlCreateImage(Varptr(vtfimage)) If vlBindImage(vtfimage0) If vlImageLoad(file$,0) width=vlImageGetWidth() height=vlImageGetHeight() format=vlImageGetFormat() imagedata=vlImageGetData(0,0,0) pixmap:tpixmap=CreatePixmap(width,height,PF_RGBA8888) vlImageConvertToRGBA8888(imagedata,pixmap.pixelptr(0,0),width,height,format) EndIf EndIf vlDeleteImage(vtfimage) Return pixmap EndIf EndFunction Function VTFEnd() If VTF_HLIB vlShutdown() FreeLibrary VTF_HLIB VTF_HLIB=0 EndIf EndFunction