Page 1 of 1

createsprite3d( OVER 100000 !

Posted: Fri Aug 06, 2010 1:00 pm
by max_aigneraigner@web.de
Hi Pb-team,

I wish that I can use the following code:

Code: Select all

sprite = createsprite( #pb_any , width, height , #pb_sprite_texture )
createsprite3d ( sprite, sprite)
But it says: "createsprite3d -> Error-> sprite3D NR too big (over 10000) , are you sure of that?"
why?! :( ;)
it would make live a bit easier :)

Here is a big example code:

Code: Select all

InitSprite()
InitKeyboard()
InitSprite3D()

OpenWindow( 0 , 10 , 10 , 1000 , 700 , "'Gemusoft Blending Test Software" ,#PB_Window_ScreenCentered)
OpenWindowedScreen( WindowID(0) , 0,0,WindowWidth(0),WindowHeight(0),0,0,0)
sprite = CreateSprite( #PB_Any , 64, 64 , #PB_Sprite_Texture )
CreateSprite3D ( sprite, sprite)

Repeat 

   ExamineKeyboard ()
   FlipBuffers()
   WindowEvent()
   DisplaySprite3D(sprite , 0 , 0 )
Until KeyboardPushed( #PB_Key_Escape)

Re: createsprite3d( OVER 100000 !

Posted: Fri Aug 06, 2010 1:12 pm
by Arctic Fox
By using a dynamic index number created by #PB_Any as a static index number, you will have tons of wasted memory (every index number up to the specified one is allocated in memory).

A workaround:

Code: Select all

sprite3d = CreateSprite3D(#PB_Any, sprite)
If you use static index numbers instead, it will not be a problem

Code: Select all

CreateSprite(1, 64, 64, #PB_Sprite_Texture)
CreateSprite3D(1, 1)

Re: createsprite3d( OVER 100000 !

Posted: Fri Aug 06, 2010 1:27 pm
by max_aigneraigner@web.de
wait a second.. #pb_any wastes memory? o.O! :|
I thought this is just a kind of ID .. in this case I will make an own "#any" function that gives me the next free lowest ID.
procedure registerSprite3d() ; gets new sprite 3d ID
procedure UnRegisterSprite3d(sprite3dID) ; deletes sprite3DID.

or so.

yours
max

Re: createsprite3d( OVER 100000 !

Posted: Fri Aug 06, 2010 1:33 pm
by Arctic Fox
Sorry, if I mislead you :oops: :)

It wastes memory if you re-use an index number created by #PB_Any for another creation as a static index number.
Further reading: http://www.purebasic.fr/english/viewtop ... 16#p284316 (I am sure that freak's explanation is much better) :wink:

Re: createsprite3d( OVER 100000 !

Posted: Fri Aug 06, 2010 1:56 pm
by max_aigneraigner@web.de
ah ok.. so I only can't use a with #pb_any- created number twice..^^
well that's not that bad then..
I will see what I can do hehe :D ;) ^^

the result will be shown in about one month^^

thanks for the help
yours
max

Re: createsprite3d( OVER 100000 !

Posted: Fri Aug 06, 2010 10:38 pm
by gnasen
max_aigneraigner@web.de wrote:ah ok.. so I only can't use a with #pb_any- created number twice..
thats not the problem if you know what you do. The error "createsprite3d -> Error-> sprite3D NR too big (over 10000) , are you sure of that?" occurs, because the handle given back from #pb_any is often a very big number which can be fast over 10000.

Further is

Code: Select all

CreateSprite3D ( sprite, sprite)
not really usefull in most cases.
It would be better if you use 2 different variable like Arctic Fox explained above.