Problem: Shader rendered meshes and ID3DXFont differ in WS_OVERLAPPED (top-level) window (okay) vs. WS_CHILD window (strangely scaled).
I have a windowed app (main window WS_OVERLAPPED style) which renders (to the client area) static and animated (skinned) meshes well. For the animated meshes I use Multianimation.fx and shader.vsh "borrowed" from the DX9 sample Multianimation. Static meshes are rendered via the device pipeline.
Wanting to add some other windows in the client area (properties and other editing aids), I moved the DirectX code to a WS_CHILD of the main window. To start with, the child window is sized to the main window's client area (no other children). Other than creating the child window with a parent in CreateWindow, I changed little in the code (storing the parent's HWND, etc.) and nothing in the DX related stuff. With the child being the same size as the main window client, buffer widths and heights remain the same (client-sized).
Static meshes rendered through the pipeline via mesh->DrawSubset(), DrawPrimitive, etc., are fine. However, the animated meshes rendered by the shader are rendered strangely scaled, differently along different axes, my own character meshes and even tiny.x (Microsoft's own). The only time anything appears scaled correctly is when the aspect ratio is 1:1, and even then, it seems to be only along one (Z) axis.
Trying to find clues, I found that text drawn to the scene using ID3DXFont also exhibits squashing and stretching as the window size changes. However, differing from the shader-draw meshes, the screen text (seems to) appear correct only at the original aspect ratio AND the original window size. Even at the original aspect ratio, the text is distorted at other than the original window size.
I've tried various combinations of things:
- Creating the device (with swapeffect COPY) with the main window's handle and presenting to the child; no change in behavior.
- Defaulting the backbuffer width/height to constant values, whatever the main window size. No joy there, EXCEPT...
- Defaulted the backbuffer width/height for an aspect of 1:1 (e.g., both width and height = 800) and presenting to the child's window handle with the destination rectangle { 0, 0, 800, 800 }. That exhibited the same behavior as any at an aspect of 1:1. Shader-rendered meshes appeared to be scaled correctly only along one axis. The ID3DXFont display was correct (the backbuffer size never changed). Again, stuff rendered via the pipeline was fine.
Again, please note, the static and shader meshes, and the screen text appear fine when renders in the client area of a WS_OVERLAPPED window.
Anyone have any ideas? Has anyone successfully used a WS_CHILD style window for rendering with shaders and/or ID3DXFont text?