Window drop shadows - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Window drop shadows (/thread-246.html)
Window drop shadows - NelsonMandella - Mar 14, 2010 04:53 PM
I'm writing a gui for opengl and I'm trying to add drop shadows to my windows, similar to those used in os x. I'm using a squarish gradient texture for the shadow, and when I resize the window, the drop shadow's size becomes distorted in relation to that of the window. Is there any way around this?
Window drop shadows - akb825 - Mar 14, 2010 05:03 PM
Instead of taking a single rectangle for the entire window and scaling it, you're going to need to create 3 rectangles: one for the bottom of the shadow, one for the right, and one for the corner to fill in the gap between the other two. Only scale the bottom rectangle along the x axis and only scale the right rectangle along the y axis. The corner rectangle never needs to be scaled. As an optimization, you can use a single 1-D texture for both the bottom and right rectangles, and a 2D texture for the corner rectangle.
Window drop shadows - NelsonMandella - Mar 14, 2010 06:55 PM
Thanks. I feel like such an idiot for not thinking of that considering that's how I already render window frames
Window drop shadows - NelsonMandella - Mar 17, 2010 11:32 AM
Okay, another question on a closely related topic. I'm trying to figure out the best way to optimize my window drawing routine. The current version draws a window, then its content, starting with the bottom window layer going through the top, using a scissor test for each window to keep the drawing within its bounds.
So I'd like to be able to draw only the portions of windows that are visible(not obscured by other windows). Is there some way to do this without performing a stencil test? And would the performance penalty incurred by a stencil test offset the performance gain received by only drawing visible regions(or might this depend on the windows content)?
Window drop shadows - OneSadCookie - Mar 17, 2010 01:25 PM
draw front to back with a depth test?
Window drop shadows - AnotherJake - Mar 17, 2010 06:23 PM
OneSadCookie Wrote:draw front to back with a depth test?
In addition to that, I'm guessing you'll probably have to draw the translucent window drop shadows last, and back to front though. Probably with depth test on but the depth mask off.
Window drop shadows - NelsonMandella - Mar 18, 2010 12:31 PM
AnotherJake Wrote:In addition to that, I'm guessing you'll probably have to draw the translucent window drop shadows last, and back to front though. Probably with depth test on but the depth mask off.
Yeah that's the part I wasn't quite sure about, but that sounds about right, thanks.
Window drop shadows - NelsonMandella - Mar 20, 2010 02:22 PM
Okay, I'm having a real difficult time getting the depth buffer to work as I'd like it to, this is also my first time ever using it.
I'm using glortho and my understanding is that both znear and zfar must be positive and that each refers to depth along the negative z axis. So I've specified znear as 1.0 and zfar as 100.0.
I'm trying to draw windows from top to bottom, where the top windows layer is 0, and the second to the top is 1, etc...
Here's my pseudo code.
The effects of this code seem to be that the frontmost window is all the way at the back instead of the front.
Window drop shadows - ThemsAllTook - Mar 20, 2010 09:40 PM
The Z axis runs from far to near. Your comment on Z_NEAR is correct, though, for gluPerspective at least; it measures distance along the -Z axis. So, near objects should have a greater Z coordinate than far objects.
Window drop shadows - NelsonMandella - Mar 21, 2010 02:34 PM
Resolved. I was accidently setting the depth variable elsewhere in my program without being aware of it.