Pixel ploting with Lock() is slow for me :(

Started by
54 comments, last by DekuTree64 23 years, 1 month ago
aright heres my thoughts...

Im not a master at directX so im really just taking a few guesses here...


Are you flipping the frame buffers every pixel?
are you doing something else uneeded every pixel?

do everything you can before setting pixels. then lock and set all your pixels from maybe an array. so basically make your own system memory buffer, which you can update at any time, and use that as a lookup table while plotting pixels. Simple enough? that way you can lock once, plot in 2 "for" loops, unlock, and flip. No BS.

Also if i seem like an idiot and what i said up top is no good at all then maybe this will help...

Track EVERYTHING. how many times you enter EACH FUNCTION. write it all to a text file. it will go a little slower but this way you can monitor EVERYTHING. Its my debug tactic. Itll work. youll see which functions are overused. just try it.


oh yeah and if i still seem like an idiot, well then im sorry. Im new to this game development thing.

-----------------------------
I''m almost finished my 3D Engine for the TI-83 calculator
-----------------------------;)I'm almost finished my 3D Engine for the TI-83 calculator ;)
Advertisement
I couldn''t help noticing the multiplies in the code... a possible optimization. Use a lookup table for anything you can calculate in advance.

-----------------------------
C++ is great, but when is B-
coming out?
-----------------------------C++ is great, but when is B-coming out?
BTW didnt mention before... DONT multiply within the pixel setting loop!!! ( yeah i know its been said alot). But creat a pointer to the first pixel in the drawing buffer. Then change the pointer by simply "adding" one. This will save you some MAD CPU time. Just use as many cool tricks you can think up to not use multiplication/division.once you lock... do your best to keep it drawing and only drawing.

-----------------------------
I''m almost finished my 3D Engine for the TI-83 calculator
-----------------------------;)I'm almost finished my 3D Engine for the TI-83 calculator ;)
DekuTree64>> Is that the DirectDraw BltFast funktion?

/MindWipe

"If it doesn''t fit, force it; if it breaks, it needed replacement anyway."
"To some its a six-pack, to me it's a support group."
Yo!
Well i think your code its ok and if it is slow is because you are calling that function many times per frame.

if your resolution is 800x600 and you are triying to fill the whole damn screen whit a color via that function, the system is making 800x600=480,000 calls to function per frame.

this is incredible slow because per every call to function the system eats many many resources and time.

i think the function is ok and it gonna be useful to plot a single pixel or a few pixel per frame.

if this is only an experiment to see the performance, its ok but you know if you need to fill the screen or a huge part use other methods like blt or bltfast or use memcpy per line, etc.

some tips:
1.-always try to avoid make multiplications. always use shifts and sums.
2.-some times you need to draw boxes or HUD's semi transparent(50% alpha), ok no problem but always make a lookup table in the initialization and then use it in the main procedure. dont make that calculation in the plotting function.

Ahumaro



Edited by - Ahumaro on February 23, 2001 1:18:55 PM
Nope. I have no idea how DDraws''s BltFast works, I just gave mine the same name cause I couldn''t think of anything else that explains what it does in such a small number of letters^^


-Deku-chan

DK Art (my site, which has little programming-related stuff on it, but you should go anyway^_^)

This topic is closed to new replies.

Advertisement