冒险解谜游戏中文网 ChinaAVG

标题: 【代理DLL汉化研究】 [C++] Overlay sample  覆盖代码实例 [打印本页]

作者: shane007    时间: 2009-5-22 11:37
标题: 【代理DLL汉化研究】 [C++] Overlay sample  覆盖代码实例
用于在全屏游戏上画东西,写字。! T. U% x/ W( [9 c- {
4 C) w) l+ J4 O# R$ q
原文
) d5 J3 h, N! F1 D: @8 Thttp://www.gamedev.net/community/forums/topic.asp?topic_id=359319
, ]* J, P7 \5 k) n9 N
2 H5 c( U5 B4 f8 {; lA lot of people seem interested in knowing how to render content over full-screen applications, like XFire and Co, judging by the number of posts about it. Here’s an unmanaged overlaying sample. Visual Studio 2003 and 2005 solutions are included.
5 V& x" R" ]1 k6 F: w  N$ D0 o$ |/ t& `4 R
The sample uses DirectDraw overlays to render a black 256x64 box to the top-left of the screen, with some text in it. I would’ve shown you a screenshot, but I can’t, due to the way overlays work. Overlays are displayed as the device is painting the monitor from the primary surface. If it’s painting a location where an overlay exists, it paints the monitor with its color instead of the primary surface. Consequently, you can’t capture that in an image.
% ~4 w' D: c" J* k- g( r5 C
) O: }! J# f: r( ~- kBack to the sample. The files of interest are:
/ Y- _% T5 h5 H8 C- [  A  XOverlay.cpp: Window creation (auto-generated, nothing interesting) and the main loop (important).8 j* I% k& O- N9 K+ }
overlay_renderer.h, overlay_renderer.cpp: The core of the sample. The code is fairly self-explanatory, though.' ?7 t, {/ x; B" z9 Y3 c
7 r$ [6 h- g0 c2 o
One important thing to keep in mind is that overlay support comes with a set of limitations. The following limitations are not checked or accounted for in the sample:) Z7 n# {$ _( W! L
dwAlignBoundarySrc3 c' @- Q" j. P) V8 A( X6 ^
dwAlignSizeSrc
0 f- e+ I: d+ H1 ~3 @. ?/ i! \dwAlignBoundaryDest( @. Z  ~9 Z: d! X! j1 y' k* T& ~
dwAlignSizeDest
0 b+ R  r# g  w- W; u* C4 G; ~dwAlignStrideAlign , @  M9 a8 b/ [0 i. V  r
dwMinOverlayStretch , x/ U5 v% i& S8 G* k( X
dwMaxOverlayStretch& B0 ~# w2 k9 ]( [/ x2 f8 A; L" E

/ i$ n7 a# n3 y! j) y' JThe limitations are hardware-dependent. For example, my X300 doesn’t impose any alignment restrictions for the source or destination overlay rectangles. In a product, however, you’d want to make sure you check for these and abide by them. Use CapsViewer to find out the limitations of your hardware quickly. I don’t know if the October SDK caps database includes DirectDraw caps or not, but consider checking it out.) d/ y& t' b2 U7 L

/ b4 ?1 M+ Q2 nThe limitations (and overlays in general) are documented under “DirectDraw->DirectDraw Essentials->Surfaces->Overlay Surfaces” in the DX7 documentation. It’s available at icarusIndie.4 Q: b* ]' `. Y' d
& C: j" g! ^  o6 U$ m4 }' @4 ^
I might write a managed port, if someone’s interested. All feedback’s welcome.




欢迎光临 冒险解谜游戏中文网 ChinaAVG (https://chinaavg.com/) Powered by Discuz! X3.2