News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

Possible PrepareFXImage Bug

Started by Tracy, February 16, 2006, 12:30:05 AM

Previous topic - Next topic

Tracy

I was flipping through the 'known bugs' section of the forum and came across the thread for the PrepareFxImage bugs. One I've come across is that if you try to use CopyImage after you use PrepareFXImage on the image you get a crash. I'm guessing that it's related to the other bugs already reported, but the thread was closed so I thought I'd post it here.

Cheers.

kevin

can you post some code that makes this occur ?

also, in what version ?  

as the following seems ok here




CreateImage 1,10,10
preparefximage 1

copyimage 1,2

print "done"
sync
waitkey


Tracy

#2
Hi Kevin.

Here's the code that causes the crash (v1.089) (the original has no **'s, of course)

Function Load_Anim(AnimFrames(),File$,Frames,FrameWidth,FrameHeight,TransparentColour)
Index=GetFreeImage()
LoadImage File$,Index  

width=GetImageWidth(index)
height=GetImageHeight(index)
FrameNum=Frames*2
Dim AnimFrames(FrameNum)
AnimFrames(0)=Frames
Mirrorindex=0
For lp=1 To Frames
 Inc MirrorIndex
 RenderToImage Index
 FreeImage=GetFreeImage()
 AnimFrames(lp)=FreeImage
 GetImage FreeImage,Xpos,Ypos,Xpos+Framewidth,Ypos+FrameHeight
 ImageMaskColour FreeImage,TransparentColour
 ScaleImage Freeimage,38,38,1
 
`Create the mirror image indexes for this image, used for facing left instead of right
 Mirror=GetFreeImage()
** PrepareFXImage freeimage
** CopyImage Freeimage,Mirror
 MirrorImage mirror,1,0
 Mir=mirrorindex+frames
 AnimFrames(mir)=Mirror
 Xpos=Xpos+Framewidth
 If Xpos=>width Then Xpos=0: Ypos=Ypos+FRameHeight
Next
RenderToScreen
DeleteImage index
EndFunction

After you mentioned the version number, I tried to upgrade to v. 1.17 and suddenly my program wouldn't run. It's apparently a lot more picky about certain functions, and I apparently had a bug that tried to position a sprite that had been deleted.

Once I got the problem initially solved I got my program to run only to have it completely and totally freeze my computer when I hit a certain key to give it a command that works great in 1.089. I had to reboot. It also looked funny with the new version (the sprites look strange when rotated.) As such, I don't really feel great about using the new version just now and think I'll stick to 1.089.

Has anyone else experienced this problem? I have no idea what's causing the crash since I get no error message and can't even Ctrl+Alt+Del out of the freeze.

If it'd be helpful to you, Kevin, I'm happy to zip my game (images/files,etc) and post it here so you can see what I'm talking about. I suppose it's possible that it's just a bad interaction with my particular machine, but I've got Windows XP as my OS and that's pretty stable. Let me know. (Though unless you reply super fast it might be a while before I check this forum again- I've got somewhere to be.)

Thanks.

Edit: 'Somewhere to be' cancelled due to inclement weather. Gotta love Wisconsin winters. Guess I'm around for the evening.

kevin

#3
The animation routines works correctly.   The issue with pre PB1.17 is the Mirror Image command doesn't support FX formatted images.  You could get around that via copying the image, mirror it, then convert to fx format.

Copy image Src,dest
MirrorIMage  Dest
preparefx src + dest

QuoteAfter you mentioned the version number, I tried to upgrade to v. 1.17 and suddenly my program wouldn't run. It's apparently a lot more picky about certain functions, and I apparently had a bug that tried to position a sprite that had been deleted.

 If your code wouldn't run under PB1.17, then your accessing sprites/images that don't exist.  This is an _illegal_ operation.  PB1.089c is at fault !


QuoteIf it'd be helpful to you, Kevin, I'm happy to zip my game (images/files,etc) and post it here so you can see what I'm talking about. I suppose it's possible that it's just a bad interaction with my particular machine, but I've got Windows XP as my OS and that's pretty stable. Let me know. (Though unless you reply super fast it might be a while before I check this forum again- I've got somewhere to be.)

Zip it up and either post or send it.

Tracy

#4
QuoteThe animation routines works correctly.   The issue with pre PB1.17 is the Mirror Image command doesn't support FX formatted images.  You could get around that via copying the image, mirror it, then convert to fx format.

Copy image Src,dest
MirrorIMage  Dest
preparefx src + dest
 If your code wouldn't run under PB1.17, then your accessing sprites/images that don't exist.  This is an _illegal_ operation.  PB1.089c is at fault !
Zip it up and either post or send it.  


Yeah, that's what I did to get around that. I'll send you the game via personal message in just one minute.

As always, thanks for the quick reply.

Tracy

#5
...and I'm retarded. Didn't see your email address there. Incoming...

kevin

The halt error is caused as your passing zero to the rnd() function in the fire bullet function.  




Function Fire_Bullet(xpos#,ypos#)    
If player(Currentplayer).reload=0

; cut stuff

; original  
 Bullet(Bullet_Qty).Angle#     = Rnd(Bullet_type(Current_bullet_Type).ArcAngle#)+Bullet_type(Current_bullet_Type).Angle#-Bullet_type(Current_bullet_Type).ArcAngle#/2


; should be

 Angle#=Rnd(Bullet_type(Current_bullet_Type).ArcAngle#)
 if angle#<>0 then Angle#=rnd(angle#)
 Bullet(Bullet_Qty).Angle#     = angle#+Bullet_type(Current_bullet_Type).Angle#-Bullet_type(Current_bullet_Type).ArcAngle#/2


; etc etc
EndFUnction


Tracy

Kevin, thank you.

Apparently, I have a bad habit of not proofing my code to leave null values alone when I call functions. v1.17 caught me doing it many, many times.

Nonetheless, it's now fixed and running without a hitch.