Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Im having problems with set object effect, real slow

Author
Message
Daniel wright 2311
User Banned
Posted: 18th Apr 2011 21:02 Edited at: 18th Apr 2011 21:04
So If I apply a effect file to an object out side of any loop it applys it just fine. BUT When I apply a effect inside any loop after a texture change from that object it slows my pc down, is there a better way to do it? I even tried it with a return from out side the loop and the slow down still is there.here is the code im using and it happens right after the texture changes.
thanks for any help.

Edit:: After I change any tecture on the object in the loop it looses its effect so this is why i need help.




my signature keeps being erased by a mod So this is my new signature.
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 18th Apr 2011 21:41
what you need to do is apply the effect ONLY ONCE!

you do NOT need to retexture/set object effect every single frame.

Generally, I try to wrap stuff up in functions, so I would have a function like this:


You can do it other ways too, but the key point is ONLY reset the texture/effect when the variable ehealth is changed!


Tell me if there's a broken link to images in a thread I post, and I'll fix 'em.
Daniel wright 2311
User Banned
Posted: 18th Apr 2011 22:19
Thank you, this worked perfecly, Im not shure why I dont use more functions then I do, it really cuts down so much code in the end result. this works real good but there is still a sec of slow down each time the texture changes, but im shure this is just dark basic pro.



my signature keeps being erased by a mod So this is my new signature.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Apr 2011 22:25 Edited at: 18th Apr 2011 22:30
You don't need to use set object effect again if you're only changing a texture. Just set the effect once before the main loop.

You also need to apply the texture to the correct texture stage, e.g. use



instead of





So your snippet should be simply:



Edit Also, as Neuro Fuzzy says, you don't need to do the retexturing each loop - but the main point is don't set the effect again (you WILL need to if you don't use the texture stage parameter).
Daniel wright 2311
User Banned
Posted: 18th Apr 2011 23:06
@Green Gandalf

great, thanks, I did not know this, im glade you helped, ill try it out now.

my signature keeps being erased by a mod So this is my new signature.
Daniel wright 2311
User Banned
Posted: 18th Apr 2011 23:14
Yep, this works great, All I really needed to do was apply the texture to the correct texture stage, wow, well, I did also learn a good way to put functions together also so I won today with 2 great ways to do something, thanks guys.

my signature keeps being erased by a mod So this is my new signature.

Login to post a reply

Server time is: 2026-07-18 06:41:31
Your offset time is: 2026-07-18 06:41:31