MiniB3D change texture problems
BlitzMax Forums/MiniB3D Module/MiniB3D change texture problems
| ||
I want to place a stopwatch in my racing car simulation. Therefore I created a cube entity beside the road with a pixmap texture on it. Each second I draw the time as text on the screen, grab a pixmap, convert it into a TTexture and asign it to the cube entity. The pixmap displays the running time correct. The entity accepts the first pixmap, but then this first remains on the cube: The screenshot shows the cube with texture in the middle of the picture. On left top corner you can see the pixmap (displayed for demonstation purpose) with running time. What do I wrong? Here is the source code: Uhr:TEntity= CreateCube() PositionEntity Uhr,-3,1,13 ScaleEntity Uhr,1,1,.1 .... Function MalenNachFlip() BeginMax2D Cls SetScale 10,10 SetColor 255,255,0 DrawText UhrZeit$,0,0 UhrAnzeige:TPixmap=GrabPixmap(0,0,256,256) Cls EndMax2D Local locUhrTex:TTexture=LoadPixTexture(UhrAnzeige) Uhr.EntityTexture locUhrTex,0,0 End Function I pimped the function LoadTexture() to LoadPixTexture() in MiniB3D to pass Pixmaps instead of files: |
| ||
I suspect the texture caching might trip up your code, as it uses the filename as a key. So in your case it would recognize the empty string as the key to your texture and ignore all other loads. You need to set tex.file and tex.file_abs to a unique enough string like pix.ToString() or similar. Or even better, disable the cache when loading pixmaps directly. (im my own modded minib3d i do both, just in case the texture filenames are used other places) |
| ||
thanks grable! your adwise brought the solution. It works now! I only needed to comment out the ListAddLast() in function TTexture.LoadAnimTexture(): Function LoadAnimTexture:TTexture(file$,flags:Int,frame_width:Int,frame_height:Int... ... ' set tex.flags before TexInList tex.flags=flags tex.FilterFlags() ' check to see if texture with same properties exists already, if so return existing texture Local old_tex:TTexture old_tex=tex.TexInList() If old_tex<>Null And old_tex<>tex Return old_tex Else If old_tex<>tex 'here-> ' ListAddLast(tex_list,tex) EndIf EndIf .... |