Fast Help With Pointer

Blitz3D Forums/Blitz3D Beginners Area/Fast Help With Pointer

Yue(Posted 2012) [#1]
Hello, I have a problem, is that achievement in a pointer load resources in the background, but when I delete the pointer again and I believe it does not work again, I'm doing something wrong or just does not work.


Yue(Posted 2012) [#2]
Not that the difference between FreeImage or put the variable that contains that image on a value of 0.

So if I use FreeImage, the thread does not work for some reason again to reload the image, but if I put in the variable to 0, if it works.

Solved by now.

;
; Example of use FastPointer library.
; (c) 2008-2009 created by MixailV aka Monster^Sage [monster-sage@...]  http://www.fastlibs.com
;
; Attention! Functions only for the advanced users, use them very accurately.
; If you do not understand how it works, do not use it!
;


.Inicio
; create scene objects
Graphics3D 800,600,0,2
SetFont LoadFont("Tahoma",15)
Camera = CreateCamera()  :  PositionEntity Camera, 0, 0, -3.5
Light = CreateLight()
Global Cube



; function for thread (with single integer param - it is obligatory)
; don't load meshes in thread, if you use RenderWorld function in main loop
Function ThreadFunction ( entity%=0 )
	Repeat
		If Cube% = 0
			Cube% = LoadImage("Yue.bmp") ; Image 278 Megas.
		End If 
	Forever
End Function


; get pointer to thread function
ThreadFunctionPointer = FunctionPointer()
	Goto skip
	ThreadFunction()		; <<< get pointer from this function
	.skip


; create thread
Thread = CreateThread (ThreadFunctionPointer, Cube)


; main loop
While Not KeyHit(1)
	RenderWorld
	If Cube<> 0
		FreeThread(Thread)
		DrawImage(Cube%,0,0)
	End If 
	AppTitle Cube%
	Text 10,10,"You can control entity from threads!"
	Flip 0
Wend
; FreeImage Cube ; <<< Error  Thread no work
Cube% = 0
; freel thread  
If IsThread(Thread) Then FreeThread(Thread)
Goto Inicio

WaitKey()
End


Last edited 2012