• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Ryan_001

Windows Desktop Manager

7 posts in this topic

Since Windows Vista all drawing to the screen has been done using the WDM. To my knowledge this creates a texture/back buffer on the video card for each top level window, and then uses these textures for compositing the final image we see. I've scoured MSDN (in particular here: [url="http://msdn.microsoft.com/en-us/library/windows/desktop/aa969540(v=vs.85).aspx"]http://msdn.microsof...0(v=vs.85).aspx[/url] and [url="http://msdn.microsoft.com/en-us/library/aa969540(v=vs.85).aspx"]http://msdn.microsof...0(v=vs.85).aspx[/url]) and google, but cannot find the answers to a few basic questions.

Is there any way I can get direct access to the texture/back buffer for a particular window? The documentation seems to imply Direct3D applications write directly to this texture, but there's no documentation about it, or any description on the details. What happens when a window is resized? How does it handle double buffering/swap chains? How do I enable per-pixel transparency (which it should be able to do in real-time without the Layered Windows mess)? How do Layered Windows integrate into this?

If I can get direct access to the texture, is there any way to render to it via OpenGL, or am I stuck with Direct3d?

I know are kinda esoteric questions, but any links, documents, or thoughts are appreciated.

Thanks in advance and Happy Thanksgiving/Columbus day [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
0

Share this post


Link to post
Share on other sites
First you can use OpenGL or Direct3D to do transparency and pixel manipulation. They give direct almost direct access to the texture.

[quote name='Ryan_001' timestamp='1349749686' post='4988193']
Is there any way I can get direct access to the texture/back buffer for a particular window?
[/quote]

What do you need this for? Because the answer may be different based on what you require.
This is because transparency, and psuedo-direct pixel manipulation can be achieved in OpenGL, Direct3D, and GDI.

[quote name='Ryan_001' timestamp='1349749686' post='4988193']
What happens when a window is resized? How does it handle double buffering/swap chains? How do I enable per-pixel transparency (which it should be able to do in real-time without the Layered Windows mess)? How do Layered Windows integrate into this?
[/quote]

All of these questions depend on what technology you are talking about.
0

Share this post


Link to post
Share on other sites
[quote name='slicksk8te' timestamp='1349803179' post='4988415']
First you can use OpenGL or Direct3D to do transparency and pixel manipulation. They give direct almost direct access to the texture.
[/quote]

Cool... how?

[quote]
[quote name='Ryan_001' timestamp='1349749686' post='4988193']
Is there any way I can get direct access to the texture/back buffer for a particular window?
[/quote]

What do you need this for? Because the answer may be different based on what you require.
This is because transparency, and psuedo-direct pixel manipulation can be achieved in OpenGL, Direct3D, and GDI.
[/quote]

Well for transparency (which you mentioned can be achieved without needing direct access), but also my other two questions remain. What happens when a window is resized? How does it handle double buffering/swap chains? For example is the back-buffer in a Direct3D swap chain the WDM texture? Does it blit from the swap chain to the WDM texture on Present()? It just seems I can save a fair amount of memory/time/hassle by rendering directly to the WDM texture and bypassing the rest of it.
0

Share this post


Link to post
Share on other sites
[quote name='Ryan_001' timestamp='1349812406' post='4988455']
What happens when a window is resized?
[/quote]

If you are working with DirectX you need to reinitialize the surface just as you initialized it but with a different resolution. Typically though in DirectX the window is static size and cannot be re-sized. OpenGL is about the same as DirectX in this respect because they both need to reinitialize the buffers and that is left to the programmer. If you are using the GDI however, you do not need to worry about any of the resizing because the OS will handle the surface (HDC) for you. To use transparent textures with GDI, check out AlphaBlend or TransparentBlit.

[quote name='Ryan_001' timestamp='1349812406' post='4988455']
How does it handle double buffering/swap chains? For example is the back-buffer in a Direct3D swap chain the WDM texture? Does it blit from the swap chain to the WDM texture on Present()?
[/quote]

The swap chain is not the WDM texture but instead a secondary buffer. When you call Present, it copies this to the WDM Texture. This is a good thing because it forces windows to stay inside their drawing regions.

[quote name='Ryan_001' timestamp='1349812406' post='4988455']
It just seems I can save a fair amount of memory/time/hassle by rendering directly to the WDM texture and bypassing the rest of it.
[/quote]

The amount of memory you are saving is very low on modern systems and will give you very very little gain. I would expect that it would take much more time/hassle to draw directly to the WDM texture because you would have to do all the drawing functions from scratch.
0

Share this post


Link to post
Share on other sites
[quote name='slicksk8te' timestamp='1349817615' post='4988491']
[quote name='Ryan_001' timestamp='1349812406' post='4988455']
What happens when a window is resized?
[/quote]

If you are working with DirectX you need to reinitialize the surface just as you initialized it but with a different resolution. Typically though in DirectX the window is static size and cannot be re-sized. OpenGL is about the same as DirectX in this respect because they both need to reinitialize the buffers and that is left to the programmer. If you are using the GDI however, you do not need to worry about any of the resizing because the OS will handle the surface (HDC) for you. To use transparent textures with GDI, check out AlphaBlend or TransparentBlit.
[/quote]

I think you've missed the point, maybe I'm not being clear. I know what I have to do when a resize occurs with Direct3D/OpenGL. I'd like to know how the WDM handles a resize internally. There's seems to be little point in setting up a swap chain (and the buffers associated with it) and reintializing every time the window is resized when a simple device->SetRenderTarget(0,GetWDMTexture()); or equivalent would seem to suffice (I understand that swap chains handle a few other situations like multi-sampling and double/triple buffering which would have to be performed 'manually' if this technique were possible/used). Also I'm not interested in how to do transparency using GDI code, but rather how do I render with Direct3D/OpenGL to the WDM texture such that the alpha channel is preserved and causes the appropriate pixels on my window to be translucent?

[quote]
[quote name='Ryan_001' timestamp='1349812406' post='4988455']
How does it handle double buffering/swap chains? For example is the back-buffer in a Direct3D swap chain the WDM texture? Does it blit from the swap chain to the WDM texture on Present()?
[/quote]

The swap chain is not the WDM texture but instead a secondary buffer. When you call Present, it copies this to the WDM Texture. This is a good thing because it forces windows to stay inside their drawing regions.
[/quote]

This is probably true when not using the WDM, but when using the WDM each window has its own unique texture which is rendered to the screen by a pair of triangles (ie. a quad) with the texture mapped to it. Regardless of where on the sceen the window is, the WDM texture is the same. You couldn't render outside the drawing region without rendering outside the WDM texture regardless of a Windows position/placement on screen.
0

Share this post


Link to post
Share on other sites
Basically, no you can't do what you want. Though I admit I can not say that I am 100% of certain of that (though I AM sure that you can't do it all), I am pretty sure. Some food for thought, some of which will answer some of your questions, and some of which may be useful to help you in your quest if you continue to pursue it:

