|
Post by NeX on Oct 8, 2015 13:35:35 GMT -8
Hi there,
I am trying to fade out the entire screen by drawing a big black rectangle over everything and decreasing its transparency over time.
the screen content is drawn before and then the rectangle is drawn last, so it should be on top of everything,
but there is a couple of horizontal lines that span the whole width of the screen, they are approximately 5 pixels wide, and correspond in the Y axis to lines that are already on the screen which have had their alpha channel changed.
i have used the SaveContext function to isolate these lines, but the problem remains
is there some kind of compound effect of adjusting the alpha channel?
also a secondary problem which may or may not be linked, black and white bitmaps, (possibly only L4 formats, but maybe L8 i haven't tested) are showing up as transparent in the black areas,
is this also an alpha channel issue or something else? i am not using any blend functions anywhere, all changes to the alpha channels are done within savecontext sections of the code except the black rectangle and setting the alpha to be 255 right before drawing the bitmaps still doesn't do anything.
any pointers would be great!
|
|
|
Post by jamesbowman on Oct 8, 2015 14:46:42 GMT -8
This should work. The final black rectangle could be drawn like this:
GD.BlendFunc(SRC_ALPHA, ONE_MINUS_SRC_ALPHA); GD.ColorA(fade); // fade factor 0-255 GD.ColorRGB(0x000000); GD.Begin(RECTS); GD.Vertex2ii(0, 0); GD.Vertex2ii(480, 272); Note the BlendFunc() call.
As an alternative, you can always just use the backlight to fade out:
for (int i = 127; i >= 0; i--) { GD.wr(REG_PWM_DUTY, i); delay(2); }
|
|
|
Post by NeX on Oct 9, 2015 4:59:06 GMT -8
Thanks for the reply James, but actually that still leaves me with the same problem, i still have areas of the screen that remain visible even after fading out. could it be a bug? it seems to be related to lines drawn on the screen, only lines that are drawn with their ColorA changed and only lines that are on top of other lines, and only horizontal lines. does that make sense?
i think the backlight fade might be the only way, thanks for the tip
|
|
|
Post by jamesbowman on Oct 9, 2015 7:03:47 GMT -8
OK, this is interesting!
(1) It could be that this is a case of line buffer overflow. If the picture is *really* complex then lines can start flickering.
If you draw the full-screen rectangle with alpha=0, so that it is fully invisible, do you still see the problem?
(2) It is possible that some piece of graphics state is affecting final rendering. If you pop the context stack 5 times before drawing, all state is returned to its default value.
GD.RestoreContext(); GD.RestoreContext(); GD.RestoreContext(); GD.RestoreContext(); GD.RestoreContext();
GD.BlendFunc(SRC_ALPHA, ONE_MINUS_SRC_ALPHA); GD.ColorA(fade); // fade factor 0-255 GD.ColorRGB(0x000000); GD.Begin(RECTS); GD.Vertex2ii(0, 0); GD.Vertex2ii(480, 272);
|
|
|
Post by NeX on Oct 9, 2015 7:33:33 GMT -8
I will try this in a moment and report back, but it does sound like a buffer overflow.
I have been adding a fade to my background by drawing a 50px line from the top to the bottom of the screen, at 20% transparency and repeating the line with decreasing pixel width until it is 1 pixel wide. i have used this a lot on the screen to add faded drop shadows. i would say there could easily be 300 lines on the screen. the problem lines also seem to be the last ones drawn, so it is sounding more and more like an overflow problem.
what is the limit of lines?
|
|
|
Post by NeX on Oct 9, 2015 8:11:14 GMT -8
nope same problem, some areas of the screen stay visible during the fade. setting the alpha of the rectangle to 0 does as expected, as in the screen just looks normal because the rectangle is invisible.
|
|
|
Post by NeX on Oct 12, 2015 9:04:03 GMT -8
I just thought i would say, i have removed the problem simply by drawing less lines on the screen, so it does seem that there is an issue with the line buffer overflowing.
|
|