Fastlibs FreeTexture bug?
Blitz3D Forums/Blitz3D Userlibs/Fastlibs FreeTexture bug?
| ||
Include "include\FastExt.bb" Graphics3D 800,600,0,2 InitExt tex=LoadTexture ("mytexture.png",1+2) cub0=CreateCube() EntityTexture cub0,tex For SurfI=1 To (CountSurfaces( cub0 )) s=GetSurface( cub0, SurfI ) b=GetSurfaceBrush(s) t0=GetBrushTexture( b, 0 ) t1=GetBrushTexture( b, 1 ) If t0>0 Then FreeTexture t0 If t1>0 Then FreeTexture t1 If b>0 Then FreeBrush b Next FreeTexture tex End I get a Memory Access Violation! What's wrong? |
| ||
Try it without FastExt in debug mode :) |
| ||
It works without FastLibs ..! Please try it :) |
| ||
:) Ok. I will soon solve this problem. |
| ||
@FlagDKT: I was right, the problem contains in your code :) I have added DebugLog function to your code that it was possible to see error. Error it is visible on TextureBuffer function (without FastExt library!), try it in Debug mode: ;;; Include "include\FastExt.bb" Graphics3D 800,600,0,2 ;;; InitExt tex=LoadTexture ("mytexture.png",1+2) cub0=CreateCube() EntityTexture cub0,tex For SurfI=1 To (CountSurfaces( cub0 )) s=GetSurface( cub0, SurfI ) DebugLog "surface "+i+": "+s b=GetSurfaceBrush(s) DebugLog "brush "+b t0=GetBrushTexture( b, 0 ) t1=GetBrushTexture( b, 1 ) If t0<>0 Then DebugLog "t0 "+t0 t0b = TextureBuffer(t0) DebugLog "t0 buffer "+t0b FreeTexture t0 EndIf If t1<>0 Then DebugLog "t1 "+t1 t1b = TextureBuffer(t1) DebugLog "t1 buffer "+t1b FreeTexture t1 EndIf If b<>0 Then FreeBrush b Next DebugLog "tex "+tex texb = TextureBuffer (tex) DebugLog "tex buffer " + texb FreeTexture tex End p.s. FastExt library uses TextureBuffer in modified FreeTexture function. It is necessary for usage of new flags of texture. |
| ||
then it is a blitz bug, not my simple code :) |
| ||
are you on the current b3d version or some stoneage thing? |
| ||
@Dreamora: b3d 1.103 |
| ||
Hi, Ok, it's a problem with texture-less brushes - smallest example I can come up with is: Graphics3D 800,600,0,2 brush=CreateBrush( 1,1,0 ) Print "brush="+brush tex=GetBrushTexture( brush,0 ) Print "tex="+tex buf=TextureBuffer( tex ) Print "buf="+buf GetBrushTexture should probably be returning '0' here, where-as it's actually returning a built-in default 0 frame texture, which is ultimately causing TextureBuffer to die. Note that EntityTexture doesn't actually change any surface brushes, it only changes the 'master' entity brush which is blended with each surface brush. Will have a fix up soon. |
| ||
Hi, Ok, on seconds thoughts I'm a little worried this fix may break stuff. Currently, GetBrushTexture will always (I think) return something - it just may be a 'blank' texture. Changing this behaviour may cause currently working apps to crash. Perhaps just fixing TextureBuffer() so it returns 0 instead of crashing (which I'm doing anyway!) is the safest way to go? |
| ||
@marksibly: I think it will be correct (TextureBuffer return zero without crashing) also will not add new problems. Mark, may be you will add native support of render-textures (with and w/o z-buffer)? It will be very cool and great, and solve all problems with FreeTexture function (for additional libraries)... |
| ||
I really need to free up textures in a loop, could you please do the same with freetexture, so it will not give an error when no texture is found? And I think that the same could be done with other free commands? |
| ||
Hi, > I really need to free up textures in a loop, could you please do the same with freetexture, Do what the same? FreeTexture is nothing like TextureBuffer. |
| ||
Ah ok, nevermind :) |
| ||
@FlagDKT: I will solve this problem in FastExt library within a week... (If Mark does not release a new update for B3D :) |
| ||
thx :) Mark will you release a new update? |
| ||
Hi, Ok, I've posted 1.104 with the TextureBuffer fix ONLY. Let me know if this is enough or not! |
| ||
It's enough for me. thank you |