Darkness Surrounds Me
BlitzMax Forums/BlitzMax Programming/Darkness Surrounds Me
| ||
Can someone please explain to me why these pixels are darkening when copied from the screen ?Strict Local pic:TPixmap,r,g,b SetGraphicsDriver GLMax2DDriver(),0 ' zero forces front buffer Graphics 800,600 SetBlend alphablend Repeat r=Rand(128,255) g=Rand(128,255) b=Rand(128,255) SetAlpha .5 SetColor r,g,b DrawOval Rand(800),Rand(600),Rand(64,256),Rand(64,256) SetAlpha 1 pic=GrabPixmap(0,0,800,600) Cls DrawImage LoadImage(Pic),0,0 WaitKey Flip 0 Until KeyDown(27) Actually, after I just posted it. I found the problem. So I guess it is now a challenge, can YOU see what's causing it ? |
| ||
SetAlpha 0.5 instead of SetAlpha 1? |
| ||
Nope. That's not the right answer. You can change the code too to see it still darkens the circles. |
| ||
Without testing: You do use "setcolor" without resetting back to white...so the grabbed image is tinted with the currently set color. Bye Ron |
| ||
On top of that, you don't clear the screen after drawing the grabbed image, so the next random colored oval will be blended with the previous oval. |
| ||
@ Tom I believe this is desired behaviour. Bye Ron |
| ||
Derron, you got it ! I was not resetting my color back to WHITE. Here is completed correct code: Run without debug for best speed. ;) I do have another question. Is it possible to plot directly to a TPIXMAP() bypassing TIMAGE ? That is, LINE, DRAWOVAL(), DRAWRECT(), DRAWIMAGE() ? |
| ||
Nope, you need to do software rendering then. DrawImage() https://github.com/GWRon/Dig/blob/master/base.gfx.imagehelper.bmx "DrawImageOnImage()" DrawOval() http://stackoverflow.com/questions/10322341/simple-algorithm-for-drawing-filled-ellipse-in-c-c DrawRect You should be able to do this on your own ;-) Line via Bresenham algorithm http://www.blitzbasic.com/Community/posts.php?topic=51143 bye Ron |
| ||
That's too bad. But, those are some great routines you posted, Derron. *BOOKMARKING* Thanks a lot guys ! Dju ever check out my fireball routine ? It's so innovative in its design, I figured someone would say something about it. :) http://www.blitzbasic.com/Community/posts.php?topic=107050 |
| ||
I am sure you are able to update your fireball now with the code posted. PS: I did not check that out - the code is surely something nifty, but for me not that "readable" as I like them to be - so I skipped that (and surely other cool stuff posted here and there). bye Ron |
| ||
Yep, fireball is working great. Really do appreciate your help here. Have a great Halloween too ! |