createsprite3d( OVER 100000 !

Just starting out? Need help? Post your questions and find answers here.
User avatar
max_aigneraigner@web.de
User
User
Posts: 67
Joined: Sun Nov 02, 2008 10:37 pm
Location: Bavaria
Contact:

createsprite3d( OVER 100000 !

Post 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)
3D Projects
A ship is safest in the harbor, but that is not what ships are built for.
User avatar
Arctic Fox
Enthusiast
Enthusiast
Posts: 609
Joined: Sun Dec 21, 2008 5:02 pm
Location: Aarhus, Denmark

Re: createsprite3d( OVER 100000 !

Post 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)
User avatar
max_aigneraigner@web.de
User
User
Posts: 67
Joined: Sun Nov 02, 2008 10:37 pm
Location: Bavaria
Contact:

Re: createsprite3d( OVER 100000 !

Post 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
3D Projects
A ship is safest in the harbor, but that is not what ships are built for.
User avatar
Arctic Fox
Enthusiast
Enthusiast
Posts: 609
Joined: Sun Dec 21, 2008 5:02 pm
Location: Aarhus, Denmark

Re: createsprite3d( OVER 100000 !

Post 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:
User avatar
max_aigneraigner@web.de
User
User
Posts: 67
Joined: Sun Nov 02, 2008 10:37 pm
Location: Bavaria
Contact:

Re: createsprite3d( OVER 100000 !

Post 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
3D Projects
A ship is safest in the harbor, but that is not what ships are built for.
gnasen
Enthusiast
Enthusiast
Posts: 282
Joined: Wed Sep 24, 2008 12:21 am

Re: createsprite3d( OVER 100000 !

Post 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.
pb 5.11
Post Reply