Possible image async loading bug? Not sure :(
Monkey Forums/Monkey Bug Reports/Possible image async loading bug? Not sure :(
| ||
This is the main code I am using;
Import mojo
Import brl.asyncevent
Class PreLoadImages Implements IOnLoadImageComplete
Field callImage : Image
Method OnLoadImageComplete : Void(image : Image, path : String, source : IAsyncEventSource)
If image
callImage = image
End If
End Method
Method New(getPath : String)
LoadImageAsync(getPath,,,Self)
End Method
Method GetImageHandle : Image()
Return callImage
End Method
End Class
Class Test Extends App
Field imgLogo : PreLoadImages
Field splashScreen : Image
Method OnCreate()
SetUpdateRate(60)
imgLogo = New PreLoadImages("imglogo.png")
End Method
Method OnRender()
Cls(255, 255, 255)
SplashScreen()
End Method
Method SplashScreen()
splashScreen = imgLogo.GetImageHandle()
DrawImage(splashScreen, (DeviceWidth()-splashScreen.Width())/2,(DeviceHeight()-splashScreen.Height())/2)
End Method
Method OnUpdate()
UpdateAsyncEvents
End Method
End Class
Function Main()
New Test
End Function
I keep on receiving this error regarding asyncimageloader.monkey: Error Message: Method Image.Init:Image(Local surf:Surface,Local nframes:Int,Local iflags:Int) is private Method UpdateAsyncEvents:Void() If IsRunning() Return RemoveAsyncEventSource Self If _result _surface.OnUnsafeLoadComplete() Local image:=(New Image).Init( _surface,_frames,_flags ) ' <-- problem with this line _onComplete.OnLoadImageComplete image,_mpath,Self Else _onComplete.OnLoadImageComplete Null,_mpath,Self Endif End Not sure how to solve it :( [edit]: using Monkey V79d |
| ||
| What is size of image? |
| ||
| . |
| ||
| You are using async loading image and do draw it in common onrender() method without checking is image loaded. Add to code the similar if splashScreen <>nul Then DrawImage(splashScreen, (DeviceWidth()-splashScreen.Width())/2,(DeviceHeight()-splashScreen.Height())/2) |
| ||
| Thanks for the help Niko, but I don't think that is the issue. I have tried the code with v78h and it works fine, compared the file asyncimageloader.monkey (v78h) with the same file that is part of v79d and they are the same, so It can't be that :( having a dig myself, but am pretty lost at the moment. |
| ||
| You are right. Seems it related to ***** v79d ***** .... Fixed private methods/functions not really private. Fixed private const/var/class decls in modules causing name clashes. |
| ||
I write keyword Public before Init declarations as on screenshot![]() It helps but... |
| ||
| Yay! putting 'Public' on line 149 within mojo/graphics.monkey fixes the issue. I just couldn't find those methods, you certainly have eagle eyes! Many thanks Niko great job! Спасибо :) |
| ||
| #EDIT - After much confusion in a related area I've found a solution to my problem. Can confirm adding Public on the line mentioned works. Wish LoadImageAsync worked on GLFW but I managed to do some image downloads using in GLFW using a different method (http://www.monkey-x.com/Community/posts.php?topic=8494). Maybe I have to have 2 different bits of code for the same thing for each target (one for HTML5 and one for GLFW). |
