changing GetWebImage() into a texture?

Blitz3D Forums/Blitz3D Programming/changing GetWebImage() into a texture?

Dock(Posted 2005) [#1]
I'm playing around with this code from the code archives, for downloading images from the internet:
http://blitzbasic.com/codearcs/codearcs.php?code=25

However, as it treats the web image as a 2D image, it seems that you can't apply it to a 3D model as a texture. Is there any simple way to change this from an image into a texture, or adjust the code to produce a texture?


jfk EO-11110(Posted 2005) [#2]
that's pretty easy, try this:
rocket_tex=createtexture(imagewidth(rocket),imageheight(rocket))
copyrect 0,0,imagewidth(rocket),imageheight(rocket),0,0,imagebuffer(rocket),texturebuffer(rocket_tex)


Edit:

of course you can also do this:


Function LoadWebTexture (webFile$)
 If BlitzGet (webFile$, CurrentDir (), "temp_web_image.bmp")
 texture = LoadTexture ("temp_web_image.bmp")
 DeleteFile "temp_web_image.bmp"
 EndIf
 Return texture
End Function

And use this instead of LoadWebImage() Of course you also need to alter this:

If rocket = 0
 RuntimeError "Failed to load web image!": End
 ; Alternative (BETTER) failure method -- use a default local image supplied with your game...
 ; rocket = loadtexture ("rocket.bmp")
EndIf



Dock(Posted 2005) [#3]
Excellent, that new function works like a treat. Thank-you JFK!

Do you know whether this sort of function would likely cause problems with zonealarm and firewalls and such? I'm curious as to how practical grabbing textures off the web really is.


jfk EO-11110(Posted 2005) [#4]
a good firewall should alert the user when you call this. Whan you are using fullscreen, zonealarms alert may be hidden in the backbuffer, this will pause the app for no visible reason, looking like a frozen program. Have a look at my Tip "how to prevent hidden alerts..." (or somethin alike) in the tutorial section.