I'm trying to make a Famo.us game where I have a background Image ( an ImageSurface ) and then I put a bunch of other ImageSurfaces over the top and animate them. However the background surface doesn't stay in the background, for starters new ImageSurfaces are drawn underneath, then weirdly they start getting drawn on top. Exact same code generating the surfaces.
the background image has a Transform.behind applied to it.
The image below kind of shows the problem, some of the small squares are behind, and some are on top.
If it makes any difference, the surfaces are all in a HeaderFooterLayout
Any ideas whats going wrong? or how I could debug this?
check the zIndex value of the surfaces isn't the same as the zIndex of the white surface you're attempting to hide them behind. If they are the same (or unspecified) the browser hazards a guess, and you end up with z-fighting where the GPU can't actually decide what to render (the white surface or the tabs?) You could have your tabs resting on one zIndex value, and the white surface on the other.
(The following is written by Keith) For anyone else, what I did was add the following to the ImageSurface
properties: {
zIndex: -1000000
}
Oddly I tried with a zIndex of -10 etc, which didn't work, only once I made that zIndex huge did it seem to fall behind everything else.
Related
I'm trying to do something like what Auslogics Disk Defrag does with its custom window:
As can be seen, the blurred semi transparent shadow surrounding the window is much darker than the standard one, so the program must be drawing it by itself. The problem is, I can't find a way to paint anything transparent around a window.
In an answer to a similiar question, someone suggested creating a slightly bigger transparent window (using WS_EX_LAYERED + SetLayeredWindowAttributes()) behind the actual application window, and then do the translucent drawing on the transparent one. Not only does it sound like an ugly hack, it doesn't actually work. If, for example, one tries to draw a semi transparent black rectangle on a transparent window via GDI+, alpha blending is applied to the shape's color over the window background color (which would also be the transparency color) and then the shape is drawn with the calculated color, which obviously is not the window transparency, resulting in an opaque rectangle.
The semi transparent shadow is actually done by Gaussian Blur of the black square.
You can use this effect to create glows and drop shadows and use the
composite effect to apply the result to the original image. It is
useful in photo processing for filters like highlights and shadows.
You can use the output of this effect for input into lighting effects,
like the Specular Lighting or Diffuse Lighting effects, because the
alpha channel is blurred, too and lighting effects use the alpha
channel to determine surface geometry as a height map.
This effect is used by the built-in Shadow effect.
Refer: Gaussian blur effect
Then remove the standard frame, the entire window is your client area, so you can draw shadow in the extended frame.
Refer: Drawing in the Extended Frame Window
I think I've found a solution that works for me. I was hoping I wouldn't have to create an extra window just for the shadow, but every method I could find or think of would require me to draw all the controls by myself and/or somehow correct their alpha values.
So, I'm using a layered window with per pixel alpha. I paint over it with Direct2D, or, alternatively, I use some PNGs with transparency for the edges and corners of the shadow and copy them on a memory DC. Either way I simply recreate the shadow with the right dimensions when the window is resized, and call UpdateLayeredWindowIndirect. Both methods seem to be working well on Windows 7 and 10, and so far I haven't found any glitches.
Preventing it from showing on the taskbar was a bit tricky. All the ways I know have drawbacks. What worked best for me was making the layered window owned by the main one. At least that way it will only be visible on the desktop where the program is actually running, unlike other alternatives which would force it to show on every virtual desktop. Finally, because I disable that window, I interact with it by processing WM_SETCURSOR.
I have some homegrown code to draw a circle in SDL2 (It's slow). Each time I want to update the window, I have to call SDL_RenderClear() and redraw the same circle. Is there any way I can avoid clearing the circle but still clear the rest of the screen to allow me to draw everything else.
The circle has to be drawn over the top of everything else.
https://imgur.com/a/0qAgd1Y
I could draw the circle each time over the rest of the image, but that takes about 500ms.
I have a game I'm currently working on, and it uses multiple views (for a minimap for example).
Thing is, I would like to have a fading effect added at some point, so I thought I'd create a black image that is the size of the screen and change its alpha value with a timer. That part is not a problem.
What happens right now is the main area (ie window default view) is fading (because the opacity of the image is increasing), but the minimap (minimap view) is unaffected. This is normal behaviour for views, but is there a way to draw an image to the whole window, regardless of the views ?
Thanks in advance
To clarify, you have the default view where you'll draw the main game, then you'll have the minimap view where you would draw the minimap. At some point in the game you want the whole screen to fade to black. It sounds like you've been trying to draw a black image on the default view (changing the alpha) to make this effect work.
So, you need a third view that you draw your black image on to get this fading effect.
When I do page transition that shows the outside part of the stage (like CCTransitionFlipX), I can briefly see the sprites outside the screen while transition. It is really annoying. I thought I can manually check the position of the sprite in realtime and remove if it is off the screen. But that won't work if that sprite is partially outside. Is there something like UIKit's clipSubviews in cocos2d?
There's a ClippingNode class that might help.
Since the flip animation allows the user to see more than just the visible screen area, because the screen rotates, I think the behavior you observed may be expected.
I've encountered a problem drawing SFML Text. In my application, I use views as a sort of coordinate system for my application. Thus, a typical view would be 10 x 10 or 20 x 20. All my normal drawing functions work fine, when drawing primitives and lines, etc., and the relevant code doesn't have to know about the coordinate system.
However, when I tried to draw text to the screen, I found that it appeared gigantic. When I reduced the font size drastically, it appeared extremely blurry and pixellated, as if it were trying to render to GIANT pixels that are 1x1 in my view.
Is there a way to draw text with a standard font size, in a way that it won't be affected by the view? Ideally, my text would width/size-wise on any view? How can I accomplish this?
Thanks for any input!
(P.S., I'm using SFML 2.0, for reference)
You can set another view (i.e. apply OpenGL transformation) and render text after it. Here is an example from sfml tutorial:
sf::View View(sf::FloatRect(600, 700, 1400, 1300));
App.SetView(View);
// Draw the game...
App.SetView(App.GetDefaultView());
// Draw the interface...