1) It's DWM (Desktop Window Manager) not WDM. Not being pedantic, just thought it might help your searches if you use the right terminology ;)

2) When you setup a swap chain in Direct3D windows mode, DirectX coordinates with DWM to provide the surface that you are rendering to, which is the DWM surface. This is a video memory surface that is owned by DWM.exe but which is shared across process boundaries by virtue of the WDDM (Windows Display Driver Model). When you Present, the DWM is notified that the surface is "dirty" so it can be recomposited on the primary surface.

3) Preserving the alpha values would not help you do what you want anyway, because you don't have control of the shaders that are used when compositing your window on the primary surface.
0

Share this post


Link to post
Share on other sites
[quote name='krippy2k8' timestamp='1349853941' post='4988630']
Basically, no you can't do what you want. Though I admit I can not say that I am 100% of certain of that (though I AM sure that you can't do it all), I am pretty sure. Some food for thought, some of which will answer some of your questions, and some of which may be useful to help you in your quest if you continue to pursue it:

1) It's DWM (Desktop Window Manager) not WDM. Not being pedantic, just thought it might help your searches if you use the right terminology ;)[/quote]

Ahh sorry, late night posting bites me again :) You are correct.

[quote]
2) When you setup a swap chain in Direct3D windows mode, DirectX coordinates with DWM to provide the surface that you are rendering to, which is the DWM surface. This is a video memory surface that is owned by DWM.exe but which is shared across process boundaries by virtue of the WDDM (Windows Display Driver Model). When you Present, the DWM is notified that the surface is "dirty" so it can be recomposited on the primary surface.[/quote]

Ya, I read that. I was unsure of how much of the 'swap chain' was shared, and how they interacted.

[quote]3) Preserving the alpha values would not help you do what you want anyway, because you don't have control of the shaders that are used when compositing your window on the primary surface.[/quote]

True, the shaders though must allow some sort of transparency. I don't really see any reason for them to not use the alpha channel... I'm not saying your aren't correct (the devs at Microsoft have done weirder things), but it still would seem strange.

There's just so little documentation about the DWM in the MSDN library, I was hoping someone here might have seen, read, or heard something I hadn't. Even Raymond Chen said on his blog: "Yes, there's a new desktop window manager, but no, I don't know any more about it than you do" (and I thought he knew everything there was to know about Windows).
0

Share this post


Link to post
Share on other sites
Raymond Chen [i]also[/i] regularly recommends you to stick to well documented public APIs rather than relying on implementation details not meant for external usage.

The specifics of how the DWM operates aren't documented on purpose because they're implementation details that might change at any time and break any software that relies on them.


Do you really want to trade-off the potential that an update may break your software without prior notice in exchange for a small performance gain that may or more not actually be achievable? It may well be possible to do what you're thinking about, but that doesn't make it a good idea.

//EDIT: If you're just investigating out of curiosity then I wish you luck in your search, but if you're writing production software please don't inflict the world with more fragile software that might suddenly stop working.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0