├── Direct3d ├── d3d9.lib ├── d3dx9.h ├── d3dx9.lib ├── d3dx9anim.h ├── d3dx9core.h ├── d3dx9effect.h ├── d3dx9math.h ├── d3dx9math.inl ├── d3dx9mesh.h ├── d3dx9shader.h ├── d3dx9shape.h ├── d3dx9tex.h └── d3dx9xof.h ├── Imgui ├── imconfig.h ├── imgui.cpp ├── imgui.h ├── imgui_demo.cpp ├── imgui_draw.cpp ├── imgui_impl_dx9.cpp ├── imgui_impl_dx9.h ├── imgui_impl_win32.cpp ├── imgui_impl_win32.h ├── imgui_internal.h ├── imgui_tables.cpp ├── imgui_widgets.cpp ├── imstb_rectpack.h ├── imstb_textedit.h └── imstb_truetype.h ├── LICENSE ├── README.md └── Valorant ├── Driver └── driver.hpp ├── Game ├── cheat.hpp ├── globals.hpp ├── sdk.hpp └── structs.hpp ├── Overlay ├── menu.hpp └── render.hpp ├── Valorant.vcxproj ├── Valorant.vcxproj.filters └── main.cpp /Direct3d/d3d9.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/httpsprotocol/Valorant-External/d44ddc7e66452e650af70eac94e56486d36eac4d/Direct3d/d3d9.lib -------------------------------------------------------------------------------- /Direct3d/d3dx9.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) Microsoft Corporation. All Rights Reserved. 4 | // 5 | // File: d3dx9.h 6 | // Content: D3DX utility library 7 | // 8 | ////////////////////////////////////////////////////////////////////////////// 9 | 10 | #ifdef __D3DX_INTERNAL__ 11 | #error Incorrect D3DX header used 12 | #endif 13 | 14 | #ifndef __D3DX9_H__ 15 | #define __D3DX9_H__ 16 | 17 | 18 | // Defines 19 | #include 20 | 21 | #define D3DX_DEFAULT ((UINT) -1) 22 | #define D3DX_DEFAULT_NONPOW2 ((UINT) -2) 23 | #define D3DX_DEFAULT_FLOAT FLT_MAX 24 | #define D3DX_FROM_FILE ((UINT) -3) 25 | #define D3DFMT_FROM_FILE ((D3DFORMAT) -3) 26 | 27 | #ifndef D3DXINLINE 28 | #ifdef _MSC_VER 29 | #if (_MSC_VER >= 1200) 30 | #define D3DXINLINE __forceinline 31 | #else 32 | #define D3DXINLINE __inline 33 | #endif 34 | #else 35 | #ifdef __cplusplus 36 | #define D3DXINLINE inline 37 | #else 38 | #define D3DXINLINE 39 | #endif 40 | #endif 41 | #endif 42 | 43 | 44 | 45 | // Includes 46 | #include "d3d9.h" 47 | #include "d3dx9math.h" 48 | #include "d3dx9core.h" 49 | #include "d3dx9xof.h" 50 | #include "d3dx9mesh.h" 51 | #include "d3dx9shader.h" 52 | #include "d3dx9effect.h" 53 | 54 | #include "d3dx9tex.h" 55 | #include "d3dx9shape.h" 56 | #include "d3dx9anim.h" 57 | 58 | 59 | 60 | // Errors 61 | #define _FACDD 0x876 62 | #define MAKE_DDHRESULT( code ) MAKE_HRESULT( 1, _FACDD, code ) 63 | 64 | enum _D3DXERR { 65 | D3DXERR_CANNOTMODIFYINDEXBUFFER = MAKE_DDHRESULT(2900), 66 | D3DXERR_INVALIDMESH = MAKE_DDHRESULT(2901), 67 | D3DXERR_CANNOTATTRSORT = MAKE_DDHRESULT(2902), 68 | D3DXERR_SKINNINGNOTSUPPORTED = MAKE_DDHRESULT(2903), 69 | D3DXERR_TOOMANYINFLUENCES = MAKE_DDHRESULT(2904), 70 | D3DXERR_INVALIDDATA = MAKE_DDHRESULT(2905), 71 | D3DXERR_LOADEDMESHASNODATA = MAKE_DDHRESULT(2906), 72 | D3DXERR_DUPLICATENAMEDFRAGMENT = MAKE_DDHRESULT(2907), 73 | D3DXERR_CANNOTREMOVELASTITEM = MAKE_DDHRESULT(2908), 74 | }; 75 | 76 | 77 | #endif //__D3DX9_H__ 78 | -------------------------------------------------------------------------------- /Direct3d/d3dx9.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/httpsprotocol/Valorant-External/d44ddc7e66452e650af70eac94e56486d36eac4d/Direct3d/d3dx9.lib -------------------------------------------------------------------------------- /Direct3d/d3dx9core.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) Microsoft Corporation. All Rights Reserved. 4 | // 5 | // File: d3dx9core.h 6 | // Content: D3DX core types and functions 7 | // 8 | /////////////////////////////////////////////////////////////////////////// 9 | 10 | #include "d3dx9.h" 11 | 12 | #ifndef __D3DX9CORE_H__ 13 | #define __D3DX9CORE_H__ 14 | 15 | 16 | /////////////////////////////////////////////////////////////////////////// 17 | // D3DX_SDK_VERSION: 18 | // ----------------- 19 | // This identifier is passed to D3DXCheckVersion in order to ensure that an 20 | // application was built against the correct header files and lib files. 21 | // This number is incremented whenever a header (or other) change would 22 | // require applications to be rebuilt. If the version doesn't match, 23 | // D3DXCheckVersion will return FALSE. (The number itself has no meaning.) 24 | /////////////////////////////////////////////////////////////////////////// 25 | 26 | #define D3DX_VERSION 0x0902 27 | 28 | #define D3DX_SDK_VERSION 43 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif //__cplusplus 33 | 34 | BOOL WINAPI 35 | D3DXCheckVersion(UINT D3DSdkVersion, UINT D3DXSdkVersion); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif //__cplusplus 40 | 41 | 42 | 43 | /////////////////////////////////////////////////////////////////////////// 44 | // D3DXDebugMute 45 | // Mutes D3DX and D3D debug spew (TRUE - mute, FALSE - not mute) 46 | // 47 | // returns previous mute value 48 | // 49 | /////////////////////////////////////////////////////////////////////////// 50 | 51 | #ifdef __cplusplus 52 | extern "C" { 53 | #endif //__cplusplus 54 | 55 | BOOL WINAPI 56 | D3DXDebugMute(BOOL Mute); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif //__cplusplus 61 | 62 | 63 | /////////////////////////////////////////////////////////////////////////// 64 | // D3DXGetDriverLevel: 65 | // Returns driver version information: 66 | // 67 | // 700 - DX7 level driver 68 | // 800 - DX8 level driver 69 | // 900 - DX9 level driver 70 | /////////////////////////////////////////////////////////////////////////// 71 | 72 | #ifdef __cplusplus 73 | extern "C" { 74 | #endif //__cplusplus 75 | 76 | UINT WINAPI 77 | D3DXGetDriverLevel(LPDIRECT3DDEVICE9 pDevice); 78 | 79 | #ifdef __cplusplus 80 | } 81 | #endif //__cplusplus 82 | 83 | 84 | /////////////////////////////////////////////////////////////////////////// 85 | // ID3DXBuffer: 86 | // ------------ 87 | // The buffer object is used by D3DX to return arbitrary size data. 88 | // 89 | // GetBufferPointer - 90 | // Returns a pointer to the beginning of the buffer. 91 | // 92 | // GetBufferSize - 93 | // Returns the size of the buffer, in bytes. 94 | /////////////////////////////////////////////////////////////////////////// 95 | 96 | typedef interface ID3DXBuffer ID3DXBuffer; 97 | typedef interface ID3DXBuffer *LPD3DXBUFFER; 98 | 99 | // {8BA5FB08-5195-40e2-AC58-0D989C3A0102} 100 | DEFINE_GUID(IID_ID3DXBuffer, 101 | 0x8ba5fb08, 0x5195, 0x40e2, 0xac, 0x58, 0xd, 0x98, 0x9c, 0x3a, 0x1, 0x2); 102 | 103 | #undef INTERFACE 104 | #define INTERFACE ID3DXBuffer 105 | 106 | DECLARE_INTERFACE_(ID3DXBuffer, IUnknown) 107 | { 108 | // IUnknown 109 | STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; 110 | STDMETHOD_(ULONG, AddRef)(THIS) PURE; 111 | STDMETHOD_(ULONG, Release)(THIS) PURE; 112 | 113 | // ID3DXBuffer 114 | STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE; 115 | STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE; 116 | }; 117 | 118 | 119 | 120 | ////////////////////////////////////////////////////////////////////////////// 121 | // D3DXSPRITE flags: 122 | // ----------------- 123 | // D3DXSPRITE_DONOTSAVESTATE 124 | // Specifies device state is not to be saved and restored in Begin/End. 125 | // D3DXSPRITE_DONOTMODIFY_RENDERSTATE 126 | // Specifies device render state is not to be changed in Begin. The device 127 | // is assumed to be in a valid state to draw vertices containing POSITION0, 128 | // TEXCOORD0, and COLOR0 data. 129 | // D3DXSPRITE_OBJECTSPACE 130 | // The WORLD, VIEW, and PROJECTION transforms are NOT modified. The 131 | // transforms currently set to the device are used to transform the sprites 132 | // when the batch is drawn (at Flush or End). If this is not specified, 133 | // WORLD, VIEW, and PROJECTION transforms are modified so that sprites are 134 | // drawn in screenspace coordinates. 135 | // D3DXSPRITE_BILLBOARD 136 | // Rotates each sprite about its center so that it is facing the viewer. 137 | // D3DXSPRITE_ALPHABLEND 138 | // Enables ALPHABLEND(SRCALPHA, INVSRCALPHA) and ALPHATEST(alpha > 0). 139 | // ID3DXFont expects this to be set when drawing text. 140 | // D3DXSPRITE_SORT_TEXTURE 141 | // Sprites are sorted by texture prior to drawing. This is recommended when 142 | // drawing non-overlapping sprites of uniform depth. For example, drawing 143 | // screen-aligned text with ID3DXFont. 144 | // D3DXSPRITE_SORT_DEPTH_FRONTTOBACK 145 | // Sprites are sorted by depth front-to-back prior to drawing. This is 146 | // recommended when drawing opaque sprites of varying depths. 147 | // D3DXSPRITE_SORT_DEPTH_BACKTOFRONT 148 | // Sprites are sorted by depth back-to-front prior to drawing. This is 149 | // recommended when drawing transparent sprites of varying depths. 150 | // D3DXSPRITE_DO_NOT_ADDREF_TEXTURE 151 | // Disables calling AddRef() on every draw, and Release() on Flush() for 152 | // better performance. 153 | ////////////////////////////////////////////////////////////////////////////// 154 | 155 | #define D3DXSPRITE_DONOTSAVESTATE (1 << 0) 156 | #define D3DXSPRITE_DONOTMODIFY_RENDERSTATE (1 << 1) 157 | #define D3DXSPRITE_OBJECTSPACE (1 << 2) 158 | #define D3DXSPRITE_BILLBOARD (1 << 3) 159 | #define D3DXSPRITE_ALPHABLEND (1 << 4) 160 | #define D3DXSPRITE_SORT_TEXTURE (1 << 5) 161 | #define D3DXSPRITE_SORT_DEPTH_FRONTTOBACK (1 << 6) 162 | #define D3DXSPRITE_SORT_DEPTH_BACKTOFRONT (1 << 7) 163 | #define D3DXSPRITE_DO_NOT_ADDREF_TEXTURE (1 << 8) 164 | 165 | 166 | ////////////////////////////////////////////////////////////////////////////// 167 | // ID3DXSprite: 168 | // ------------ 169 | // This object intends to provide an easy way to drawing sprites using D3D. 170 | // 171 | // Begin - 172 | // Prepares device for drawing sprites. 173 | // 174 | // Draw - 175 | // Draws a sprite. Before transformation, the sprite is the size of 176 | // SrcRect, with its top-left corner specified by Position. The color 177 | // and alpha channels are modulated by Color. 178 | // 179 | // Flush - 180 | // Forces all batched sprites to submitted to the device. 181 | // 182 | // End - 183 | // Restores device state to how it was when Begin was called. 184 | // 185 | // OnLostDevice, OnResetDevice - 186 | // Call OnLostDevice() on this object before calling Reset() on the 187 | // device, so that this object can release any stateblocks and video 188 | // memory resources. After Reset(), the call OnResetDevice(). 189 | ////////////////////////////////////////////////////////////////////////////// 190 | 191 | typedef interface ID3DXSprite ID3DXSprite; 192 | typedef interface ID3DXSprite *LPD3DXSPRITE; 193 | 194 | 195 | // {BA0B762D-7D28-43ec-B9DC-2F84443B0614} 196 | DEFINE_GUID(IID_ID3DXSprite, 197 | 0xba0b762d, 0x7d28, 0x43ec, 0xb9, 0xdc, 0x2f, 0x84, 0x44, 0x3b, 0x6, 0x14); 198 | 199 | 200 | #undef INTERFACE 201 | #define INTERFACE ID3DXSprite 202 | 203 | DECLARE_INTERFACE_(ID3DXSprite, IUnknown) 204 | { 205 | // IUnknown 206 | STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; 207 | STDMETHOD_(ULONG, AddRef)(THIS) PURE; 208 | STDMETHOD_(ULONG, Release)(THIS) PURE; 209 | 210 | // ID3DXSprite 211 | STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; 212 | 213 | STDMETHOD(GetTransform)(THIS_ D3DXMATRIX *pTransform) PURE; 214 | STDMETHOD(SetTransform)(THIS_ CONST D3DXMATRIX *pTransform) PURE; 215 | 216 | STDMETHOD(SetWorldViewRH)(THIS_ CONST D3DXMATRIX *pWorld, CONST D3DXMATRIX *pView) PURE; 217 | STDMETHOD(SetWorldViewLH)(THIS_ CONST D3DXMATRIX *pWorld, CONST D3DXMATRIX *pView) PURE; 218 | 219 | STDMETHOD(Begin)(THIS_ DWORD Flags) PURE; 220 | STDMETHOD(Draw)(THIS_ LPDIRECT3DTEXTURE9 pTexture, CONST RECT *pSrcRect, CONST D3DXVECTOR3 *pCenter, CONST D3DXVECTOR3 *pPosition, D3DCOLOR Color) PURE; 221 | STDMETHOD(Flush)(THIS) PURE; 222 | STDMETHOD(End)(THIS) PURE; 223 | 224 | STDMETHOD(OnLostDevice)(THIS) PURE; 225 | STDMETHOD(OnResetDevice)(THIS) PURE; 226 | }; 227 | 228 | 229 | #ifdef __cplusplus 230 | extern "C" { 231 | #endif //__cplusplus 232 | 233 | HRESULT WINAPI 234 | D3DXCreateSprite( 235 | LPDIRECT3DDEVICE9 pDevice, 236 | LPD3DXSPRITE* ppSprite); 237 | 238 | #ifdef __cplusplus 239 | } 240 | #endif //__cplusplus 241 | 242 | 243 | 244 | ////////////////////////////////////////////////////////////////////////////// 245 | // ID3DXFont: 246 | // ---------- 247 | // Font objects contain the textures and resources needed to render a specific 248 | // font on a specific device. 249 | // 250 | // GetGlyphData - 251 | // Returns glyph cache data, for a given glyph. 252 | // 253 | // PreloadCharacters/PreloadGlyphs/PreloadText - 254 | // Preloads glyphs into the glyph cache textures. 255 | // 256 | // DrawText - 257 | // Draws formatted text on a D3D device. Some parameters are 258 | // surprisingly similar to those of GDI's DrawText function. See GDI 259 | // documentation for a detailed description of these parameters. 260 | // If pSprite is NULL, an internal sprite object will be used. 261 | // 262 | // OnLostDevice, OnResetDevice - 263 | // Call OnLostDevice() on this object before calling Reset() on the 264 | // device, so that this object can release any stateblocks and video 265 | // memory resources. After Reset(), the call OnResetDevice(). 266 | ////////////////////////////////////////////////////////////////////////////// 267 | 268 | typedef struct _D3DXFONT_DESCA 269 | { 270 | INT Height; 271 | UINT Width; 272 | UINT Weight; 273 | UINT MipLevels; 274 | BOOL Italic; 275 | BYTE CharSet; 276 | BYTE OutputPrecision; 277 | BYTE Quality; 278 | BYTE PitchAndFamily; 279 | CHAR FaceName[LF_FACESIZE]; 280 | 281 | } D3DXFONT_DESCA, *LPD3DXFONT_DESCA; 282 | 283 | typedef struct _D3DXFONT_DESCW 284 | { 285 | INT Height; 286 | UINT Width; 287 | UINT Weight; 288 | UINT MipLevels; 289 | BOOL Italic; 290 | BYTE CharSet; 291 | BYTE OutputPrecision; 292 | BYTE Quality; 293 | BYTE PitchAndFamily; 294 | WCHAR FaceName[LF_FACESIZE]; 295 | 296 | } D3DXFONT_DESCW, *LPD3DXFONT_DESCW; 297 | 298 | #ifdef UNICODE 299 | typedef D3DXFONT_DESCW D3DXFONT_DESC; 300 | typedef LPD3DXFONT_DESCW LPD3DXFONT_DESC; 301 | #else 302 | typedef D3DXFONT_DESCA D3DXFONT_DESC; 303 | typedef LPD3DXFONT_DESCA LPD3DXFONT_DESC; 304 | #endif 305 | 306 | 307 | typedef interface ID3DXFont ID3DXFont; 308 | typedef interface ID3DXFont *LPD3DXFONT; 309 | 310 | 311 | // {D79DBB70-5F21-4d36-BBC2-FF525C213CDC} 312 | DEFINE_GUID(IID_ID3DXFont, 313 | 0xd79dbb70, 0x5f21, 0x4d36, 0xbb, 0xc2, 0xff, 0x52, 0x5c, 0x21, 0x3c, 0xdc); 314 | 315 | 316 | #undef INTERFACE 317 | #define INTERFACE ID3DXFont 318 | 319 | DECLARE_INTERFACE_(ID3DXFont, IUnknown) 320 | { 321 | // IUnknown 322 | STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; 323 | STDMETHOD_(ULONG, AddRef)(THIS) PURE; 324 | STDMETHOD_(ULONG, Release)(THIS) PURE; 325 | 326 | // ID3DXFont 327 | STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9 *ppDevice) PURE; 328 | STDMETHOD(GetDescA)(THIS_ D3DXFONT_DESCA *pDesc) PURE; 329 | STDMETHOD(GetDescW)(THIS_ D3DXFONT_DESCW *pDesc) PURE; 330 | STDMETHOD_(BOOL, GetTextMetricsA)(THIS_ TEXTMETRICA *pTextMetrics) PURE; 331 | STDMETHOD_(BOOL, GetTextMetricsW)(THIS_ TEXTMETRICW *pTextMetrics) PURE; 332 | 333 | STDMETHOD_(HDC, GetDC)(THIS) PURE; 334 | STDMETHOD(GetGlyphData)(THIS_ UINT Glyph, LPDIRECT3DTEXTURE9 *ppTexture, RECT *pBlackBox, POINT *pCellInc) PURE; 335 | 336 | STDMETHOD(PreloadCharacters)(THIS_ UINT First, UINT Last) PURE; 337 | STDMETHOD(PreloadGlyphs)(THIS_ UINT First, UINT Last) PURE; 338 | STDMETHOD(PreloadTextA)(THIS_ LPCSTR pString, INT Count) PURE; 339 | STDMETHOD(PreloadTextW)(THIS_ LPCWSTR pString, INT Count) PURE; 340 | 341 | STDMETHOD_(INT, DrawTextA)(THIS_ LPD3DXSPRITE pSprite, LPCSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE; 342 | STDMETHOD_(INT, DrawTextW)(THIS_ LPD3DXSPRITE pSprite, LPCWSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE; 343 | 344 | STDMETHOD(OnLostDevice)(THIS) PURE; 345 | STDMETHOD(OnResetDevice)(THIS) PURE; 346 | 347 | #ifdef __cplusplus 348 | #ifdef UNICODE 349 | HRESULT GetDesc(D3DXFONT_DESCW *pDesc) { return GetDescW(pDesc); } 350 | HRESULT PreloadText(LPCWSTR pString, INT Count) { return PreloadTextW(pString, Count); } 351 | #else 352 | HRESULT GetDesc(D3DXFONT_DESCA *pDesc) { return GetDescA(pDesc); } 353 | HRESULT PreloadText(LPCSTR pString, INT Count) { return PreloadTextA(pString, Count); } 354 | #endif 355 | #endif //__cplusplus 356 | }; 357 | 358 | #ifndef GetTextMetrics 359 | #ifdef UNICODE 360 | #define GetTextMetrics GetTextMetricsW 361 | #else 362 | #define GetTextMetrics GetTextMetricsA 363 | #endif 364 | #endif 365 | 366 | #ifndef DrawText 367 | #ifdef UNICODE 368 | #define DrawText DrawTextW 369 | #else 370 | #define DrawText DrawTextA 371 | #endif 372 | #endif 373 | 374 | 375 | #ifdef __cplusplus 376 | extern "C" { 377 | #endif //__cplusplus 378 | 379 | 380 | HRESULT WINAPI 381 | D3DXCreateFontA( 382 | LPDIRECT3DDEVICE9 pDevice, 383 | INT Height, 384 | UINT Width, 385 | UINT Weight, 386 | UINT MipLevels, 387 | BOOL Italic, 388 | DWORD CharSet, 389 | DWORD OutputPrecision, 390 | DWORD Quality, 391 | DWORD PitchAndFamily, 392 | LPCSTR pFaceName, 393 | LPD3DXFONT* ppFont); 394 | 395 | HRESULT WINAPI 396 | D3DXCreateFontW( 397 | LPDIRECT3DDEVICE9 pDevice, 398 | INT Height, 399 | UINT Width, 400 | UINT Weight, 401 | UINT MipLevels, 402 | BOOL Italic, 403 | DWORD CharSet, 404 | DWORD OutputPrecision, 405 | DWORD Quality, 406 | DWORD PitchAndFamily, 407 | LPCWSTR pFaceName, 408 | LPD3DXFONT* ppFont); 409 | 410 | #ifdef UNICODE 411 | #define D3DXCreateFont D3DXCreateFontW 412 | #else 413 | #define D3DXCreateFont D3DXCreateFontA 414 | #endif 415 | 416 | 417 | HRESULT WINAPI 418 | D3DXCreateFontIndirectA( 419 | LPDIRECT3DDEVICE9 pDevice, 420 | CONST D3DXFONT_DESCA* pDesc, 421 | LPD3DXFONT* ppFont); 422 | 423 | HRESULT WINAPI 424 | D3DXCreateFontIndirectW( 425 | LPDIRECT3DDEVICE9 pDevice, 426 | CONST D3DXFONT_DESCW* pDesc, 427 | LPD3DXFONT* ppFont); 428 | 429 | #ifdef UNICODE 430 | #define D3DXCreateFontIndirect D3DXCreateFontIndirectW 431 | #else 432 | #define D3DXCreateFontIndirect D3DXCreateFontIndirectA 433 | #endif 434 | 435 | 436 | #ifdef __cplusplus 437 | } 438 | #endif //__cplusplus 439 | 440 | 441 | 442 | /////////////////////////////////////////////////////////////////////////// 443 | // ID3DXRenderToSurface: 444 | // --------------------- 445 | // This object abstracts rendering to surfaces. These surfaces do not 446 | // necessarily need to be render targets. If they are not, a compatible 447 | // render target is used, and the result copied into surface at end scene. 448 | // 449 | // BeginScene, EndScene - 450 | // Call BeginScene() and EndScene() at the beginning and ending of your 451 | // scene. These calls will setup and restore render targets, viewports, 452 | // etc.. 453 | // 454 | // OnLostDevice, OnResetDevice - 455 | // Call OnLostDevice() on this object before calling Reset() on the 456 | // device, so that this object can release any stateblocks and video 457 | // memory resources. After Reset(), the call OnResetDevice(). 458 | /////////////////////////////////////////////////////////////////////////// 459 | 460 | typedef struct _D3DXRTS_DESC 461 | { 462 | UINT Width; 463 | UINT Height; 464 | D3DFORMAT Format; 465 | BOOL DepthStencil; 466 | D3DFORMAT DepthStencilFormat; 467 | 468 | } D3DXRTS_DESC, *LPD3DXRTS_DESC; 469 | 470 | 471 | typedef interface ID3DXRenderToSurface ID3DXRenderToSurface; 472 | typedef interface ID3DXRenderToSurface *LPD3DXRENDERTOSURFACE; 473 | 474 | 475 | // {6985F346-2C3D-43b3-BE8B-DAAE8A03D894} 476 | DEFINE_GUID(IID_ID3DXRenderToSurface, 477 | 0x6985f346, 0x2c3d, 0x43b3, 0xbe, 0x8b, 0xda, 0xae, 0x8a, 0x3, 0xd8, 0x94); 478 | 479 | 480 | #undef INTERFACE 481 | #define INTERFACE ID3DXRenderToSurface 482 | 483 | DECLARE_INTERFACE_(ID3DXRenderToSurface, IUnknown) 484 | { 485 | // IUnknown 486 | STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; 487 | STDMETHOD_(ULONG, AddRef)(THIS) PURE; 488 | STDMETHOD_(ULONG, Release)(THIS) PURE; 489 | 490 | // ID3DXRenderToSurface 491 | STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; 492 | STDMETHOD(GetDesc)(THIS_ D3DXRTS_DESC* pDesc) PURE; 493 | 494 | STDMETHOD(BeginScene)(THIS_ LPDIRECT3DSURFACE9 pSurface, CONST D3DVIEWPORT9* pViewport) PURE; 495 | STDMETHOD(EndScene)(THIS_ DWORD MipFilter) PURE; 496 | 497 | STDMETHOD(OnLostDevice)(THIS) PURE; 498 | STDMETHOD(OnResetDevice)(THIS) PURE; 499 | }; 500 | 501 | 502 | #ifdef __cplusplus 503 | extern "C" { 504 | #endif //__cplusplus 505 | 506 | HRESULT WINAPI 507 | D3DXCreateRenderToSurface( 508 | LPDIRECT3DDEVICE9 pDevice, 509 | UINT Width, 510 | UINT Height, 511 | D3DFORMAT Format, 512 | BOOL DepthStencil, 513 | D3DFORMAT DepthStencilFormat, 514 | LPD3DXRENDERTOSURFACE* ppRenderToSurface); 515 | 516 | #ifdef __cplusplus 517 | } 518 | #endif //__cplusplus 519 | 520 | 521 | 522 | /////////////////////////////////////////////////////////////////////////// 523 | // ID3DXRenderToEnvMap: 524 | // -------------------- 525 | // This object abstracts rendering to environment maps. These surfaces 526 | // do not necessarily need to be render targets. If they are not, a 527 | // compatible render target is used, and the result copied into the 528 | // environment map at end scene. 529 | // 530 | // BeginCube, BeginSphere, BeginHemisphere, BeginParabolic - 531 | // This function initiates the rendering of the environment map. As 532 | // parameters, you pass the textures in which will get filled in with 533 | // the resulting environment map. 534 | // 535 | // Face - 536 | // Call this function to initiate the drawing of each face. For each 537 | // environment map, you will call this six times.. once for each face 538 | // in D3DCUBEMAP_FACES. 539 | // 540 | // End - 541 | // This will restore all render targets, and if needed compose all the 542 | // rendered faces into the environment map surfaces. 543 | // 544 | // OnLostDevice, OnResetDevice - 545 | // Call OnLostDevice() on this object before calling Reset() on the 546 | // device, so that this object can release any stateblocks and video 547 | // memory resources. After Reset(), the call OnResetDevice(). 548 | /////////////////////////////////////////////////////////////////////////// 549 | 550 | typedef struct _D3DXRTE_DESC 551 | { 552 | UINT Size; 553 | UINT MipLevels; 554 | D3DFORMAT Format; 555 | BOOL DepthStencil; 556 | D3DFORMAT DepthStencilFormat; 557 | 558 | } D3DXRTE_DESC, *LPD3DXRTE_DESC; 559 | 560 | 561 | typedef interface ID3DXRenderToEnvMap ID3DXRenderToEnvMap; 562 | typedef interface ID3DXRenderToEnvMap *LPD3DXRenderToEnvMap; 563 | 564 | 565 | // {313F1B4B-C7B0-4fa2-9D9D-8D380B64385E} 566 | DEFINE_GUID(IID_ID3DXRenderToEnvMap, 567 | 0x313f1b4b, 0xc7b0, 0x4fa2, 0x9d, 0x9d, 0x8d, 0x38, 0xb, 0x64, 0x38, 0x5e); 568 | 569 | 570 | #undef INTERFACE 571 | #define INTERFACE ID3DXRenderToEnvMap 572 | 573 | DECLARE_INTERFACE_(ID3DXRenderToEnvMap, IUnknown) 574 | { 575 | // IUnknown 576 | STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; 577 | STDMETHOD_(ULONG, AddRef)(THIS) PURE; 578 | STDMETHOD_(ULONG, Release)(THIS) PURE; 579 | 580 | // ID3DXRenderToEnvMap 581 | STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; 582 | STDMETHOD(GetDesc)(THIS_ D3DXRTE_DESC* pDesc) PURE; 583 | 584 | STDMETHOD(BeginCube)(THIS_ 585 | LPDIRECT3DCUBETEXTURE9 pCubeTex) PURE; 586 | 587 | STDMETHOD(BeginSphere)(THIS_ 588 | LPDIRECT3DTEXTURE9 pTex) PURE; 589 | 590 | STDMETHOD(BeginHemisphere)(THIS_ 591 | LPDIRECT3DTEXTURE9 pTexZPos, 592 | LPDIRECT3DTEXTURE9 pTexZNeg) PURE; 593 | 594 | STDMETHOD(BeginParabolic)(THIS_ 595 | LPDIRECT3DTEXTURE9 pTexZPos, 596 | LPDIRECT3DTEXTURE9 pTexZNeg) PURE; 597 | 598 | STDMETHOD(Face)(THIS_ D3DCUBEMAP_FACES Face, DWORD MipFilter) PURE; 599 | STDMETHOD(End)(THIS_ DWORD MipFilter) PURE; 600 | 601 | STDMETHOD(OnLostDevice)(THIS) PURE; 602 | STDMETHOD(OnResetDevice)(THIS) PURE; 603 | }; 604 | 605 | 606 | #ifdef __cplusplus 607 | extern "C" { 608 | #endif //__cplusplus 609 | 610 | HRESULT WINAPI 611 | D3DXCreateRenderToEnvMap( 612 | LPDIRECT3DDEVICE9 pDevice, 613 | UINT Size, 614 | UINT MipLevels, 615 | D3DFORMAT Format, 616 | BOOL DepthStencil, 617 | D3DFORMAT DepthStencilFormat, 618 | LPD3DXRenderToEnvMap* ppRenderToEnvMap); 619 | 620 | #ifdef __cplusplus 621 | } 622 | #endif //__cplusplus 623 | 624 | 625 | 626 | /////////////////////////////////////////////////////////////////////////// 627 | // ID3DXLine: 628 | // ------------ 629 | // This object intends to provide an easy way to draw lines using D3D. 630 | // 631 | // Begin - 632 | // Prepares device for drawing lines 633 | // 634 | // Draw - 635 | // Draws a line strip in screen-space. 636 | // Input is in the form of a array defining points on the line strip. of D3DXVECTOR2 637 | // 638 | // DrawTransform - 639 | // Draws a line in screen-space with a specified input transformation matrix. 640 | // 641 | // End - 642 | // Restores device state to how it was when Begin was called. 643 | // 644 | // SetPattern - 645 | // Applies a stipple pattern to the line. Input is one 32-bit 646 | // DWORD which describes the stipple pattern. 1 is opaque, 0 is 647 | // transparent. 648 | // 649 | // SetPatternScale - 650 | // Stretches the stipple pattern in the u direction. Input is one 651 | // floating-point value. 0.0f is no scaling, whereas 1.0f doubles 652 | // the length of the stipple pattern. 653 | // 654 | // SetWidth - 655 | // Specifies the thickness of the line in the v direction. Input is 656 | // one floating-point value. 657 | // 658 | // SetAntialias - 659 | // Toggles line antialiasing. Input is a BOOL. 660 | // TRUE = Antialiasing on. 661 | // FALSE = Antialiasing off. 662 | // 663 | // SetGLLines - 664 | // Toggles non-antialiased OpenGL line emulation. Input is a BOOL. 665 | // TRUE = OpenGL line emulation on. 666 | // FALSE = OpenGL line emulation off. 667 | // 668 | // OpenGL line: Regular line: 669 | // *\ *\ 670 | // | \ / \ 671 | // | \ *\ \ 672 | // *\ \ \ \ 673 | // \ \ \ \ 674 | // \ * \ * 675 | // \ | \ / 676 | // \| * 677 | // * 678 | // 679 | // OnLostDevice, OnResetDevice - 680 | // Call OnLostDevice() on this object before calling Reset() on the 681 | // device, so that this object can release any stateblocks and video 682 | // memory resources. After Reset(), the call OnResetDevice(). 683 | /////////////////////////////////////////////////////////////////////////// 684 | 685 | 686 | typedef interface ID3DXLine ID3DXLine; 687 | typedef interface ID3DXLine *LPD3DXLINE; 688 | 689 | 690 | // {D379BA7F-9042-4ac4-9F5E-58192A4C6BD8} 691 | DEFINE_GUID(IID_ID3DXLine, 692 | 0xd379ba7f, 0x9042, 0x4ac4, 0x9f, 0x5e, 0x58, 0x19, 0x2a, 0x4c, 0x6b, 0xd8); 693 | 694 | #undef INTERFACE 695 | #define INTERFACE ID3DXLine 696 | 697 | DECLARE_INTERFACE_(ID3DXLine, IUnknown) 698 | { 699 | // IUnknown 700 | STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; 701 | STDMETHOD_(ULONG, AddRef)(THIS) PURE; 702 | STDMETHOD_(ULONG, Release)(THIS) PURE; 703 | 704 | // ID3DXLine 705 | STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; 706 | 707 | STDMETHOD(Begin)(THIS) PURE; 708 | 709 | STDMETHOD(Draw)(THIS_ CONST D3DXVECTOR2 *pVertexList, 710 | DWORD dwVertexListCount, D3DCOLOR Color) PURE; 711 | 712 | STDMETHOD(DrawTransform)(THIS_ CONST D3DXVECTOR3 *pVertexList, 713 | DWORD dwVertexListCount, CONST D3DXMATRIX* pTransform, 714 | D3DCOLOR Color) PURE; 715 | 716 | STDMETHOD(SetPattern)(THIS_ DWORD dwPattern) PURE; 717 | STDMETHOD_(DWORD, GetPattern)(THIS) PURE; 718 | 719 | STDMETHOD(SetPatternScale)(THIS_ FLOAT fPatternScale) PURE; 720 | STDMETHOD_(FLOAT, GetPatternScale)(THIS) PURE; 721 | 722 | STDMETHOD(SetWidth)(THIS_ FLOAT fWidth) PURE; 723 | STDMETHOD_(FLOAT, GetWidth)(THIS) PURE; 724 | 725 | STDMETHOD(SetAntialias)(THIS_ BOOL bAntialias) PURE; 726 | STDMETHOD_(BOOL, GetAntialias)(THIS) PURE; 727 | 728 | STDMETHOD(SetGLLines)(THIS_ BOOL bGLLines) PURE; 729 | STDMETHOD_(BOOL, GetGLLines)(THIS) PURE; 730 | 731 | STDMETHOD(End)(THIS) PURE; 732 | 733 | STDMETHOD(OnLostDevice)(THIS) PURE; 734 | STDMETHOD(OnResetDevice)(THIS) PURE; 735 | }; 736 | 737 | 738 | #ifdef __cplusplus 739 | extern "C" { 740 | #endif //__cplusplus 741 | 742 | 743 | HRESULT WINAPI 744 | D3DXCreateLine( 745 | LPDIRECT3DDEVICE9 pDevice, 746 | LPD3DXLINE* ppLine); 747 | 748 | #ifdef __cplusplus 749 | } 750 | #endif //__cplusplus 751 | 752 | #endif //__D3DX9CORE_H__ 753 | -------------------------------------------------------------------------------- /Direct3d/d3dx9shape.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) Microsoft Corporation. All Rights Reserved. 4 | // 5 | // File: d3dx9shapes.h 6 | // Content: D3DX simple shapes 7 | // 8 | /////////////////////////////////////////////////////////////////////////// 9 | 10 | #include "d3dx9.h" 11 | 12 | #ifndef __D3DX9SHAPES_H__ 13 | #define __D3DX9SHAPES_H__ 14 | 15 | /////////////////////////////////////////////////////////////////////////// 16 | // Functions: 17 | /////////////////////////////////////////////////////////////////////////// 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif //__cplusplus 22 | 23 | 24 | //------------------------------------------------------------------------- 25 | // D3DXCreatePolygon: 26 | // ------------------ 27 | // Creates a mesh containing an n-sided polygon. The polygon is centered 28 | // at the origin. 29 | // 30 | // Parameters: 31 | // 32 | // pDevice The D3D device with which the mesh is going to be used. 33 | // Length Length of each side. 34 | // Sides Number of sides the polygon has. (Must be >= 3) 35 | // ppMesh The mesh object which will be created 36 | // ppAdjacency Returns a buffer containing adjacency info. Can be NULL. 37 | //------------------------------------------------------------------------- 38 | HRESULT WINAPI 39 | D3DXCreatePolygon( 40 | LPDIRECT3DDEVICE9 pDevice, 41 | FLOAT Length, 42 | UINT Sides, 43 | LPD3DXMESH* ppMesh, 44 | LPD3DXBUFFER* ppAdjacency); 45 | 46 | 47 | //------------------------------------------------------------------------- 48 | // D3DXCreateBox: 49 | // -------------- 50 | // Creates a mesh containing an axis-aligned box. The box is centered at 51 | // the origin. 52 | // 53 | // Parameters: 54 | // 55 | // pDevice The D3D device with which the mesh is going to be used. 56 | // Width Width of box (along X-axis) 57 | // Height Height of box (along Y-axis) 58 | // Depth Depth of box (along Z-axis) 59 | // ppMesh The mesh object which will be created 60 | // ppAdjacency Returns a buffer containing adjacency info. Can be NULL. 61 | //------------------------------------------------------------------------- 62 | HRESULT WINAPI 63 | D3DXCreateBox( 64 | LPDIRECT3DDEVICE9 pDevice, 65 | FLOAT Width, 66 | FLOAT Height, 67 | FLOAT Depth, 68 | LPD3DXMESH* ppMesh, 69 | LPD3DXBUFFER* ppAdjacency); 70 | 71 | 72 | //------------------------------------------------------------------------- 73 | // D3DXCreateCylinder: 74 | // ------------------- 75 | // Creates a mesh containing a cylinder. The generated cylinder is 76 | // centered at the origin, and its axis is aligned with the Z-axis. 77 | // 78 | // Parameters: 79 | // 80 | // pDevice The D3D device with which the mesh is going to be used. 81 | // Radius1 Radius at -Z end (should be >= 0.0f) 82 | // Radius2 Radius at +Z end (should be >= 0.0f) 83 | // Length Length of cylinder (along Z-axis) 84 | // Slices Number of slices about the main axis 85 | // Stacks Number of stacks along the main axis 86 | // ppMesh The mesh object which will be created 87 | // ppAdjacency Returns a buffer containing adjacency info. Can be NULL. 88 | //------------------------------------------------------------------------- 89 | HRESULT WINAPI 90 | D3DXCreateCylinder( 91 | LPDIRECT3DDEVICE9 pDevice, 92 | FLOAT Radius1, 93 | FLOAT Radius2, 94 | FLOAT Length, 95 | UINT Slices, 96 | UINT Stacks, 97 | LPD3DXMESH* ppMesh, 98 | LPD3DXBUFFER* ppAdjacency); 99 | 100 | 101 | //------------------------------------------------------------------------- 102 | // D3DXCreateSphere: 103 | // ----------------- 104 | // Creates a mesh containing a sphere. The sphere is centered at the 105 | // origin. 106 | // 107 | // Parameters: 108 | // 109 | // pDevice The D3D device with which the mesh is going to be used. 110 | // Radius Radius of the sphere (should be >= 0.0f) 111 | // Slices Number of slices about the main axis 112 | // Stacks Number of stacks along the main axis 113 | // ppMesh The mesh object which will be created 114 | // ppAdjacency Returns a buffer containing adjacency info. Can be NULL. 115 | //------------------------------------------------------------------------- 116 | HRESULT WINAPI 117 | D3DXCreateSphere( 118 | LPDIRECT3DDEVICE9 pDevice, 119 | FLOAT Radius, 120 | UINT Slices, 121 | UINT Stacks, 122 | LPD3DXMESH* ppMesh, 123 | LPD3DXBUFFER* ppAdjacency); 124 | 125 | 126 | //------------------------------------------------------------------------- 127 | // D3DXCreateTorus: 128 | // ---------------- 129 | // Creates a mesh containing a torus. The generated torus is centered at 130 | // the origin, and its axis is aligned with the Z-axis. 131 | // 132 | // Parameters: 133 | // 134 | // pDevice The D3D device with which the mesh is going to be used. 135 | // InnerRadius Inner radius of the torus (should be >= 0.0f) 136 | // OuterRadius Outer radius of the torue (should be >= 0.0f) 137 | // Sides Number of sides in a cross-section (must be >= 3) 138 | // Rings Number of rings making up the torus (must be >= 3) 139 | // ppMesh The mesh object which will be created 140 | // ppAdjacency Returns a buffer containing adjacency info. Can be NULL. 141 | //------------------------------------------------------------------------- 142 | HRESULT WINAPI 143 | D3DXCreateTorus( 144 | LPDIRECT3DDEVICE9 pDevice, 145 | FLOAT InnerRadius, 146 | FLOAT OuterRadius, 147 | UINT Sides, 148 | UINT Rings, 149 | LPD3DXMESH* ppMesh, 150 | LPD3DXBUFFER* ppAdjacency); 151 | 152 | 153 | //------------------------------------------------------------------------- 154 | // D3DXCreateTeapot: 155 | // ----------------- 156 | // Creates a mesh containing a teapot. 157 | // 158 | // Parameters: 159 | // 160 | // pDevice The D3D device with which the mesh is going to be used. 161 | // ppMesh The mesh object which will be created 162 | // ppAdjacency Returns a buffer containing adjacency info. Can be NULL. 163 | //------------------------------------------------------------------------- 164 | HRESULT WINAPI 165 | D3DXCreateTeapot( 166 | LPDIRECT3DDEVICE9 pDevice, 167 | LPD3DXMESH* ppMesh, 168 | LPD3DXBUFFER* ppAdjacency); 169 | 170 | 171 | //------------------------------------------------------------------------- 172 | // D3DXCreateText: 173 | // --------------- 174 | // Creates a mesh containing the specified text using the font associated 175 | // with the device context. 176 | // 177 | // Parameters: 178 | // 179 | // pDevice The D3D device with which the mesh is going to be used. 180 | // hDC Device context, with desired font selected 181 | // pText Text to generate 182 | // Deviation Maximum chordal deviation from true font outlines 183 | // Extrusion Amount to extrude text in -Z direction 184 | // ppMesh The mesh object which will be created 185 | // pGlyphMetrics Address of buffer to receive glyph metric data (or NULL) 186 | //------------------------------------------------------------------------- 187 | HRESULT WINAPI 188 | D3DXCreateTextA( 189 | LPDIRECT3DDEVICE9 pDevice, 190 | HDC hDC, 191 | LPCSTR pText, 192 | FLOAT Deviation, 193 | FLOAT Extrusion, 194 | LPD3DXMESH* ppMesh, 195 | LPD3DXBUFFER* ppAdjacency, 196 | LPGLYPHMETRICSFLOAT pGlyphMetrics); 197 | 198 | HRESULT WINAPI 199 | D3DXCreateTextW( 200 | LPDIRECT3DDEVICE9 pDevice, 201 | HDC hDC, 202 | LPCWSTR pText, 203 | FLOAT Deviation, 204 | FLOAT Extrusion, 205 | LPD3DXMESH* ppMesh, 206 | LPD3DXBUFFER* ppAdjacency, 207 | LPGLYPHMETRICSFLOAT pGlyphMetrics); 208 | 209 | #ifdef UNICODE 210 | #define D3DXCreateText D3DXCreateTextW 211 | #else 212 | #define D3DXCreateText D3DXCreateTextA 213 | #endif 214 | 215 | 216 | #ifdef __cplusplus 217 | } 218 | #endif //__cplusplus 219 | 220 | #endif //__D3DX9SHAPES_H__ 221 | -------------------------------------------------------------------------------- /Direct3d/d3dx9xof.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) Microsoft Corporation. All Rights Reserved. 4 | // 5 | // File: d3dx9xof.h 6 | // Content: D3DX .X File types and functions 7 | // 8 | /////////////////////////////////////////////////////////////////////////// 9 | 10 | #include "d3dx9.h" 11 | 12 | #if !defined( __D3DX9XOF_H__ ) 13 | #define __D3DX9XOF_H__ 14 | 15 | #if defined( __cplusplus ) 16 | extern "C" { 17 | #endif // defined( __cplusplus ) 18 | 19 | //---------------------------------------------------------------------------- 20 | // D3DXF_FILEFORMAT 21 | // This flag is used to specify what file type to use when saving to disk. 22 | // _BINARY, and _TEXT are mutually exclusive, while 23 | // _COMPRESSED is an optional setting that works with all file types. 24 | //---------------------------------------------------------------------------- 25 | typedef DWORD D3DXF_FILEFORMAT; 26 | 27 | #define D3DXF_FILEFORMAT_BINARY 0 28 | #define D3DXF_FILEFORMAT_TEXT 1 29 | #define D3DXF_FILEFORMAT_COMPRESSED 2 30 | 31 | //---------------------------------------------------------------------------- 32 | // D3DXF_FILESAVEOPTIONS 33 | // This flag is used to specify where to save the file to. Each flag is 34 | // mutually exclusive, indicates the data location of the file, and also 35 | // chooses which additional data will specify the location. 36 | // _TOFILE is paired with a filename (LPCSTR) 37 | // _TOWFILE is paired with a filename (LPWSTR) 38 | //---------------------------------------------------------------------------- 39 | typedef DWORD D3DXF_FILESAVEOPTIONS; 40 | 41 | #define D3DXF_FILESAVE_TOFILE 0x00L 42 | #define D3DXF_FILESAVE_TOWFILE 0x01L 43 | 44 | //---------------------------------------------------------------------------- 45 | // D3DXF_FILELOADOPTIONS 46 | // This flag is used to specify where to load the file from. Each flag is 47 | // mutually exclusive, indicates the data location of the file, and also 48 | // chooses which additional data will specify the location. 49 | // _FROMFILE is paired with a filename (LPCSTR) 50 | // _FROMWFILE is paired with a filename (LPWSTR) 51 | // _FROMRESOURCE is paired with a (D3DXF_FILELOADRESOUCE*) description. 52 | // _FROMMEMORY is paired with a (D3DXF_FILELOADMEMORY*) description. 53 | //---------------------------------------------------------------------------- 54 | typedef DWORD D3DXF_FILELOADOPTIONS; 55 | 56 | #define D3DXF_FILELOAD_FROMFILE 0x00L 57 | #define D3DXF_FILELOAD_FROMWFILE 0x01L 58 | #define D3DXF_FILELOAD_FROMRESOURCE 0x02L 59 | #define D3DXF_FILELOAD_FROMMEMORY 0x03L 60 | 61 | //---------------------------------------------------------------------------- 62 | // D3DXF_FILELOADRESOURCE: 63 | //---------------------------------------------------------------------------- 64 | 65 | typedef struct _D3DXF_FILELOADRESOURCE 66 | { 67 | HMODULE hModule; // Desc 68 | LPCSTR lpName; // Desc 69 | LPCSTR lpType; // Desc 70 | } D3DXF_FILELOADRESOURCE; 71 | 72 | //---------------------------------------------------------------------------- 73 | // D3DXF_FILELOADMEMORY: 74 | //---------------------------------------------------------------------------- 75 | 76 | typedef struct _D3DXF_FILELOADMEMORY 77 | { 78 | LPCVOID lpMemory; // Desc 79 | SIZE_T dSize; // Desc 80 | } D3DXF_FILELOADMEMORY; 81 | 82 | #if defined( _WIN32 ) && !defined( _NO_COM ) 83 | 84 | // {cef08cf9-7b4f-4429-9624-2a690a933201} 85 | DEFINE_GUID( IID_ID3DXFile, 86 | 0xcef08cf9, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); 87 | 88 | // {cef08cfa-7b4f-4429-9624-2a690a933201} 89 | DEFINE_GUID( IID_ID3DXFileSaveObject, 90 | 0xcef08cfa, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); 91 | 92 | // {cef08cfb-7b4f-4429-9624-2a690a933201} 93 | DEFINE_GUID( IID_ID3DXFileSaveData, 94 | 0xcef08cfb, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); 95 | 96 | // {cef08cfc-7b4f-4429-9624-2a690a933201} 97 | DEFINE_GUID( IID_ID3DXFileEnumObject, 98 | 0xcef08cfc, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); 99 | 100 | // {cef08cfd-7b4f-4429-9624-2a690a933201} 101 | DEFINE_GUID( IID_ID3DXFileData, 102 | 0xcef08cfd, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); 103 | 104 | #endif // defined( _WIN32 ) && !defined( _NO_COM ) 105 | 106 | #if defined( __cplusplus ) 107 | #if !defined( DECLSPEC_UUID ) 108 | #if _MSC_VER >= 1100 109 | #define DECLSPEC_UUID( x ) __declspec( uuid( x ) ) 110 | #else // !( _MSC_VER >= 1100 ) 111 | #define DECLSPEC_UUID( x ) 112 | #endif // !( _MSC_VER >= 1100 ) 113 | #endif // !defined( DECLSPEC_UUID ) 114 | 115 | interface DECLSPEC_UUID( "cef08cf9-7b4f-4429-9624-2a690a933201" ) 116 | ID3DXFile; 117 | interface DECLSPEC_UUID( "cef08cfa-7b4f-4429-9624-2a690a933201" ) 118 | ID3DXFileSaveObject; 119 | interface DECLSPEC_UUID( "cef08cfb-7b4f-4429-9624-2a690a933201" ) 120 | ID3DXFileSaveData; 121 | interface DECLSPEC_UUID( "cef08cfc-7b4f-4429-9624-2a690a933201" ) 122 | ID3DXFileEnumObject; 123 | interface DECLSPEC_UUID( "cef08cfd-7b4f-4429-9624-2a690a933201" ) 124 | ID3DXFileData; 125 | 126 | #if defined( _COM_SMARTPTR_TYPEDEF ) 127 | _COM_SMARTPTR_TYPEDEF( ID3DXFile, 128 | __uuidof( ID3DXFile ) ); 129 | _COM_SMARTPTR_TYPEDEF( ID3DXFileSaveObject, 130 | __uuidof( ID3DXFileSaveObject ) ); 131 | _COM_SMARTPTR_TYPEDEF( ID3DXFileSaveData, 132 | __uuidof( ID3DXFileSaveData ) ); 133 | _COM_SMARTPTR_TYPEDEF( ID3DXFileEnumObject, 134 | __uuidof( ID3DXFileEnumObject ) ); 135 | _COM_SMARTPTR_TYPEDEF( ID3DXFileData, 136 | __uuidof( ID3DXFileData ) ); 137 | #endif // defined( _COM_SMARTPTR_TYPEDEF ) 138 | #endif // defined( __cplusplus ) 139 | 140 | typedef interface ID3DXFile ID3DXFile; 141 | typedef interface ID3DXFileSaveObject ID3DXFileSaveObject; 142 | typedef interface ID3DXFileSaveData ID3DXFileSaveData; 143 | typedef interface ID3DXFileEnumObject ID3DXFileEnumObject; 144 | typedef interface ID3DXFileData ID3DXFileData; 145 | 146 | ////////////////////////////////////////////////////////////////////////////// 147 | // ID3DXFile ///////////////////////////////////////////////////////////////// 148 | ////////////////////////////////////////////////////////////////////////////// 149 | 150 | #undef INTERFACE 151 | #define INTERFACE ID3DXFile 152 | 153 | DECLARE_INTERFACE_( ID3DXFile, IUnknown ) 154 | { 155 | STDMETHOD( QueryInterface )( THIS_ REFIID, LPVOID* ) PURE; 156 | STDMETHOD_( ULONG, AddRef )( THIS ) PURE; 157 | STDMETHOD_( ULONG, Release )( THIS ) PURE; 158 | 159 | STDMETHOD( CreateEnumObject )( THIS_ LPCVOID, D3DXF_FILELOADOPTIONS, 160 | ID3DXFileEnumObject** ) PURE; 161 | STDMETHOD( CreateSaveObject )( THIS_ LPCVOID, D3DXF_FILESAVEOPTIONS, 162 | D3DXF_FILEFORMAT, ID3DXFileSaveObject** ) PURE; 163 | STDMETHOD( RegisterTemplates )( THIS_ LPCVOID, SIZE_T ) PURE; 164 | STDMETHOD( RegisterEnumTemplates )( THIS_ ID3DXFileEnumObject* ) PURE; 165 | }; 166 | 167 | ////////////////////////////////////////////////////////////////////////////// 168 | // ID3DXFileSaveObject /////////////////////////////////////////////////////// 169 | ////////////////////////////////////////////////////////////////////////////// 170 | 171 | #undef INTERFACE 172 | #define INTERFACE ID3DXFileSaveObject 173 | 174 | DECLARE_INTERFACE_( ID3DXFileSaveObject, IUnknown ) 175 | { 176 | STDMETHOD( QueryInterface )( THIS_ REFIID, LPVOID* ) PURE; 177 | STDMETHOD_( ULONG, AddRef )( THIS ) PURE; 178 | STDMETHOD_( ULONG, Release )( THIS ) PURE; 179 | 180 | STDMETHOD( GetFile )( THIS_ ID3DXFile** ) PURE; 181 | STDMETHOD( AddDataObject )( THIS_ REFGUID, LPCSTR, CONST GUID*, 182 | SIZE_T, LPCVOID, ID3DXFileSaveData** ) PURE; 183 | STDMETHOD( Save )( THIS ) PURE; 184 | }; 185 | 186 | ////////////////////////////////////////////////////////////////////////////// 187 | // ID3DXFileSaveData ///////////////////////////////////////////////////////// 188 | ////////////////////////////////////////////////////////////////////////////// 189 | 190 | #undef INTERFACE 191 | #define INTERFACE ID3DXFileSaveData 192 | 193 | DECLARE_INTERFACE_( ID3DXFileSaveData, IUnknown ) 194 | { 195 | STDMETHOD( QueryInterface )( THIS_ REFIID, LPVOID* ) PURE; 196 | STDMETHOD_( ULONG, AddRef )( THIS ) PURE; 197 | STDMETHOD_( ULONG, Release )( THIS ) PURE; 198 | 199 | STDMETHOD( GetSave )( THIS_ ID3DXFileSaveObject** ) PURE; 200 | STDMETHOD( GetName )( THIS_ LPSTR, SIZE_T* ) PURE; 201 | STDMETHOD( GetId )( THIS_ LPGUID ) PURE; 202 | STDMETHOD( GetType )( THIS_ GUID* ) PURE; 203 | STDMETHOD( AddDataObject )( THIS_ REFGUID, LPCSTR, CONST GUID*, 204 | SIZE_T, LPCVOID, ID3DXFileSaveData** ) PURE; 205 | STDMETHOD( AddDataReference )( THIS_ LPCSTR, CONST GUID* ) PURE; 206 | }; 207 | 208 | ////////////////////////////////////////////////////////////////////////////// 209 | // ID3DXFileEnumObject /////////////////////////////////////////////////////// 210 | ////////////////////////////////////////////////////////////////////////////// 211 | 212 | #undef INTERFACE 213 | #define INTERFACE ID3DXFileEnumObject 214 | 215 | DECLARE_INTERFACE_( ID3DXFileEnumObject, IUnknown ) 216 | { 217 | STDMETHOD( QueryInterface )( THIS_ REFIID, LPVOID* ) PURE; 218 | STDMETHOD_( ULONG, AddRef )( THIS ) PURE; 219 | STDMETHOD_( ULONG, Release )( THIS ) PURE; 220 | 221 | STDMETHOD( GetFile )( THIS_ ID3DXFile** ) PURE; 222 | STDMETHOD( GetChildren )( THIS_ SIZE_T* ) PURE; 223 | STDMETHOD( GetChild )( THIS_ SIZE_T, ID3DXFileData** ) PURE; 224 | STDMETHOD( GetDataObjectById )( THIS_ REFGUID, ID3DXFileData** ) PURE; 225 | STDMETHOD( GetDataObjectByName )( THIS_ LPCSTR, ID3DXFileData** ) PURE; 226 | }; 227 | 228 | ////////////////////////////////////////////////////////////////////////////// 229 | // ID3DXFileData ///////////////////////////////////////////////////////////// 230 | ////////////////////////////////////////////////////////////////////////////// 231 | 232 | #undef INTERFACE 233 | #define INTERFACE ID3DXFileData 234 | 235 | DECLARE_INTERFACE_( ID3DXFileData, IUnknown ) 236 | { 237 | STDMETHOD( QueryInterface )( THIS_ REFIID, LPVOID* ) PURE; 238 | STDMETHOD_( ULONG, AddRef )( THIS ) PURE; 239 | STDMETHOD_( ULONG, Release )( THIS ) PURE; 240 | 241 | STDMETHOD( GetEnum )( THIS_ ID3DXFileEnumObject** ) PURE; 242 | STDMETHOD( GetName )( THIS_ LPSTR, SIZE_T* ) PURE; 243 | STDMETHOD( GetId )( THIS_ LPGUID ) PURE; 244 | STDMETHOD( Lock )( THIS_ SIZE_T*, LPCVOID* ) PURE; 245 | STDMETHOD( Unlock )( THIS ) PURE; 246 | STDMETHOD( GetType )( THIS_ GUID* ) PURE; 247 | STDMETHOD_( BOOL, IsReference )( THIS ) PURE; 248 | STDMETHOD( GetChildren )( THIS_ SIZE_T* ) PURE; 249 | STDMETHOD( GetChild )( THIS_ SIZE_T, ID3DXFileData** ) PURE; 250 | }; 251 | 252 | STDAPI D3DXFileCreate( ID3DXFile** lplpDirectXFile ); 253 | 254 | /* 255 | * DirectX File errors. 256 | */ 257 | 258 | #define _FACD3DXF 0x876 259 | 260 | #define D3DXFERR_BADOBJECT MAKE_HRESULT( 1, _FACD3DXF, 900 ) 261 | #define D3DXFERR_BADVALUE MAKE_HRESULT( 1, _FACD3DXF, 901 ) 262 | #define D3DXFERR_BADTYPE MAKE_HRESULT( 1, _FACD3DXF, 902 ) 263 | #define D3DXFERR_NOTFOUND MAKE_HRESULT( 1, _FACD3DXF, 903 ) 264 | #define D3DXFERR_NOTDONEYET MAKE_HRESULT( 1, _FACD3DXF, 904 ) 265 | #define D3DXFERR_FILENOTFOUND MAKE_HRESULT( 1, _FACD3DXF, 905 ) 266 | #define D3DXFERR_RESOURCENOTFOUND MAKE_HRESULT( 1, _FACD3DXF, 906 ) 267 | #define D3DXFERR_BADRESOURCE MAKE_HRESULT( 1, _FACD3DXF, 907 ) 268 | #define D3DXFERR_BADFILETYPE MAKE_HRESULT( 1, _FACD3DXF, 908 ) 269 | #define D3DXFERR_BADFILEVERSION MAKE_HRESULT( 1, _FACD3DXF, 909 ) 270 | #define D3DXFERR_BADFILEFLOATSIZE MAKE_HRESULT( 1, _FACD3DXF, 910 ) 271 | #define D3DXFERR_BADFILE MAKE_HRESULT( 1, _FACD3DXF, 911 ) 272 | #define D3DXFERR_PARSEERROR MAKE_HRESULT( 1, _FACD3DXF, 912 ) 273 | #define D3DXFERR_BADARRAYSIZE MAKE_HRESULT( 1, _FACD3DXF, 913 ) 274 | #define D3DXFERR_BADDATAREFERENCE MAKE_HRESULT( 1, _FACD3DXF, 914 ) 275 | #define D3DXFERR_NOMOREOBJECTS MAKE_HRESULT( 1, _FACD3DXF, 915 ) 276 | #define D3DXFERR_NOMOREDATA MAKE_HRESULT( 1, _FACD3DXF, 916 ) 277 | #define D3DXFERR_BADCACHEFILE MAKE_HRESULT( 1, _FACD3DXF, 917 ) 278 | 279 | /* 280 | * DirectX File object types. 281 | */ 282 | 283 | #ifndef WIN_TYPES 284 | #define WIN_TYPES(itype, ptype) typedef interface itype *LP##ptype, **LPLP##ptype 285 | #endif 286 | 287 | WIN_TYPES(ID3DXFile, D3DXFILE); 288 | WIN_TYPES(ID3DXFileEnumObject, D3DXFILEENUMOBJECT); 289 | WIN_TYPES(ID3DXFileSaveObject, D3DXFILESAVEOBJECT); 290 | WIN_TYPES(ID3DXFileData, D3DXFILEDATA); 291 | WIN_TYPES(ID3DXFileSaveData, D3DXFILESAVEDATA); 292 | 293 | #if defined( __cplusplus ) 294 | } // extern "C" 295 | #endif // defined( __cplusplus ) 296 | 297 | #endif // !defined( __D3DX9XOF_H__ ) 298 | 299 | -------------------------------------------------------------------------------- /Imgui/imconfig.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // COMPILE-TIME OPTIONS FOR DEAR IMGUI 3 | // Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure. 4 | // You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions. 5 | //----------------------------------------------------------------------------- 6 | // A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/rebased branch with your modifications to it) 7 | // B) or '#define IMGUI_USER_CONFIG "my_imgui_config.h"' in your project and then add directives in your own file without touching this template. 8 | //----------------------------------------------------------------------------- 9 | // You need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include the imgui*.cpp 10 | // files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures. 11 | // Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts. 12 | // Call IMGUI_CHECKVERSION() from your .cpp files to verify that the data structures your files are using are matching the ones imgui.cpp is using. 13 | //----------------------------------------------------------------------------- 14 | 15 | #pragma once 16 | 17 | //---- Define assertion handler. Defaults to calling assert(). 18 | // If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement. 19 | //#define IM_ASSERT(_EXPR) MyAssert(_EXPR) 20 | //#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts 21 | 22 | //---- Define attributes of all API symbols declarations, e.g. for DLL under Windows 23 | // Using Dear ImGui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility. 24 | // DLL users: heaps and globals are not shared across DLL boundaries! You will need to call SetCurrentContext() + SetAllocatorFunctions() 25 | // for each static/DLL boundary you are calling from. Read "Context and Memory Allocators" section of imgui.cpp for more details. 26 | //#define IMGUI_API __declspec( dllexport ) 27 | //#define IMGUI_API __declspec( dllimport ) 28 | 29 | //---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names. 30 | //#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS 31 | //#define IMGUI_DISABLE_OBSOLETE_KEYIO // 1.87: disable legacy io.KeyMap[]+io.KeysDown[] in favor io.AddKeyEvent(). This will be folded into IMGUI_DISABLE_OBSOLETE_FUNCTIONS in a few versions. 32 | 33 | //---- Disable all of Dear ImGui or don't implement standard windows/tools. 34 | // It is very strongly recommended to NOT disable the demo windows and debug tool during development. They are extremely useful in day to day work. Please read comments in imgui_demo.cpp. 35 | //#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty. 36 | //#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty. 37 | //#define IMGUI_DISABLE_DEBUG_TOOLS // Disable metrics/debugger and other debug tools: ShowMetricsWindow(), ShowDebugLogWindow() and ShowStackToolWindow() will be empty (this was called IMGUI_DISABLE_METRICS_WINDOW before 1.88). 38 | 39 | //---- Don't implement some functions to reduce linkage requirements. 40 | //#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. (user32.lib/.a, kernel32.lib/.a) 41 | //#define IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with Visual Studio] Implement default IME handler (require imm32.lib/.a, auto-link for Visual Studio, -limm32 on command-line for MinGW) 42 | //#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with non-Visual Studio compilers] Don't implement default IME handler (won't require imm32.lib/.a) 43 | //#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime). 44 | //#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default). 45 | //#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf) 46 | //#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself. 47 | //#define IMGUI_DISABLE_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle at all (replace them with dummies) 48 | //#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function. 49 | //#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions(). 50 | //#define IMGUI_DISABLE_SSE // Disable use of SSE intrinsics even if available 51 | 52 | //---- Include imgui_user.h at the end of imgui.h as a convenience 53 | //#define IMGUI_INCLUDE_IMGUI_USER_H 54 | 55 | //---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another) 56 | //#define IMGUI_USE_BGRA_PACKED_COLOR 57 | 58 | //---- Use 32-bit for ImWchar (default is 16-bit) to support unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...) 59 | //#define IMGUI_USE_WCHAR32 60 | 61 | //---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version 62 | // By default the embedded implementations are declared static and not available outside of Dear ImGui sources files. 63 | //#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h" 64 | //#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h" 65 | //#define IMGUI_STB_SPRINTF_FILENAME "my_folder/stb_sprintf.h" // only used if enabled 66 | //#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION 67 | //#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION 68 | 69 | //---- Use stb_sprintf.h for a faster implementation of vsnprintf instead of the one from libc (unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined) 70 | // Compatibility checks of arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by stb_sprintf.h. 71 | //#define IMGUI_USE_STB_SPRINTF 72 | 73 | //---- Use FreeType to build and rasterize the font atlas (instead of stb_truetype which is embedded by default in Dear ImGui) 74 | // Requires FreeType headers to be available in the include path. Requires program to be compiled with 'misc/freetype/imgui_freetype.cpp' (in this repository) + the FreeType library (not provided). 75 | // On Windows you may use vcpkg with 'vcpkg install freetype --triplet=x64-windows' + 'vcpkg integrate install'. 76 | //#define IMGUI_ENABLE_FREETYPE 77 | 78 | //---- Use stb_truetype to build and rasterize the font atlas (default) 79 | // The only purpose of this define is if you want force compilation of the stb_truetype backend ALONG with the FreeType backend. 80 | //#define IMGUI_ENABLE_STB_TRUETYPE 81 | 82 | //---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4. 83 | // This will be inlined as part of ImVec2 and ImVec4 class declarations. 84 | /* 85 | #define IM_VEC2_CLASS_EXTRA \ 86 | constexpr ImVec2(const MyVec2& f) : x(f.x), y(f.y) {} \ 87 | operator MyVec2() const { return MyVec2(x,y); } 88 | 89 | #define IM_VEC4_CLASS_EXTRA \ 90 | constexpr ImVec4(const MyVec4& f) : x(f.x), y(f.y), z(f.z), w(f.w) {} \ 91 | operator MyVec4() const { return MyVec4(x,y,z,w); } 92 | */ 93 | 94 | //---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices. 95 | // Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices). 96 | // Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer. 97 | // Read about ImGuiBackendFlags_RendererHasVtxOffset for details. 98 | //#define ImDrawIdx unsigned int 99 | 100 | //---- Override ImDrawCallback signature (will need to modify renderer backends accordingly) 101 | //struct ImDrawList; 102 | //struct ImDrawCmd; 103 | //typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data); 104 | //#define ImDrawCallback MyImDrawCallback 105 | 106 | //---- Debug Tools: Macro to break in Debugger 107 | // (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.) 108 | //#define IM_DEBUG_BREAK IM_ASSERT(0) 109 | //#define IM_DEBUG_BREAK __debugbreak() 110 | 111 | //---- Debug Tools: Have the Item Picker break in the ItemAdd() function instead of ItemHoverable(), 112 | // (which comes earlier in the code, will catch a few extra items, allow picking items other than Hovered one.) 113 | // This adds a small runtime cost which is why it is not enabled by default. 114 | //#define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX 115 | 116 | //---- Debug Tools: Enable slower asserts 117 | //#define IMGUI_DEBUG_PARANOID 118 | 119 | //---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files. 120 | /* 121 | namespace ImGui 122 | { 123 | void MyFunction(const char* name, const MyMatrix44& v); 124 | } 125 | */ 126 | -------------------------------------------------------------------------------- /Imgui/imgui_impl_dx9.cpp: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for DirectX9 2 | // This needs to be used along with a Platform Backend (e.g. Win32) 3 | 4 | // Implemented features: 5 | // [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID! 6 | // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. 7 | 8 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 9 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. 10 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 11 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 12 | 13 | // CHANGELOG 14 | // (minor and older changes stripped away, please see git history for details) 15 | // 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX). 16 | // 2021-06-25: DirectX9: Explicitly disable texture state stages after >= 1. 17 | // 2021-05-19: DirectX9: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement) 18 | // 2021-04-23: DirectX9: Explicitly setting up more graphics states to increase compatibility with unusual non-default states. 19 | // 2021-03-18: DirectX9: Calling IDirect3DStateBlock9::Capture() after CreateStateBlock() as a workaround for state restoring issues (see #3857). 20 | // 2021-03-03: DirectX9: Added support for IMGUI_USE_BGRA_PACKED_COLOR in user's imconfig file. 21 | // 2021-02-18: DirectX9: Change blending equation to preserve alpha in output buffer. 22 | // 2019-05-29: DirectX9: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag. 23 | // 2019-04-30: DirectX9: Added support for special ImDrawCallback_ResetRenderState callback to reset render state. 24 | // 2019-03-29: Misc: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). 25 | // 2019-01-16: Misc: Disabled fog before drawing UI's. Fixes issue #2288. 26 | // 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window. 27 | // 2018-06-08: Misc: Extracted imgui_impl_dx9.cpp/.h away from the old combined DX9+Win32 example. 28 | // 2018-06-08: DirectX9: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle. 29 | // 2018-05-07: Render: Saving/restoring Transform because they don't seem to be included in the StateBlock. Setting shading mode to Gouraud. 30 | // 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplDX9_RenderDrawData() in the .h file so you can call it yourself. 31 | // 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves. 32 | 33 | #include "imgui.h" 34 | #include "imgui_impl_dx9.h" 35 | 36 | // DirectX 37 | #include 38 | 39 | // DirectX data 40 | struct ImGui_ImplDX9_Data 41 | { 42 | LPDIRECT3DDEVICE9 pd3dDevice; 43 | LPDIRECT3DVERTEXBUFFER9 pVB; 44 | LPDIRECT3DINDEXBUFFER9 pIB; 45 | LPDIRECT3DTEXTURE9 FontTexture; 46 | int VertexBufferSize; 47 | int IndexBufferSize; 48 | 49 | ImGui_ImplDX9_Data() { memset((void*)this, 0, sizeof(*this)); VertexBufferSize = 5000; IndexBufferSize = 10000; } 50 | }; 51 | 52 | struct CUSTOMVERTEX 53 | { 54 | float pos[3]; 55 | D3DCOLOR col; 56 | float uv[2]; 57 | }; 58 | #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1) 59 | 60 | #ifdef IMGUI_USE_BGRA_PACKED_COLOR 61 | #define IMGUI_COL_TO_DX9_ARGB(_COL) (_COL) 62 | #else 63 | #define IMGUI_COL_TO_DX9_ARGB(_COL) (((_COL) & 0xFF00FF00) | (((_COL) & 0xFF0000) >> 16) | (((_COL) & 0xFF) << 16)) 64 | #endif 65 | 66 | // Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts 67 | // It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts. 68 | static ImGui_ImplDX9_Data* ImGui_ImplDX9_GetBackendData() 69 | { 70 | return ImGui::GetCurrentContext() ? (ImGui_ImplDX9_Data*)ImGui::GetIO().BackendRendererUserData : NULL; 71 | } 72 | 73 | // Functions 74 | static void ImGui_ImplDX9_SetupRenderState(ImDrawData* draw_data) 75 | { 76 | ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData(); 77 | 78 | // Setup viewport 79 | D3DVIEWPORT9 vp; 80 | vp.X = vp.Y = 0; 81 | vp.Width = (DWORD)draw_data->DisplaySize.x; 82 | vp.Height = (DWORD)draw_data->DisplaySize.y; 83 | vp.MinZ = 0.0f; 84 | vp.MaxZ = 1.0f; 85 | bd->pd3dDevice->SetViewport(&vp); 86 | 87 | // Setup render state: fixed-pipeline, alpha-blending, no face culling, no depth testing, shade mode (for gradient), bilinear sampling. 88 | bd->pd3dDevice->SetPixelShader(NULL); 89 | bd->pd3dDevice->SetVertexShader(NULL); 90 | bd->pd3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); 91 | bd->pd3dDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD); 92 | bd->pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, FALSE); 93 | bd->pd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); 94 | bd->pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); 95 | bd->pd3dDevice->SetRenderState(D3DRS_ZENABLE, FALSE); 96 | bd->pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); 97 | bd->pd3dDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD); 98 | bd->pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); 99 | bd->pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); 100 | bd->pd3dDevice->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, TRUE); 101 | bd->pd3dDevice->SetRenderState(D3DRS_SRCBLENDALPHA, D3DBLEND_ONE); 102 | bd->pd3dDevice->SetRenderState(D3DRS_DESTBLENDALPHA, D3DBLEND_INVSRCALPHA); 103 | bd->pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE); 104 | bd->pd3dDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); 105 | bd->pd3dDevice->SetRenderState(D3DRS_RANGEFOGENABLE, FALSE); 106 | bd->pd3dDevice->SetRenderState(D3DRS_SPECULARENABLE, FALSE); 107 | bd->pd3dDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE); 108 | bd->pd3dDevice->SetRenderState(D3DRS_CLIPPING, TRUE); 109 | bd->pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE); 110 | bd->pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); 111 | bd->pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); 112 | bd->pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); 113 | bd->pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); 114 | bd->pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); 115 | bd->pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); 116 | bd->pd3dDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); 117 | bd->pd3dDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); 118 | bd->pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); 119 | bd->pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); 120 | 121 | // Setup orthographic projection matrix 122 | // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps. 123 | // Being agnostic of whether or can be used, we aren't relying on D3DXMatrixIdentity()/D3DXMatrixOrthoOffCenterLH() or DirectX::XMMatrixIdentity()/DirectX::XMMatrixOrthographicOffCenterLH() 124 | { 125 | float L = draw_data->DisplayPos.x + 0.5f; 126 | float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x + 0.5f; 127 | float T = draw_data->DisplayPos.y + 0.5f; 128 | float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y + 0.5f; 129 | D3DMATRIX mat_identity = { { { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f } } }; 130 | D3DMATRIX mat_projection = 131 | { { { 132 | 2.0f/(R-L), 0.0f, 0.0f, 0.0f, 133 | 0.0f, 2.0f/(T-B), 0.0f, 0.0f, 134 | 0.0f, 0.0f, 0.5f, 0.0f, 135 | (L+R)/(L-R), (T+B)/(B-T), 0.5f, 1.0f 136 | } } }; 137 | bd->pd3dDevice->SetTransform(D3DTS_WORLD, &mat_identity); 138 | bd->pd3dDevice->SetTransform(D3DTS_VIEW, &mat_identity); 139 | bd->pd3dDevice->SetTransform(D3DTS_PROJECTION, &mat_projection); 140 | } 141 | } 142 | 143 | // Render function. 144 | void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data) 145 | { 146 | // Avoid rendering when minimized 147 | if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f) 148 | return; 149 | 150 | // Create and grow buffers if needed 151 | ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData(); 152 | if (!bd->pVB || bd->VertexBufferSize < draw_data->TotalVtxCount) 153 | { 154 | if (bd->pVB) { bd->pVB->Release(); bd->pVB = NULL; } 155 | bd->VertexBufferSize = draw_data->TotalVtxCount + 5000; 156 | if (bd->pd3dDevice->CreateVertexBuffer(bd->VertexBufferSize * sizeof(CUSTOMVERTEX), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &bd->pVB, NULL) < 0) 157 | return; 158 | } 159 | if (!bd->pIB || bd->IndexBufferSize < draw_data->TotalIdxCount) 160 | { 161 | if (bd->pIB) { bd->pIB->Release(); bd->pIB = NULL; } 162 | bd->IndexBufferSize = draw_data->TotalIdxCount + 10000; 163 | if (bd->pd3dDevice->CreateIndexBuffer(bd->IndexBufferSize * sizeof(ImDrawIdx), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, sizeof(ImDrawIdx) == 2 ? D3DFMT_INDEX16 : D3DFMT_INDEX32, D3DPOOL_DEFAULT, &bd->pIB, NULL) < 0) 164 | return; 165 | } 166 | 167 | // Backup the DX9 state 168 | IDirect3DStateBlock9* d3d9_state_block = NULL; 169 | if (bd->pd3dDevice->CreateStateBlock(D3DSBT_ALL, &d3d9_state_block) < 0) 170 | return; 171 | if (d3d9_state_block->Capture() < 0) 172 | { 173 | d3d9_state_block->Release(); 174 | return; 175 | } 176 | 177 | // Backup the DX9 transform (DX9 documentation suggests that it is included in the StateBlock but it doesn't appear to) 178 | D3DMATRIX last_world, last_view, last_projection; 179 | bd->pd3dDevice->GetTransform(D3DTS_WORLD, &last_world); 180 | bd->pd3dDevice->GetTransform(D3DTS_VIEW, &last_view); 181 | bd->pd3dDevice->GetTransform(D3DTS_PROJECTION, &last_projection); 182 | 183 | // Allocate buffers 184 | CUSTOMVERTEX* vtx_dst; 185 | ImDrawIdx* idx_dst; 186 | if (bd->pVB->Lock(0, (UINT)(draw_data->TotalVtxCount * sizeof(CUSTOMVERTEX)), (void**)&vtx_dst, D3DLOCK_DISCARD) < 0) 187 | { 188 | d3d9_state_block->Release(); 189 | return; 190 | } 191 | if (bd->pIB->Lock(0, (UINT)(draw_data->TotalIdxCount * sizeof(ImDrawIdx)), (void**)&idx_dst, D3DLOCK_DISCARD) < 0) 192 | { 193 | bd->pVB->Unlock(); 194 | d3d9_state_block->Release(); 195 | return; 196 | } 197 | 198 | // Copy and convert all vertices into a single contiguous buffer, convert colors to DX9 default format. 199 | // FIXME-OPT: This is a minor waste of resource, the ideal is to use imconfig.h and 200 | // 1) to avoid repacking colors: #define IMGUI_USE_BGRA_PACKED_COLOR 201 | // 2) to avoid repacking vertices: #define IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT struct ImDrawVert { ImVec2 pos; float z; ImU32 col; ImVec2 uv; } 202 | for (int n = 0; n < draw_data->CmdListsCount; n++) 203 | { 204 | const ImDrawList* cmd_list = draw_data->CmdLists[n]; 205 | const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data; 206 | for (int i = 0; i < cmd_list->VtxBuffer.Size; i++) 207 | { 208 | vtx_dst->pos[0] = vtx_src->pos.x; 209 | vtx_dst->pos[1] = vtx_src->pos.y; 210 | vtx_dst->pos[2] = 0.0f; 211 | vtx_dst->col = IMGUI_COL_TO_DX9_ARGB(vtx_src->col); 212 | vtx_dst->uv[0] = vtx_src->uv.x; 213 | vtx_dst->uv[1] = vtx_src->uv.y; 214 | vtx_dst++; 215 | vtx_src++; 216 | } 217 | memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx)); 218 | idx_dst += cmd_list->IdxBuffer.Size; 219 | } 220 | bd->pVB->Unlock(); 221 | bd->pIB->Unlock(); 222 | bd->pd3dDevice->SetStreamSource(0, bd->pVB, 0, sizeof(CUSTOMVERTEX)); 223 | bd->pd3dDevice->SetIndices(bd->pIB); 224 | bd->pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX); 225 | 226 | // Setup desired DX state 227 | ImGui_ImplDX9_SetupRenderState(draw_data); 228 | 229 | // Render command lists 230 | // (Because we merged all buffers into a single one, we maintain our own offset into them) 231 | int global_vtx_offset = 0; 232 | int global_idx_offset = 0; 233 | ImVec2 clip_off = draw_data->DisplayPos; 234 | for (int n = 0; n < draw_data->CmdListsCount; n++) 235 | { 236 | const ImDrawList* cmd_list = draw_data->CmdLists[n]; 237 | for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) 238 | { 239 | const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; 240 | if (pcmd->UserCallback != NULL) 241 | { 242 | // User callback, registered via ImDrawList::AddCallback() 243 | // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.) 244 | if (pcmd->UserCallback == ImDrawCallback_ResetRenderState) 245 | ImGui_ImplDX9_SetupRenderState(draw_data); 246 | else 247 | pcmd->UserCallback(cmd_list, pcmd); 248 | } 249 | else 250 | { 251 | // Project scissor/clipping rectangles into framebuffer space 252 | ImVec2 clip_min(pcmd->ClipRect.x - clip_off.x, pcmd->ClipRect.y - clip_off.y); 253 | ImVec2 clip_max(pcmd->ClipRect.z - clip_off.x, pcmd->ClipRect.w - clip_off.y); 254 | if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y) 255 | continue; 256 | 257 | // Apply Scissor/clipping rectangle, Bind texture, Draw 258 | const RECT r = { (LONG)clip_min.x, (LONG)clip_min.y, (LONG)clip_max.x, (LONG)clip_max.y }; 259 | const LPDIRECT3DTEXTURE9 texture = (LPDIRECT3DTEXTURE9)pcmd->GetTexID(); 260 | bd->pd3dDevice->SetTexture(0, texture); 261 | bd->pd3dDevice->SetScissorRect(&r); 262 | bd->pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, pcmd->VtxOffset + global_vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, pcmd->IdxOffset + global_idx_offset, pcmd->ElemCount / 3); 263 | } 264 | } 265 | global_idx_offset += cmd_list->IdxBuffer.Size; 266 | global_vtx_offset += cmd_list->VtxBuffer.Size; 267 | } 268 | 269 | // Restore the DX9 transform 270 | bd->pd3dDevice->SetTransform(D3DTS_WORLD, &last_world); 271 | bd->pd3dDevice->SetTransform(D3DTS_VIEW, &last_view); 272 | bd->pd3dDevice->SetTransform(D3DTS_PROJECTION, &last_projection); 273 | 274 | // Restore the DX9 state 275 | d3d9_state_block->Apply(); 276 | d3d9_state_block->Release(); 277 | } 278 | 279 | bool ImGui_ImplDX9_Init(IDirect3DDevice9* device) 280 | { 281 | ImGuiIO& io = ImGui::GetIO(); 282 | IM_ASSERT(io.BackendRendererUserData == NULL && "Already initialized a renderer backend!"); 283 | 284 | // Setup backend capabilities flags 285 | ImGui_ImplDX9_Data* bd = IM_NEW(ImGui_ImplDX9_Data)(); 286 | io.BackendRendererUserData = (void*)bd; 287 | io.BackendRendererName = "imgui_impl_dx9"; 288 | io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. 289 | 290 | bd->pd3dDevice = device; 291 | bd->pd3dDevice->AddRef(); 292 | 293 | return true; 294 | } 295 | 296 | void ImGui_ImplDX9_Shutdown() 297 | { 298 | ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData(); 299 | IM_ASSERT(bd != NULL && "No renderer backend to shutdown, or already shutdown?"); 300 | ImGuiIO& io = ImGui::GetIO(); 301 | 302 | ImGui_ImplDX9_InvalidateDeviceObjects(); 303 | if (bd->pd3dDevice) { bd->pd3dDevice->Release(); } 304 | io.BackendRendererName = NULL; 305 | io.BackendRendererUserData = NULL; 306 | IM_DELETE(bd); 307 | } 308 | 309 | static bool ImGui_ImplDX9_CreateFontsTexture() 310 | { 311 | // Build texture atlas 312 | ImGuiIO& io = ImGui::GetIO(); 313 | ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData(); 314 | unsigned char* pixels; 315 | int width, height, bytes_per_pixel; 316 | io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height, &bytes_per_pixel); 317 | 318 | // Convert RGBA32 to BGRA32 (because RGBA32 is not well supported by DX9 devices) 319 | #ifndef IMGUI_USE_BGRA_PACKED_COLOR 320 | if (io.Fonts->TexPixelsUseColors) 321 | { 322 | ImU32* dst_start = (ImU32*)ImGui::MemAlloc((size_t)width * height * bytes_per_pixel); 323 | for (ImU32* src = (ImU32*)pixels, *dst = dst_start, *dst_end = dst_start + (size_t)width * height; dst < dst_end; src++, dst++) 324 | *dst = IMGUI_COL_TO_DX9_ARGB(*src); 325 | pixels = (unsigned char*)dst_start; 326 | } 327 | #endif 328 | 329 | // Upload texture to graphics system 330 | bd->FontTexture = NULL; 331 | if (bd->pd3dDevice->CreateTexture(width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &bd->FontTexture, NULL) < 0) 332 | return false; 333 | D3DLOCKED_RECT tex_locked_rect; 334 | if (bd->FontTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK) 335 | return false; 336 | for (int y = 0; y < height; y++) 337 | memcpy((unsigned char*)tex_locked_rect.pBits + (size_t)tex_locked_rect.Pitch * y, pixels + (size_t)width * bytes_per_pixel * y, (size_t)width * bytes_per_pixel); 338 | bd->FontTexture->UnlockRect(0); 339 | 340 | // Store our identifier 341 | io.Fonts->SetTexID((ImTextureID)bd->FontTexture); 342 | 343 | #ifndef IMGUI_USE_BGRA_PACKED_COLOR 344 | if (io.Fonts->TexPixelsUseColors) 345 | ImGui::MemFree(pixels); 346 | #endif 347 | 348 | return true; 349 | } 350 | 351 | bool ImGui_ImplDX9_CreateDeviceObjects() 352 | { 353 | ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData(); 354 | if (!bd || !bd->pd3dDevice) 355 | return false; 356 | if (!ImGui_ImplDX9_CreateFontsTexture()) 357 | return false; 358 | return true; 359 | } 360 | 361 | void ImGui_ImplDX9_InvalidateDeviceObjects() 362 | { 363 | ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData(); 364 | if (!bd || !bd->pd3dDevice) 365 | return; 366 | if (bd->pVB) { bd->pVB->Release(); bd->pVB = NULL; } 367 | if (bd->pIB) { bd->pIB->Release(); bd->pIB = NULL; } 368 | if (bd->FontTexture) { bd->FontTexture->Release(); bd->FontTexture = NULL; ImGui::GetIO().Fonts->SetTexID(NULL); } // We copied bd->pFontTextureView to io.Fonts->TexID so let's clear that as well. 369 | } 370 | 371 | void ImGui_ImplDX9_NewFrame() 372 | { 373 | ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData(); 374 | IM_ASSERT(bd != NULL && "Did you call ImGui_ImplDX9_Init()?"); 375 | 376 | if (!bd->FontTexture) 377 | ImGui_ImplDX9_CreateDeviceObjects(); 378 | } 379 | -------------------------------------------------------------------------------- /Imgui/imgui_impl_dx9.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for DirectX9 2 | // This needs to be used along with a Platform Backend (e.g. Win32) 3 | 4 | // Implemented features: 5 | // [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID! 6 | // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. 7 | 8 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 9 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. 10 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 11 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 12 | 13 | #pragma once 14 | #include "imgui.h" // IMGUI_IMPL_API 15 | 16 | struct IDirect3DDevice9; 17 | 18 | IMGUI_IMPL_API bool ImGui_ImplDX9_Init(IDirect3DDevice9* device); 19 | IMGUI_IMPL_API void ImGui_ImplDX9_Shutdown(); 20 | IMGUI_IMPL_API void ImGui_ImplDX9_NewFrame(); 21 | IMGUI_IMPL_API void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data); 22 | 23 | // Use if you want to reset your rendering device without losing Dear ImGui state. 24 | IMGUI_IMPL_API bool ImGui_ImplDX9_CreateDeviceObjects(); 25 | IMGUI_IMPL_API void ImGui_ImplDX9_InvalidateDeviceObjects(); 26 | -------------------------------------------------------------------------------- /Imgui/imgui_impl_win32.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Platform Backend for Windows (standard windows API for 32 and 64 bits applications) 2 | // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) 3 | 4 | // Implemented features: 5 | // [X] Platform: Clipboard support (for Win32 this is actually part of core dear imgui) 6 | // [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy VK_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set] 7 | // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. 8 | // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. 9 | 10 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 11 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. 12 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 13 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 14 | 15 | #pragma once 16 | #include "imgui.h" // IMGUI_IMPL_API 17 | 18 | IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd); 19 | IMGUI_IMPL_API void ImGui_ImplWin32_Shutdown(); 20 | IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame(); 21 | 22 | // Win32 message handler your application need to call. 23 | // - Intentionally commented out in a '#if 0' block to avoid dragging dependencies on from this helper. 24 | // - You should COPY the line below into your .cpp code to forward declare the function and then you can call it. 25 | // - Call from your application's message handler. Keep calling your message handler unless this function returns TRUE. 26 | 27 | #if 0 28 | extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); 29 | #endif 30 | 31 | // DPI-related helpers (optional) 32 | // - Use to enable DPI awareness without having to create an application manifest. 33 | // - Your own app may already do this via a manifest or explicit calls. This is mostly useful for our examples/ apps. 34 | // - In theory we could call simple functions from Windows SDK such as SetProcessDPIAware(), SetProcessDpiAwareness(), etc. 35 | // but most of the functions provided by Microsoft require Windows 8.1/10+ SDK at compile time and Windows 8/10+ at runtime, 36 | // neither we want to require the user to have. So we dynamically select and load those functions to avoid dependencies. 37 | IMGUI_IMPL_API void ImGui_ImplWin32_EnableDpiAwareness(); 38 | IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd); // HWND hwnd 39 | IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor); // HMONITOR monitor 40 | 41 | // Transparency related helpers (optional) [experimental] 42 | // - Use to enable alpha compositing transparency with the desktop. 43 | // - Use together with e.g. clearing your framebuffer with zero-alpha. 44 | IMGUI_IMPL_API void ImGui_ImplWin32_EnableAlphaCompositing(void* hwnd); // HWND hwnd 45 | -------------------------------------------------------------------------------- /Imgui/imstb_rectpack.h: -------------------------------------------------------------------------------- 1 | // [DEAR IMGUI] 2 | // This is a slightly modified version of stb_rect_pack.h 1.01. 3 | // Grep for [DEAR IMGUI] to find the changes. 4 | // 5 | // stb_rect_pack.h - v1.01 - public domain - rectangle packing 6 | // Sean Barrett 2014 7 | // 8 | // Useful for e.g. packing rectangular textures into an atlas. 9 | // Does not do rotation. 10 | // 11 | // Before #including, 12 | // 13 | // #define STB_RECT_PACK_IMPLEMENTATION 14 | // 15 | // in the file that you want to have the implementation. 16 | // 17 | // Not necessarily the awesomest packing method, but better than 18 | // the totally naive one in stb_truetype (which is primarily what 19 | // this is meant to replace). 20 | // 21 | // Has only had a few tests run, may have issues. 22 | // 23 | // More docs to come. 24 | // 25 | // No memory allocations; uses qsort() and assert() from stdlib. 26 | // Can override those by defining STBRP_SORT and STBRP_ASSERT. 27 | // 28 | // This library currently uses the Skyline Bottom-Left algorithm. 29 | // 30 | // Please note: better rectangle packers are welcome! Please 31 | // implement them to the same API, but with a different init 32 | // function. 33 | // 34 | // Credits 35 | // 36 | // Library 37 | // Sean Barrett 38 | // Minor features 39 | // Martins Mozeiko 40 | // github:IntellectualKitty 41 | // 42 | // Bugfixes / warning fixes 43 | // Jeremy Jaussaud 44 | // Fabian Giesen 45 | // 46 | // Version history: 47 | // 48 | // 1.01 (2021-07-11) always use large rect mode, expose STBRP__MAXVAL in public section 49 | // 1.00 (2019-02-25) avoid small space waste; gracefully fail too-wide rectangles 50 | // 0.99 (2019-02-07) warning fixes 51 | // 0.11 (2017-03-03) return packing success/fail result 52 | // 0.10 (2016-10-25) remove cast-away-const to avoid warnings 53 | // 0.09 (2016-08-27) fix compiler warnings 54 | // 0.08 (2015-09-13) really fix bug with empty rects (w=0 or h=0) 55 | // 0.07 (2015-09-13) fix bug with empty rects (w=0 or h=0) 56 | // 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort 57 | // 0.05: added STBRP_ASSERT to allow replacing assert 58 | // 0.04: fixed minor bug in STBRP_LARGE_RECTS support 59 | // 0.01: initial release 60 | // 61 | // LICENSE 62 | // 63 | // See end of file for license information. 64 | 65 | ////////////////////////////////////////////////////////////////////////////// 66 | // 67 | // INCLUDE SECTION 68 | // 69 | 70 | #ifndef STB_INCLUDE_STB_RECT_PACK_H 71 | #define STB_INCLUDE_STB_RECT_PACK_H 72 | 73 | #define STB_RECT_PACK_VERSION 1 74 | 75 | #ifdef STBRP_STATIC 76 | #define STBRP_DEF static 77 | #else 78 | #define STBRP_DEF extern 79 | #endif 80 | 81 | #ifdef __cplusplus 82 | extern "C" { 83 | #endif 84 | 85 | typedef struct stbrp_context stbrp_context; 86 | typedef struct stbrp_node stbrp_node; 87 | typedef struct stbrp_rect stbrp_rect; 88 | 89 | typedef int stbrp_coord; 90 | 91 | #define STBRP__MAXVAL 0x7fffffff 92 | // Mostly for internal use, but this is the maximum supported coordinate value. 93 | 94 | STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects); 95 | // Assign packed locations to rectangles. The rectangles are of type 96 | // 'stbrp_rect' defined below, stored in the array 'rects', and there 97 | // are 'num_rects' many of them. 98 | // 99 | // Rectangles which are successfully packed have the 'was_packed' flag 100 | // set to a non-zero value and 'x' and 'y' store the minimum location 101 | // on each axis (i.e. bottom-left in cartesian coordinates, top-left 102 | // if you imagine y increasing downwards). Rectangles which do not fit 103 | // have the 'was_packed' flag set to 0. 104 | // 105 | // You should not try to access the 'rects' array from another thread 106 | // while this function is running, as the function temporarily reorders 107 | // the array while it executes. 108 | // 109 | // To pack into another rectangle, you need to call stbrp_init_target 110 | // again. To continue packing into the same rectangle, you can call 111 | // this function again. Calling this multiple times with multiple rect 112 | // arrays will probably produce worse packing results than calling it 113 | // a single time with the full rectangle array, but the option is 114 | // available. 115 | // 116 | // The function returns 1 if all of the rectangles were successfully 117 | // packed and 0 otherwise. 118 | 119 | struct stbrp_rect 120 | { 121 | // reserved for your use: 122 | int id; 123 | 124 | // input: 125 | stbrp_coord w, h; 126 | 127 | // output: 128 | stbrp_coord x, y; 129 | int was_packed; // non-zero if valid packing 130 | 131 | }; // 16 bytes, nominally 132 | 133 | 134 | STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes); 135 | // Initialize a rectangle packer to: 136 | // pack a rectangle that is 'width' by 'height' in dimensions 137 | // using temporary storage provided by the array 'nodes', which is 'num_nodes' long 138 | // 139 | // You must call this function every time you start packing into a new target. 140 | // 141 | // There is no "shutdown" function. The 'nodes' memory must stay valid for 142 | // the following stbrp_pack_rects() call (or calls), but can be freed after 143 | // the call (or calls) finish. 144 | // 145 | // Note: to guarantee best results, either: 146 | // 1. make sure 'num_nodes' >= 'width' 147 | // or 2. call stbrp_allow_out_of_mem() defined below with 'allow_out_of_mem = 1' 148 | // 149 | // If you don't do either of the above things, widths will be quantized to multiples 150 | // of small integers to guarantee the algorithm doesn't run out of temporary storage. 151 | // 152 | // If you do #2, then the non-quantized algorithm will be used, but the algorithm 153 | // may run out of temporary storage and be unable to pack some rectangles. 154 | 155 | STBRP_DEF void stbrp_setup_allow_out_of_mem (stbrp_context *context, int allow_out_of_mem); 156 | // Optionally call this function after init but before doing any packing to 157 | // change the handling of the out-of-temp-memory scenario, described above. 158 | // If you call init again, this will be reset to the default (false). 159 | 160 | 161 | STBRP_DEF void stbrp_setup_heuristic (stbrp_context *context, int heuristic); 162 | // Optionally select which packing heuristic the library should use. Different 163 | // heuristics will produce better/worse results for different data sets. 164 | // If you call init again, this will be reset to the default. 165 | 166 | enum 167 | { 168 | STBRP_HEURISTIC_Skyline_default=0, 169 | STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default, 170 | STBRP_HEURISTIC_Skyline_BF_sortHeight 171 | }; 172 | 173 | 174 | ////////////////////////////////////////////////////////////////////////////// 175 | // 176 | // the details of the following structures don't matter to you, but they must 177 | // be visible so you can handle the memory allocations for them 178 | 179 | struct stbrp_node 180 | { 181 | stbrp_coord x,y; 182 | stbrp_node *next; 183 | }; 184 | 185 | struct stbrp_context 186 | { 187 | int width; 188 | int height; 189 | int align; 190 | int init_mode; 191 | int heuristic; 192 | int num_nodes; 193 | stbrp_node *active_head; 194 | stbrp_node *free_head; 195 | stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2' 196 | }; 197 | 198 | #ifdef __cplusplus 199 | } 200 | #endif 201 | 202 | #endif 203 | 204 | ////////////////////////////////////////////////////////////////////////////// 205 | // 206 | // IMPLEMENTATION SECTION 207 | // 208 | 209 | #ifdef STB_RECT_PACK_IMPLEMENTATION 210 | #ifndef STBRP_SORT 211 | #include 212 | #define STBRP_SORT qsort 213 | #endif 214 | 215 | #ifndef STBRP_ASSERT 216 | #include 217 | #define STBRP_ASSERT assert 218 | #endif 219 | 220 | #ifdef _MSC_VER 221 | #define STBRP__NOTUSED(v) (void)(v) 222 | #define STBRP__CDECL __cdecl 223 | #else 224 | #define STBRP__NOTUSED(v) (void)sizeof(v) 225 | #define STBRP__CDECL 226 | #endif 227 | 228 | enum 229 | { 230 | STBRP__INIT_skyline = 1 231 | }; 232 | 233 | STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic) 234 | { 235 | switch (context->init_mode) { 236 | case STBRP__INIT_skyline: 237 | STBRP_ASSERT(heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight); 238 | context->heuristic = heuristic; 239 | break; 240 | default: 241 | STBRP_ASSERT(0); 242 | } 243 | } 244 | 245 | STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem) 246 | { 247 | if (allow_out_of_mem) 248 | // if it's ok to run out of memory, then don't bother aligning them; 249 | // this gives better packing, but may fail due to OOM (even though 250 | // the rectangles easily fit). @TODO a smarter approach would be to only 251 | // quantize once we've hit OOM, then we could get rid of this parameter. 252 | context->align = 1; 253 | else { 254 | // if it's not ok to run out of memory, then quantize the widths 255 | // so that num_nodes is always enough nodes. 256 | // 257 | // I.e. num_nodes * align >= width 258 | // align >= width / num_nodes 259 | // align = ceil(width/num_nodes) 260 | 261 | context->align = (context->width + context->num_nodes-1) / context->num_nodes; 262 | } 263 | } 264 | 265 | STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes) 266 | { 267 | int i; 268 | 269 | for (i=0; i < num_nodes-1; ++i) 270 | nodes[i].next = &nodes[i+1]; 271 | nodes[i].next = NULL; 272 | context->init_mode = STBRP__INIT_skyline; 273 | context->heuristic = STBRP_HEURISTIC_Skyline_default; 274 | context->free_head = &nodes[0]; 275 | context->active_head = &context->extra[0]; 276 | context->width = width; 277 | context->height = height; 278 | context->num_nodes = num_nodes; 279 | stbrp_setup_allow_out_of_mem(context, 0); 280 | 281 | // node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly) 282 | context->extra[0].x = 0; 283 | context->extra[0].y = 0; 284 | context->extra[0].next = &context->extra[1]; 285 | context->extra[1].x = (stbrp_coord) width; 286 | context->extra[1].y = (1<<30); 287 | context->extra[1].next = NULL; 288 | } 289 | 290 | // find minimum y position if it starts at x1 291 | static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste) 292 | { 293 | stbrp_node *node = first; 294 | int x1 = x0 + width; 295 | int min_y, visited_width, waste_area; 296 | 297 | STBRP__NOTUSED(c); 298 | 299 | STBRP_ASSERT(first->x <= x0); 300 | 301 | #if 0 302 | // skip in case we're past the node 303 | while (node->next->x <= x0) 304 | ++node; 305 | #else 306 | STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency 307 | #endif 308 | 309 | STBRP_ASSERT(node->x <= x0); 310 | 311 | min_y = 0; 312 | waste_area = 0; 313 | visited_width = 0; 314 | while (node->x < x1) { 315 | if (node->y > min_y) { 316 | // raise min_y higher. 317 | // we've accounted for all waste up to min_y, 318 | // but we'll now add more waste for everything we've visted 319 | waste_area += visited_width * (node->y - min_y); 320 | min_y = node->y; 321 | // the first time through, visited_width might be reduced 322 | if (node->x < x0) 323 | visited_width += node->next->x - x0; 324 | else 325 | visited_width += node->next->x - node->x; 326 | } else { 327 | // add waste area 328 | int under_width = node->next->x - node->x; 329 | if (under_width + visited_width > width) 330 | under_width = width - visited_width; 331 | waste_area += under_width * (min_y - node->y); 332 | visited_width += under_width; 333 | } 334 | node = node->next; 335 | } 336 | 337 | *pwaste = waste_area; 338 | return min_y; 339 | } 340 | 341 | typedef struct 342 | { 343 | int x,y; 344 | stbrp_node **prev_link; 345 | } stbrp__findresult; 346 | 347 | static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height) 348 | { 349 | int best_waste = (1<<30), best_x, best_y = (1 << 30); 350 | stbrp__findresult fr; 351 | stbrp_node **prev, *node, *tail, **best = NULL; 352 | 353 | // align to multiple of c->align 354 | width = (width + c->align - 1); 355 | width -= width % c->align; 356 | STBRP_ASSERT(width % c->align == 0); 357 | 358 | // if it can't possibly fit, bail immediately 359 | if (width > c->width || height > c->height) { 360 | fr.prev_link = NULL; 361 | fr.x = fr.y = 0; 362 | return fr; 363 | } 364 | 365 | node = c->active_head; 366 | prev = &c->active_head; 367 | while (node->x + width <= c->width) { 368 | int y,waste; 369 | y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste); 370 | if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL 371 | // bottom left 372 | if (y < best_y) { 373 | best_y = y; 374 | best = prev; 375 | } 376 | } else { 377 | // best-fit 378 | if (y + height <= c->height) { 379 | // can only use it if it first vertically 380 | if (y < best_y || (y == best_y && waste < best_waste)) { 381 | best_y = y; 382 | best_waste = waste; 383 | best = prev; 384 | } 385 | } 386 | } 387 | prev = &node->next; 388 | node = node->next; 389 | } 390 | 391 | best_x = (best == NULL) ? 0 : (*best)->x; 392 | 393 | // if doing best-fit (BF), we also have to try aligning right edge to each node position 394 | // 395 | // e.g, if fitting 396 | // 397 | // ____________________ 398 | // |____________________| 399 | // 400 | // into 401 | // 402 | // | | 403 | // | ____________| 404 | // |____________| 405 | // 406 | // then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned 407 | // 408 | // This makes BF take about 2x the time 409 | 410 | if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) { 411 | tail = c->active_head; 412 | node = c->active_head; 413 | prev = &c->active_head; 414 | // find first node that's admissible 415 | while (tail->x < width) 416 | tail = tail->next; 417 | while (tail) { 418 | int xpos = tail->x - width; 419 | int y,waste; 420 | STBRP_ASSERT(xpos >= 0); 421 | // find the left position that matches this 422 | while (node->next->x <= xpos) { 423 | prev = &node->next; 424 | node = node->next; 425 | } 426 | STBRP_ASSERT(node->next->x > xpos && node->x <= xpos); 427 | y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste); 428 | if (y + height <= c->height) { 429 | if (y <= best_y) { 430 | if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) { 431 | best_x = xpos; 432 | //STBRP_ASSERT(y <= best_y); [DEAR IMGUI] 433 | best_y = y; 434 | best_waste = waste; 435 | best = prev; 436 | } 437 | } 438 | } 439 | tail = tail->next; 440 | } 441 | } 442 | 443 | fr.prev_link = best; 444 | fr.x = best_x; 445 | fr.y = best_y; 446 | return fr; 447 | } 448 | 449 | static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height) 450 | { 451 | // find best position according to heuristic 452 | stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height); 453 | stbrp_node *node, *cur; 454 | 455 | // bail if: 456 | // 1. it failed 457 | // 2. the best node doesn't fit (we don't always check this) 458 | // 3. we're out of memory 459 | if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) { 460 | res.prev_link = NULL; 461 | return res; 462 | } 463 | 464 | // on success, create new node 465 | node = context->free_head; 466 | node->x = (stbrp_coord) res.x; 467 | node->y = (stbrp_coord) (res.y + height); 468 | 469 | context->free_head = node->next; 470 | 471 | // insert the new node into the right starting point, and 472 | // let 'cur' point to the remaining nodes needing to be 473 | // stiched back in 474 | 475 | cur = *res.prev_link; 476 | if (cur->x < res.x) { 477 | // preserve the existing one, so start testing with the next one 478 | stbrp_node *next = cur->next; 479 | cur->next = node; 480 | cur = next; 481 | } else { 482 | *res.prev_link = node; 483 | } 484 | 485 | // from here, traverse cur and free the nodes, until we get to one 486 | // that shouldn't be freed 487 | while (cur->next && cur->next->x <= res.x + width) { 488 | stbrp_node *next = cur->next; 489 | // move the current node to the free list 490 | cur->next = context->free_head; 491 | context->free_head = cur; 492 | cur = next; 493 | } 494 | 495 | // stitch the list back in 496 | node->next = cur; 497 | 498 | if (cur->x < res.x + width) 499 | cur->x = (stbrp_coord) (res.x + width); 500 | 501 | #ifdef _DEBUG 502 | cur = context->active_head; 503 | while (cur->x < context->width) { 504 | STBRP_ASSERT(cur->x < cur->next->x); 505 | cur = cur->next; 506 | } 507 | STBRP_ASSERT(cur->next == NULL); 508 | 509 | { 510 | int count=0; 511 | cur = context->active_head; 512 | while (cur) { 513 | cur = cur->next; 514 | ++count; 515 | } 516 | cur = context->free_head; 517 | while (cur) { 518 | cur = cur->next; 519 | ++count; 520 | } 521 | STBRP_ASSERT(count == context->num_nodes+2); 522 | } 523 | #endif 524 | 525 | return res; 526 | } 527 | 528 | static int STBRP__CDECL rect_height_compare(const void *a, const void *b) 529 | { 530 | const stbrp_rect *p = (const stbrp_rect *) a; 531 | const stbrp_rect *q = (const stbrp_rect *) b; 532 | if (p->h > q->h) 533 | return -1; 534 | if (p->h < q->h) 535 | return 1; 536 | return (p->w > q->w) ? -1 : (p->w < q->w); 537 | } 538 | 539 | static int STBRP__CDECL rect_original_order(const void *a, const void *b) 540 | { 541 | const stbrp_rect *p = (const stbrp_rect *) a; 542 | const stbrp_rect *q = (const stbrp_rect *) b; 543 | return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed); 544 | } 545 | 546 | STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects) 547 | { 548 | int i, all_rects_packed = 1; 549 | 550 | // we use the 'was_packed' field internally to allow sorting/unsorting 551 | for (i=0; i < num_rects; ++i) { 552 | rects[i].was_packed = i; 553 | } 554 | 555 | // sort according to heuristic 556 | STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare); 557 | 558 | for (i=0; i < num_rects; ++i) { 559 | if (rects[i].w == 0 || rects[i].h == 0) { 560 | rects[i].x = rects[i].y = 0; // empty rect needs no space 561 | } else { 562 | stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h); 563 | if (fr.prev_link) { 564 | rects[i].x = (stbrp_coord) fr.x; 565 | rects[i].y = (stbrp_coord) fr.y; 566 | } else { 567 | rects[i].x = rects[i].y = STBRP__MAXVAL; 568 | } 569 | } 570 | } 571 | 572 | // unsort 573 | STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order); 574 | 575 | // set was_packed flags and all_rects_packed status 576 | for (i=0; i < num_rects; ++i) { 577 | rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL); 578 | if (!rects[i].was_packed) 579 | all_rects_packed = 0; 580 | } 581 | 582 | // return the all_rects_packed status 583 | return all_rects_packed; 584 | } 585 | #endif 586 | 587 | /* 588 | ------------------------------------------------------------------------------ 589 | This software is available under 2 licenses -- choose whichever you prefer. 590 | ------------------------------------------------------------------------------ 591 | ALTERNATIVE A - MIT License 592 | Copyright (c) 2017 Sean Barrett 593 | Permission is hereby granted, free of charge, to any person obtaining a copy of 594 | this software and associated documentation files (the "Software"), to deal in 595 | the Software without restriction, including without limitation the rights to 596 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 597 | of the Software, and to permit persons to whom the Software is furnished to do 598 | so, subject to the following conditions: 599 | The above copyright notice and this permission notice shall be included in all 600 | copies or substantial portions of the Software. 601 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 602 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 603 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 604 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 605 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 606 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 607 | SOFTWARE. 608 | ------------------------------------------------------------------------------ 609 | ALTERNATIVE B - Public Domain (www.unlicense.org) 610 | This is free and unencumbered software released into the public domain. 611 | Anyone is free to copy, modify, publish, use, compile, sell, or distribute this 612 | software, either in source code form or as a compiled binary, for any purpose, 613 | commercial or non-commercial, and by any means. 614 | In jurisdictions that recognize copyright laws, the author or authors of this 615 | software dedicate any and all copyright interest in the software to the public 616 | domain. We make this dedication for the benefit of the public at large and to 617 | the detriment of our heirs and successors. We intend this dedication to be an 618 | overt act of relinquishment in perpetuity of all present and future rights to 619 | this software under copyright law. 620 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 621 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 622 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 623 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 624 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 625 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 626 | ------------------------------------------------------------------------------ 627 | */ 628 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### STATUS : DOWN 2 | ```sh-session 3 | Status 4 | ------ 5 | AIMBOT (Undetected) 6 | ESP (Undetected) 7 | OTHER (Undetected) 8 | UPDATED = STATUS : DOWN 9 | ----------------- 10 | ``` 11 | ```sh-session 12 | Characteristics 13 | --------------- 14 | AIMBOT (Rage [Blatant] or smooth aim.) 15 | ESP (Enemy Health, Hitbox, Name, Allies, Skeleton.) 16 | Visuals (Fog Of War, Distance, Weapons, Colors.) 17 | HOT KEYS / KEYBINDS (Menu, Aim, ESP.) 18 | ``` 19 | ### IMPORTANT 20 | This cheat isn't signed by Windows. Windows MIGHT say file is dangerous, but it does this for all game cheats. (50/50 Chance Now) 21 | ```sh-session 22 | Only Download Launchers from the Releases Tab. The ones there are Up To Date. 23 | ``` 24 | 25 | 26 | ### STEPS 27 | ```sh-session 28 | [1] Disable any Antivirus that is active. (Antivirus will block the game cheat from loading properly.) 29 | [2] Download and Unzip the zip folder into any directory. 30 | [3] Download ValoExt.exe from the releases tab. Your web browser may block the download. To bypass, open the full downloads page and select 'keep anyway'. 31 | [4] Run ValoExt.exe BEFORE Opening Valorant 32 | [5] Launch Valorant, Load into your desired game-mode, then press Ins (Inspect Key) to open the GUI. 33 | ``` 34 | ### Have Fun! But one more thing... 35 | Although this cheat IS safe, I recommend using an ALT Account or your own Driver. I have not been banned yet, but I am not responsible for you. 36 | ### Pic of Training mode 37 | 38 | -------------------------------------------------------------------------------- /Valorant/Driver/driver.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class _driver 4 | { 5 | private: 6 | typedef INT64(*Nt_UserGetPointerProprietaryId)(uintptr_t); 7 | Nt_UserGetPointerProprietaryId NtUserGetPointerProprietaryId = nullptr; 8 | 9 | #define DRIVER_READVM 0x80000001 10 | #define DRIVER_GETPOOL 0x80000002 11 | 12 | int _processid; 13 | uint64_t _guardedregion; 14 | 15 | struct _requests { 16 | uint32_t src_pid; 17 | uint64_t src_addr; 18 | uint64_t dst_addr; 19 | size_t size; 20 | int request_key; 21 | std::uintptr_t allocation; 22 | }; 23 | 24 | public: 25 | auto initdriver(int processid) -> void 26 | { 27 | NtUserGetPointerProprietaryId = (Nt_UserGetPointerProprietaryId)GetProcAddress(LoadLibraryA("win32u.dll"), "NtUserGetPointerProprietaryId"); 28 | if (NtUserGetPointerProprietaryId != 0) 29 | { 30 | printf("NtUserGetPointerProprietaryId: %p\n", NtUserGetPointerProprietaryId); 31 | _processid = processid; 32 | } 33 | } 34 | 35 | auto readvm(uint32_t src_pid, uint64_t src_addr, uint64_t dst_addr, size_t size) -> void 36 | { 37 | if (src_pid == 0 || src_addr == 0) return; 38 | 39 | _requests out = { src_pid, src_addr, dst_addr, size, DRIVER_READVM }; 40 | NtUserGetPointerProprietaryId(reinterpret_cast(&out)); 41 | } 42 | 43 | auto guarded_region() -> uintptr_t 44 | { 45 | _requests out = { 0 }; 46 | out.request_key = DRIVER_GETPOOL; 47 | NtUserGetPointerProprietaryId(reinterpret_cast(&out)); 48 | _guardedregion = out.allocation; 49 | return out.allocation; 50 | } 51 | 52 | template 53 | T readguarded(uintptr_t src, size_t size = sizeof(T)) 54 | { 55 | T buffer; 56 | readvm(_processid, src, (uintptr_t)&buffer, size); 57 | uintptr_t val = _guardedregion + (*(uintptr_t*)&buffer & 0xFFFFFF); 58 | return *(T*)&val; 59 | } 60 | 61 | template 62 | T readv(uintptr_t src, size_t size = sizeof(T)) 63 | { 64 | T buffer; 65 | readvm(_processid, src, (uintptr_t)&buffer, size); 66 | return buffer; 67 | } 68 | 69 | template 70 | void readarray(uint64_t address, T* array, size_t len) 71 | { 72 | readvm(_processid, address, (uintptr_t)&array, sizeof(T) * len); 73 | } 74 | 75 | //bluefire1337 76 | inline static bool isguarded(uintptr_t pointer) noexcept 77 | { 78 | static constexpr uintptr_t filter = 0xFFFFFFF000000000; 79 | uintptr_t result = pointer & filter; 80 | return result == 0x8000000000 || result == 0x10000000000; 81 | } 82 | template 83 | T read(T src) 84 | { 85 | T buffer = readv< uintptr_t >(src); 86 | 87 | if (isguarded((uintptr_t)buffer)) 88 | { 89 | return readguarded< uintptr_t >(src); 90 | } 91 | 92 | return buffer; 93 | } 94 | }; 95 | 96 | _driver driver; 97 | -------------------------------------------------------------------------------- /Valorant/Game/cheat.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "sdk.hpp" 3 | #include 4 | 5 | using namespace Globals; 6 | using namespace Camera; 7 | using namespace UE4; 8 | 9 | GWorld* UWorld; 10 | GGameInstance* UGameInstance; 11 | GLocalPlayer* ULocalPlayer; 12 | GPlayerController* APlayerController; 13 | GPawn* APawn; 14 | GPrivatePawn* APrivatePawn; 15 | GULevel* ULevel; 16 | GUSkeletalMeshComponent* USkeletalMeshComponent; 17 | 18 | bool cached = false; 19 | uintptr_t WorldPtr; 20 | 21 | auto CacheGame() -> void 22 | { 23 | auto guardedregion = driver.guarded_region(); 24 | 25 | while (true) 26 | { 27 | std::vector CachedList; 28 | 29 | WorldPtr = GetWorld(guardedregion); 30 | 31 | auto ULevelPtr = UWorld->ULevel(WorldPtr); 32 | auto UGameInstancePtr = UWorld->GameInstance(WorldPtr); 33 | 34 | auto ULocalPlayerPtr = UGameInstance->ULocalPlayer(UGameInstancePtr); 35 | auto APlayerControllerPtr = ULocalPlayer->APlayerController(ULocalPlayerPtr); 36 | 37 | PlayerCameraManager = APlayerController->APlayerCameraManager(APlayerControllerPtr); 38 | auto MyHUD = APlayerController->AHUD(APlayerControllerPtr); 39 | 40 | auto APawnPtr = APlayerController->APawn(APlayerControllerPtr); 41 | 42 | if (APawnPtr != 0) 43 | { 44 | MyUniqueID = APawn->UniqueID(APawnPtr); 45 | MyRelativeLocation = APawn->RelativeLocation(APawnPtr); 46 | } 47 | 48 | if (MyHUD != 0) 49 | { 50 | auto PlayerArray = ULevel->AActorArray(ULevelPtr); 51 | 52 | for (uint32_t i = 0; i < PlayerArray.Count; ++i) 53 | { 54 | auto Pawns = PlayerArray[i]; 55 | if (Pawns != APawnPtr) 56 | { 57 | if (MyUniqueID == APawn->UniqueID(Pawns)) 58 | { 59 | ValEntity Entities{ Pawns }; 60 | CachedList.push_back(Entities); 61 | } 62 | } 63 | } 64 | 65 | ValList.clear(); 66 | ValList = CachedList; 67 | Sleep(1000); 68 | } 69 | } 70 | } 71 | 72 | auto CheatLoop() -> void 73 | { 74 | for (ValEntity ValEntityList : ValList) 75 | { 76 | auto SkeletalMesh = APrivatePawn->USkeletalMeshComponent(ValEntityList.Actor); 77 | 78 | auto RelativeLocation = APawn->RelativeLocation(ValEntityList.Actor); 79 | auto RelativeLocationProjected = UE4::SDK::ProjectWorldToScreen(RelativeLocation); 80 | 81 | auto RelativePosition = RelativeLocation - CameraLocation; 82 | auto RelativeDistance = RelativePosition.Length() / 10000 * 2; 83 | 84 | auto HeadBone = UE4::SDK::GetEntityBone(SkeletalMesh, 8); 85 | auto HeadBoneProjected = UE4::SDK::ProjectWorldToScreen(HeadBone); 86 | 87 | auto RootBone = UE4::SDK::GetEntityBone(SkeletalMesh, 0); 88 | auto RootBoneProjected = UE4::SDK::ProjectWorldToScreen(RootBone); 89 | auto RootBoneProjected2 = UE4::SDK::ProjectWorldToScreen(FVector(RootBone.x, RootBone.y, RootBone.z - 15)); 90 | 91 | auto Distance = MyRelativeLocation.Distance(RelativeLocation); 92 | 93 | float BoxHeight = abs(HeadBoneProjected.y - RootBoneProjected.y); 94 | float BoxWidth = BoxHeight * 0.40; 95 | 96 | auto ESPColor = ImColor(255, 255, 255); 97 | 98 | auto Health = APawn->Health(ValEntityList.Actor); 99 | if (Health <= 0) continue; 100 | 101 | if (APawn->bIsDormant(ValEntityList.Actor)) 102 | { 103 | if (Settings::Visuals::bSnaplines) 104 | DrawTracers(RootBoneProjected, ESPColor); 105 | 106 | if (Settings::Visuals::bBox) 107 | Draw2DBox(RelativeLocationProjected, BoxWidth, BoxHeight, ESPColor); 108 | 109 | if (Settings::Visuals::bBoxOutlined) 110 | DrawOutlinedBox(RelativeLocationProjected, BoxWidth, BoxHeight, ESPColor); 111 | 112 | if (Settings::Visuals::bHealth) 113 | DrawHealthBar(RelativeLocationProjected, BoxWidth, BoxHeight, Health, RelativeDistance); 114 | 115 | if (Settings::Visuals::bDistance) 116 | DrawDistance(RootBoneProjected2, Distance); 117 | } 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /Valorant/Game/globals.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | HWND Entryhwnd = NULL; 5 | int processid = 0; 6 | 7 | namespace offsets 8 | { 9 | DWORD 10 | Gameinstance = 0x1a0, 11 | Ulevel = 0x38, 12 | LocalPlayers = 0x40, 13 | PlayerController = 0x38, 14 | PlayerCameraManager = 0x478, 15 | MyHUD = 0x470, 16 | AcknowledgedPawn = 0x460, 17 | PlayerState = 0x3f0, 18 | TeamComponent = 0x628, 19 | TeamID = 0xf8, 20 | UniqueID = 0x38, 21 | FNameID = 0x18, 22 | AActorArray = 0xa0, 23 | RootComponent = 0x230, 24 | RelativeLocation = 0x164, 25 | MeshComponent = 0x430, 26 | DamageHandler = 0x9a8, 27 | bIsDormant = 0x100, 28 | Health = 0x1b0, 29 | ComponentToWorld = 0x250, 30 | BoneArray = 0x5b0, 31 | BoneArrayCache = BoneArray + 0x10, 32 | BoneCount = 0x5b8; 33 | } 34 | 35 | namespace Settings 36 | { 37 | inline bool bMenu = true; 38 | 39 | namespace Visuals 40 | { 41 | inline bool bSnaplines = true; 42 | inline bool bDistance = false; 43 | inline bool bBox = true; 44 | inline bool bBoxOutlined = false; 45 | inline bool bHealth = false; 46 | 47 | inline float BoxWidth = 1.0f; 48 | } 49 | } -------------------------------------------------------------------------------- /Valorant/Game/sdk.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "../Overlay/render.hpp" 7 | #include "../Driver/driver.hpp" 8 | #include "structs.hpp" 9 | #include 10 | 11 | using namespace UE4Structs; 12 | 13 | namespace Globals 14 | { 15 | DWORD_PTR 16 | LocalPlayer, 17 | PlayerController, 18 | PlayerCameraManager; 19 | 20 | int MyUniqueID, MyTeamID, BoneCount; 21 | 22 | FVector MyRelativeLocation, closestPawn; 23 | 24 | namespace Camera 25 | { 26 | FVector CameraLocation, CameraRotation; 27 | float FovAngle; 28 | } 29 | } 30 | 31 | using namespace Globals; 32 | using namespace Camera; 33 | 34 | 35 | namespace UE4 36 | { 37 | struct GWorld 38 | { 39 | uintptr_t GameInstance(uintptr_t GameWorld) { 40 | return driver.readv(GameWorld + offsets::Gameinstance); 41 | }; 42 | 43 | uintptr_t ULevel(uintptr_t World) { 44 | return driver.read(World + offsets::Ulevel); 45 | }; 46 | }; 47 | 48 | struct GGameInstance { 49 | uintptr_t ULocalPlayer(uintptr_t UGameInstance) { 50 | auto ULocalPlayerArray = driver.readv(UGameInstance + offsets::LocalPlayers); 51 | return driver.readv(ULocalPlayerArray); 52 | }; 53 | }; 54 | 55 | struct GULevel { 56 | TArrayDrink AActorArray(uintptr_t ULevel) { 57 | return driver.readv>(ULevel + offsets::AActorArray); 58 | }; 59 | }; 60 | 61 | struct GPrivatePawn { 62 | uintptr_t USkeletalMeshComponent(uintptr_t Pawn) { 63 | return driver.read(Pawn + offsets::MeshComponent); 64 | }; 65 | }; 66 | 67 | struct GUSkeletalMeshComponent { 68 | int BoneCount(uintptr_t Mesh) { 69 | return driver.read(Mesh + offsets::BoneCount); 70 | }; 71 | }; 72 | 73 | struct GLocalPlayer { 74 | uintptr_t APlayerController(uintptr_t ULocalPlayer) { 75 | return driver.read(ULocalPlayer + offsets::PlayerController); 76 | }; 77 | }; 78 | 79 | struct GPlayerController { 80 | uintptr_t APlayerCameraManager(uintptr_t APlayerController) { 81 | return driver.read(APlayerController + offsets::PlayerCameraManager); 82 | }; 83 | uintptr_t AHUD(uintptr_t APlayerController) { 84 | return driver.read(APlayerController + offsets::MyHUD); 85 | }; 86 | uintptr_t APawn(uintptr_t APlayerController) { 87 | return driver.read(APlayerController + offsets::AcknowledgedPawn); 88 | }; 89 | }; 90 | 91 | struct GPawn { 92 | auto TeamID(uintptr_t APawn) -> int { 93 | auto PlayerState = driver.readv(APawn + offsets::PlayerState); 94 | auto TeamComponent = driver.readv(PlayerState + offsets::TeamComponent); 95 | return driver.readv(TeamComponent + offsets::TeamID); 96 | }; 97 | 98 | auto UniqueID(uintptr_t APawn) -> int { 99 | return driver.readv(APawn + offsets::UniqueID); 100 | }; 101 | 102 | auto FNameID(uintptr_t APawn) -> int { 103 | return driver.readv(APawn + offsets::FNameID); 104 | }; 105 | 106 | auto RelativeLocation(uintptr_t APawn) -> FVector { 107 | auto RootComponent = driver.readv(APawn + offsets::RootComponent); 108 | return driver.readv(RootComponent + offsets::RelativeLocation); 109 | }; 110 | 111 | auto bIsDormant(uintptr_t APawn) -> bool { 112 | return driver.readv(APawn + offsets::bIsDormant); 113 | }; 114 | 115 | auto Health(uintptr_t APawn) -> float { 116 | auto DamageHandler = driver.read(APawn + offsets::DamageHandler); 117 | return driver.readv(DamageHandler + offsets::Health); 118 | }; 119 | }; 120 | 121 | auto GetWorld(uintptr_t Pointer) -> uintptr_t 122 | { 123 | std::uintptr_t uworld_addr = driver.readv(Pointer + 0x50); 124 | 125 | unsigned long long uworld_offset; 126 | 127 | if (uworld_addr > 0x10000000000) 128 | { 129 | uworld_offset = uworld_addr - 0x10000000000; 130 | } 131 | else { 132 | uworld_offset = uworld_addr - 0x8000000000; 133 | } 134 | 135 | return Pointer + uworld_offset; 136 | } 137 | 138 | auto VectorToRotation(FVector relativeLocation) -> FVector 139 | { 140 | constexpr auto radToUnrRot = 57.2957795f; 141 | 142 | return FVector( 143 | atan2(relativeLocation.z, sqrt((relativeLocation.x * relativeLocation.x) + (relativeLocation.y * relativeLocation.y))) * radToUnrRot, 144 | atan2(relativeLocation.y, relativeLocation.x) * radToUnrRot, 145 | 0.f); 146 | } 147 | 148 | auto AimAtVector(FVector targetLocation, FVector cameraLocation) -> FVector 149 | { 150 | return VectorToRotation(targetLocation - cameraLocation); 151 | } 152 | 153 | namespace SDK 154 | { 155 | auto GetEntityBone(DWORD_PTR mesh, int id) -> FVector 156 | { 157 | DWORD_PTR array = driver.readv(mesh + offsets::BoneArray); 158 | if (array == NULL) 159 | array = driver.readv(mesh + offsets::BoneArrayCache); 160 | 161 | FTransform bone = driver.readv(array + (id * 0x30)); 162 | 163 | FTransform ComponentToWorld = driver.readv(mesh + offsets::ComponentToWorld); 164 | D3DMATRIX Matrix; 165 | 166 | Matrix = MatrixMultiplication(bone.ToMatrixWithScale(), ComponentToWorld.ToMatrixWithScale()); 167 | 168 | return FVector(Matrix._41, Matrix._42, Matrix._43); 169 | } 170 | 171 | auto ProjectWorldToScreen(FVector WorldLocation) -> FVector 172 | { 173 | FVector Screenlocation = FVector(0, 0, 0); 174 | 175 | auto ViewInfo = driver.readv(PlayerCameraManager + 0x1fe0 + 0x10); 176 | 177 | CameraLocation = ViewInfo.Location; 178 | CameraRotation = ViewInfo.Rotation; 179 | 180 | 181 | D3DMATRIX tempMatrix = Matrix(CameraRotation, FVector(0, 0, 0)); 182 | 183 | FVector vAxisX = FVector(tempMatrix.m[0][0], tempMatrix.m[0][1], tempMatrix.m[0][2]), 184 | vAxisY = FVector(tempMatrix.m[1][0], tempMatrix.m[1][1], tempMatrix.m[1][2]), 185 | vAxisZ = FVector(tempMatrix.m[2][0], tempMatrix.m[2][1], tempMatrix.m[2][2]); 186 | 187 | FVector vDelta = WorldLocation - CameraLocation; 188 | FVector vTransformed = FVector(vDelta.Dot(vAxisY), vDelta.Dot(vAxisZ), vDelta.Dot(vAxisX)); 189 | 190 | if (vTransformed.z < 1.f) vTransformed.z = 1.f; 191 | 192 | FovAngle = ViewInfo.FOV; 193 | 194 | float ScreenCenterX = Width / 2.0f; 195 | float ScreenCenterY = Height / 2.0f; 196 | 197 | Screenlocation.x = ScreenCenterX + vTransformed.x * (ScreenCenterX / tanf(FovAngle * (float)M_PI / 360.f)) / vTransformed.z; 198 | Screenlocation.y = ScreenCenterY - vTransformed.y * (ScreenCenterX / tanf(FovAngle * (float)M_PI / 360.f)) / vTransformed.z; 199 | 200 | return Screenlocation; 201 | } 202 | 203 | bool IsVec3Valid(FVector vec3) 204 | { 205 | return !(vec3.x == 0 && vec3.y == 0 && vec3.z == 0); 206 | } 207 | } 208 | } -------------------------------------------------------------------------------- /Valorant/Game/structs.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "../Driver/driver.hpp" 7 | 8 | #define M_PI 3.14159265358979323846264338327950288419716939937510 9 | 10 | namespace UE4Structs 11 | { 12 | typedef struct _ValEntity { 13 | uint64_t Actor; 14 | }ValEntity; 15 | std::vector ValList; 16 | 17 | class FVector 18 | { 19 | public: 20 | FVector() : x(0.f), y(0.f), z(0.f) 21 | { 22 | 23 | } 24 | 25 | FVector(float _x, float _y, float _z) : x(_x), y(_y), z(_z) 26 | { 27 | 28 | } 29 | ~FVector() 30 | { 31 | 32 | } 33 | 34 | float x; 35 | float y; 36 | float z; 37 | 38 | inline float Dot(FVector v) 39 | { 40 | return x * v.x + y * v.y + z * v.z; 41 | } 42 | 43 | inline float Distance(FVector v) 44 | { 45 | float x = this->x - v.x; 46 | float y = this->y - v.y; 47 | float z = this->z - v.z; 48 | 49 | return sqrtf((x * x) + (y * y) + (z * z)) * 0.03048f; 50 | } 51 | 52 | FVector operator+(FVector v) 53 | { 54 | return FVector(x + v.x, y + v.y, z + v.z); 55 | } 56 | 57 | FVector operator-(FVector v) 58 | { 59 | return FVector(x - v.x, y - v.y, z - v.z); 60 | } 61 | 62 | FVector operator*(float number) const { 63 | return FVector(x * number, y * number, z * number); 64 | } 65 | 66 | __forceinline float Magnitude() const { 67 | return sqrtf(x * x + y * y + z * z); 68 | } 69 | 70 | inline float Length() 71 | { 72 | return sqrtf((x * x) + (y * y) + (z * z)); 73 | } 74 | 75 | __forceinline FVector Normalize() { 76 | FVector vector; 77 | float length = this->Magnitude(); 78 | 79 | if (length != 0) { 80 | vector.x = x / length; 81 | vector.y = y / length; 82 | vector.z = z / length; 83 | } 84 | else { 85 | vector.x = vector.y = 0.0f; 86 | vector.z = 1.0f; 87 | } 88 | return vector; 89 | } 90 | 91 | __forceinline FVector& operator+=(const FVector& v) { 92 | x += v.x; 93 | y += v.y; 94 | z += v.z; 95 | return *this; 96 | } 97 | }; 98 | 99 | D3DXMATRIX Matrix(FVector rot, FVector origin) 100 | { 101 | float radPitch = (rot.x * float(M_PI) / 180.f); 102 | float radYaw = (rot.y * float(M_PI) / 180.f); 103 | float radRoll = (rot.z * float(M_PI) / 180.f); 104 | 105 | float SP = sinf(radPitch); 106 | float CP = cosf(radPitch); 107 | float SY = sinf(radYaw); 108 | float CY = cosf(radYaw); 109 | float SR = sinf(radRoll); 110 | float CR = cosf(radRoll); 111 | 112 | D3DMATRIX matrix; 113 | matrix.m[0][0] = CP * CY; 114 | matrix.m[0][1] = CP * SY; 115 | matrix.m[0][2] = SP; 116 | matrix.m[0][3] = 0.f; 117 | 118 | matrix.m[1][0] = SR * SP * CY - CR * SY; 119 | matrix.m[1][1] = SR * SP * SY + CR * CY; 120 | matrix.m[1][2] = -SR * CP; 121 | matrix.m[1][3] = 0.f; 122 | 123 | matrix.m[2][0] = -(CR * SP * CY + SR * SY); 124 | matrix.m[2][1] = CY * SR - CR * SP * SY; 125 | matrix.m[2][2] = CR * CP; 126 | matrix.m[2][3] = 0.f; 127 | 128 | matrix.m[3][0] = origin.x; 129 | matrix.m[3][1] = origin.y; 130 | matrix.m[3][2] = origin.z; 131 | matrix.m[3][3] = 1.f; 132 | 133 | return matrix; 134 | } 135 | 136 | struct FQuat 137 | { 138 | float x; 139 | float y; 140 | float z; 141 | float w; 142 | }; 143 | 144 | struct FTransform 145 | { 146 | FQuat rot; 147 | FVector translation; 148 | char pad[4]; 149 | FVector scale; 150 | char pad1[4]; 151 | 152 | D3DMATRIX ToMatrixWithScale() 153 | { 154 | D3DMATRIX m; 155 | m._41 = translation.x; 156 | m._42 = translation.y; 157 | m._43 = translation.z; 158 | 159 | float x2 = rot.x + rot.x; 160 | float y2 = rot.y + rot.y; 161 | float z2 = rot.z + rot.z; 162 | 163 | float xx2 = rot.x * x2; 164 | float yy2 = rot.y * y2; 165 | float zz2 = rot.z * z2; 166 | m._11 = (1.0f - (yy2 + zz2)) * scale.x; 167 | m._22 = (1.0f - (xx2 + zz2)) * scale.y; 168 | m._33 = (1.0f - (xx2 + yy2)) * scale.z; 169 | 170 | float yz2 = rot.y * z2; 171 | float wx2 = rot.w * x2; 172 | m._32 = (yz2 - wx2) * scale.z; 173 | m._23 = (yz2 + wx2) * scale.y; 174 | 175 | float xy2 = rot.x * y2; 176 | float wz2 = rot.w * z2; 177 | m._21 = (xy2 - wz2) * scale.y; 178 | m._12 = (xy2 + wz2) * scale.x; 179 | 180 | float xz2 = rot.x * z2; 181 | float wy2 = rot.w * y2; 182 | m._31 = (xz2 + wy2) * scale.z; 183 | m._13 = (xz2 - wy2) * scale.x; 184 | 185 | m._14 = 0.0f; 186 | m._24 = 0.0f; 187 | m._34 = 0.0f; 188 | m._44 = 1.0f; 189 | 190 | return m; 191 | } 192 | }; 193 | 194 | D3DMATRIX MatrixMultiplication(D3DMATRIX pM1, D3DMATRIX pM2) 195 | { 196 | D3DMATRIX pOut; 197 | pOut._11 = pM1._11 * pM2._11 + pM1._12 * pM2._21 + pM1._13 * pM2._31 + pM1._14 * pM2._41; 198 | pOut._12 = pM1._11 * pM2._12 + pM1._12 * pM2._22 + pM1._13 * pM2._32 + pM1._14 * pM2._42; 199 | pOut._13 = pM1._11 * pM2._13 + pM1._12 * pM2._23 + pM1._13 * pM2._33 + pM1._14 * pM2._43; 200 | pOut._14 = pM1._11 * pM2._14 + pM1._12 * pM2._24 + pM1._13 * pM2._34 + pM1._14 * pM2._44; 201 | pOut._21 = pM1._21 * pM2._11 + pM1._22 * pM2._21 + pM1._23 * pM2._31 + pM1._24 * pM2._41; 202 | pOut._22 = pM1._21 * pM2._12 + pM1._22 * pM2._22 + pM1._23 * pM2._32 + pM1._24 * pM2._42; 203 | pOut._23 = pM1._21 * pM2._13 + pM1._22 * pM2._23 + pM1._23 * pM2._33 + pM1._24 * pM2._43; 204 | pOut._24 = pM1._21 * pM2._14 + pM1._22 * pM2._24 + pM1._23 * pM2._34 + pM1._24 * pM2._44; 205 | pOut._31 = pM1._31 * pM2._11 + pM1._32 * pM2._21 + pM1._33 * pM2._31 + pM1._34 * pM2._41; 206 | pOut._32 = pM1._31 * pM2._12 + pM1._32 * pM2._22 + pM1._33 * pM2._32 + pM1._34 * pM2._42; 207 | pOut._33 = pM1._31 * pM2._13 + pM1._32 * pM2._23 + pM1._33 * pM2._33 + pM1._34 * pM2._43; 208 | pOut._34 = pM1._31 * pM2._14 + pM1._32 * pM2._24 + pM1._33 * pM2._34 + pM1._34 * pM2._44; 209 | pOut._41 = pM1._41 * pM2._11 + pM1._42 * pM2._21 + pM1._43 * pM2._31 + pM1._44 * pM2._41; 210 | pOut._42 = pM1._41 * pM2._12 + pM1._42 * pM2._22 + pM1._43 * pM2._32 + pM1._44 * pM2._42; 211 | pOut._43 = pM1._41 * pM2._13 + pM1._42 * pM2._23 + pM1._43 * pM2._33 + pM1._44 * pM2._43; 212 | pOut._44 = pM1._41 * pM2._14 + pM1._42 * pM2._24 + pM1._43 * pM2._34 + pM1._44 * pM2._44; 213 | 214 | return pOut; 215 | } 216 | 217 | struct FMinimalViewInfo { 218 | FVector Location; // 0x00(0x0c) 219 | FVector Rotation; // 0x0c(0x0c) 220 | float FOV; // 0x18(0x04) 221 | }; 222 | 223 | template 224 | class TArrayDrink { 225 | 226 | public: 227 | TArrayDrink() { 228 | Data = NULL; 229 | Count = 0; 230 | Max = 0; 231 | }; 232 | 233 | T operator[](uint64_t i) const { 234 | return driver.read(((uintptr_t)Data) + i * sizeof(T)); 235 | }; 236 | 237 | T* Data; 238 | unsigned int Count; 239 | unsigned int Max; 240 | }; 241 | 242 | template 243 | class TArray 244 | { 245 | public: 246 | int Length() const 247 | { 248 | return m_nCount; 249 | } 250 | 251 | bool IsValid() const 252 | { 253 | if (m_nCount > m_nMax) 254 | return false; 255 | if (!m_Data) 256 | return false; 257 | return true; 258 | } 259 | 260 | uint64_t GetAddress() const 261 | { 262 | return m_Data; 263 | } 264 | 265 | T GetById(int i) 266 | { 267 | return driver.readv(m_Data + i * 8); 268 | } 269 | 270 | [[nodiscard]] 271 | std::vector GetIter(int maxCount = 1000) { 272 | if (m_nCount > maxCount) 273 | return {}; 274 | 275 | std::vector buffer(m_nCount); 276 | driver.readarray(m_Data, buffer.data(), m_nCount); 277 | return buffer; 278 | } 279 | 280 | protected: 281 | uint64_t m_Data; 282 | uint32_t m_nCount; 283 | uint32_t m_nMax; 284 | }; 285 | } 286 | namespace ColorStructs 287 | { 288 | 289 | typedef struct 290 | { 291 | DWORD R; 292 | DWORD G; 293 | DWORD B; 294 | DWORD A; 295 | }RGBA; 296 | 297 | class Color 298 | { 299 | public: 300 | RGBA red = { 255,0,0,255 }; 301 | RGBA Magenta = { 255,0,255,255 }; 302 | RGBA yellow = { 255,255,0,255 }; 303 | RGBA grayblue = { 128,128,255,255 }; 304 | RGBA green = { 128,224,0,255 }; 305 | RGBA darkgreen = { 0,224,128,255 }; 306 | RGBA brown = { 192,96,0,255 }; 307 | RGBA pink = { 255,168,255,255 }; 308 | RGBA DarkYellow = { 216,216,0,255 }; 309 | RGBA SilverWhite = { 236,236,236,255 }; 310 | RGBA purple = { 144,0,255,255 }; 311 | RGBA Navy = { 88,48,224,255 }; 312 | RGBA skyblue = { 0,136,255,255 }; 313 | RGBA graygreen = { 128,160,128,255 }; 314 | RGBA blue = { 0,96,192,255 }; 315 | RGBA orange = { 255,128,0,255 }; 316 | RGBA peachred = { 255,80,128,255 }; 317 | RGBA reds = { 255,128,192,255 }; 318 | RGBA darkgray = { 96,96,96,255 }; 319 | RGBA Navys = { 0,0,128,255 }; 320 | RGBA darkgreens = { 0,128,0,255 }; 321 | RGBA darkblue = { 0,128,128,255 }; 322 | RGBA redbrown = { 128,0,0,255 }; 323 | RGBA purplered = { 128,0,128,255 }; 324 | RGBA greens = { 25,255,25,140 }; 325 | RGBA envy = { 0,255,255,255 }; 326 | RGBA black = { 0,0,0,255 }; 327 | RGBA neger = { 215, 240, 180, 255 }; 328 | RGBA negernot = { 222, 180, 200, 255 }; 329 | RGBA gray = { 128,128,128,255 }; 330 | RGBA white = { 255,255,255,255 }; 331 | RGBA blues = { 30,144,255,255 }; 332 | RGBA lightblue = { 135,206,250,255 }; 333 | RGBA Scarlet = { 220, 20, 60, 160 }; 334 | RGBA white_ = { 255,255,255,200 }; 335 | RGBA gray_ = { 128,128,128,200 }; 336 | RGBA black_ = { 0,0,0,200 }; 337 | RGBA red_ = { 255,0,0,200 }; 338 | RGBA Magenta_ = { 255,0,255,200 }; 339 | RGBA yellow_ = { 255,255,0,200 }; 340 | RGBA grayblue_ = { 128,128,255,200 }; 341 | RGBA green_ = { 128,224,0,200 }; 342 | RGBA darkgreen_ = { 0,224,128,200 }; 343 | RGBA brown_ = { 192,96,0,200 }; 344 | RGBA pink_ = { 255,168,255,200 }; 345 | RGBA darkyellow_ = { 216,216,0,200 }; 346 | RGBA silverwhite_ = { 236,236,236,200 }; 347 | RGBA purple_ = { 144,0,255,200 }; 348 | RGBA Blue_ = { 88,48,224,200 }; 349 | RGBA skyblue_ = { 0,136,255,200 }; 350 | RGBA graygreen_ = { 128,160,128,200 }; 351 | RGBA blue_ = { 0,96,192,200 }; 352 | RGBA orange_ = { 255,128,0,200 }; 353 | RGBA pinks_ = { 255,80,128,200 }; 354 | RGBA Fuhong_ = { 255,128,192,200 }; 355 | RGBA darkgray_ = { 96,96,96,200 }; 356 | RGBA Navy_ = { 0,0,128,200 }; 357 | RGBA darkgreens_ = { 0,128,0,200 }; 358 | RGBA darkblue_ = { 0,128,128,200 }; 359 | RGBA redbrown_ = { 128,0,0,200 }; 360 | RGBA purplered_ = { 128,0,128,200 }; 361 | RGBA greens_ = { 0,255,0,200 }; 362 | RGBA envy_ = { 0,255,255,200 }; 363 | 364 | RGBA glassblack = { 0, 0, 0, 160 }; 365 | RGBA GlassBlue = { 65,105,225,80 }; 366 | RGBA glassyellow = { 255,255,0,160 }; 367 | RGBA glass = { 200,200,200,60 }; 368 | 369 | RGBA filled = { 0, 0, 0, 150 }; 370 | 371 | RGBA Plum = { 221,160,221,160 }; 372 | 373 | }; 374 | Color Col; 375 | } -------------------------------------------------------------------------------- /Valorant/Overlay/menu.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | auto drawmenu() -> void 4 | { 5 | if (GetAsyncKeyState(VK_INSERT) & 1) { Settings::bMenu = !Settings::bMenu; } 6 | 7 | if (Settings::bMenu) 8 | { 9 | ImGui::Begin("Valorant", NULL, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse); 10 | 11 | ImGui::SetWindowSize("Valorant", ImVec2(300, 450)); 12 | 13 | ImGui::Spacing(); 14 | 15 | ImGui::Checkbox("Enable 2D Box", &Settings::Visuals::bBox); 16 | if (Settings::Visuals::bBox) Settings::Visuals::bBoxOutlined = false; 17 | 18 | ImGui::Checkbox("Enable Cornered Box", &Settings::Visuals::bBoxOutlined); 19 | if (Settings::Visuals::bBoxOutlined) Settings::Visuals::bBox = false; 20 | 21 | ImGui::Checkbox("Enable Snaplines", &Settings::Visuals::bSnaplines); 22 | ImGui::Checkbox("Enable Distance", &Settings::Visuals::bDistance); 23 | ImGui::Checkbox("Enable HealthBar", &Settings::Visuals::bHealth); 24 | 25 | ImGui::End(); 26 | } 27 | } -------------------------------------------------------------------------------- /Valorant/Overlay/render.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "../../Includes/Imgui/imgui_internal.h" 10 | #include "../../Includes/Imgui/imgui.h" 11 | #include "../../Includes/Imgui/imgui_impl_win32.h" 12 | #include "../../Includes/Imgui/imgui_impl_dx9.h" 13 | #include "../game/globals.hpp" 14 | #include "../Game/structs.hpp" 15 | 16 | #pragma comment(lib, "d3dx9.lib") 17 | #pragma comment(lib, "d3d9.lib") 18 | #pragma comment(lib, "Dwmapi.lib") 19 | 20 | IDirect3D9Ex* p_Object = NULL; 21 | IDirect3DDevice9Ex* p_Device = NULL; 22 | D3DPRESENT_PARAMETERS p_Params = { NULL }; 23 | 24 | HWND MyWnd = NULL; 25 | HWND GameWnd = NULL; 26 | MSG Message = { NULL }; 27 | 28 | RECT GameRect = { NULL }; 29 | D3DPRESENT_PARAMETERS d3dpp; 30 | 31 | DWORD ScreenCenterX; 32 | DWORD ScreenCenterY; 33 | 34 | static ULONG Width = GetSystemMetrics(SM_CXSCREEN); 35 | static ULONG Height = GetSystemMetrics(SM_CYSCREEN); 36 | 37 | WPARAM main_loop(); 38 | void render(); 39 | 40 | void DefaultTheme() { 41 | 42 | ImGuiStyle& s = ImGui::GetStyle(); 43 | 44 | const ImColor accentCol = ImColor(255, 0, 0, 255); 45 | const ImColor bgSecondary = ImColor(255, 0, 0, 255); 46 | s.Colors[ImGuiCol_WindowBg] = ImColor(32, 32, 32, 255); 47 | s.Colors[ImGuiCol_ChildBg] = bgSecondary; 48 | s.Colors[ImGuiCol_FrameBg] = ImColor(65, 64, 64, 255); 49 | s.Colors[ImGuiCol_FrameBgActive] = ImColor(35, 37, 39, 255); 50 | s.Colors[ImGuiCol_Border] = ImColor(1, 1, 1, 255); 51 | s.Colors[ImGuiCol_CheckMark] = ImColor(255, 0, 0, 255); 52 | s.Colors[ImGuiCol_SliderGrab] = ImColor(255, 0, 0, 255); 53 | s.Colors[ImGuiCol_SliderGrab] = ImColor(255, 0, 0, 255); 54 | s.Colors[ImGuiCol_SliderGrabActive] = ImColor(255, 0, 0, 255); 55 | s.Colors[ImGuiCol_ResizeGrip] = ImColor(24, 24, 24, 255); 56 | s.Colors[ImGuiCol_Header] = ImColor(0, 0, 0, 255); 57 | s.Colors[ImGuiCol_HeaderHovered] = ImColor(0, 0, 0, 255); 58 | s.Colors[ImGuiCol_HeaderActive] = ImColor(0, 0, 0, 255); 59 | s.Colors[ImGuiCol_TitleBg] = ImColor(0, 0, 0, 255); 60 | s.Colors[ImGuiCol_TitleBgCollapsed] = ImColor(0, 0, 0, 255); 61 | s.Colors[ImGuiCol_TitleBgActive] = ImColor(0, 0, 0, 255); 62 | s.Colors[ImGuiCol_FrameBgHovered] = ImColor(65, 64, 64, 255); 63 | s.Colors[ImGuiCol_ScrollbarBg] = ImColor(0, 0, 0, 255); 64 | s.Colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.80f, 0.80f, 0.83f, 0.31f); 65 | s.Colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.56f, 0.56f, 0.58f, 1.00f); 66 | s.Colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.06f, 0.05f, 0.07f, 1.00f); 67 | s.Colors[ImGuiCol_Header] = ImColor(42, 42, 42, 255); 68 | s.Colors[ImGuiCol_HeaderHovered] = ImColor(50, 50, 50, 255); 69 | s.Colors[ImGuiCol_HeaderActive] = ImColor(50, 50, 50, 255); 70 | s.Colors[ImGuiCol_PopupBg] = ImColor(15, 15, 15, 255); 71 | s.Colors[ImGuiCol_Button] = ImColor(30, 30, 30, 255); 72 | s.Colors[ImGuiCol_ButtonHovered] = ImColor(30, 30, 30, 255); 73 | s.Colors[ImGuiCol_ButtonActive] = ImColor(30, 30, 30, 255); 74 | s.Colors[ImGuiCol_Text] = ImColor(255, 255, 255, 255); 75 | 76 | s.AntiAliasedFill = true; 77 | s.AntiAliasedLines = true; 78 | 79 | s.ChildRounding = 0.0f; 80 | s.FrameBorderSize = 1.0f; 81 | s.FrameRounding = 0.0f; 82 | s.PopupRounding = 0.0f; 83 | s.ScrollbarRounding = 0.0f; 84 | s.ScrollbarSize = 0.0f; 85 | s.TabRounding = 0.0f; 86 | s.WindowRounding = 0.0f; 87 | 88 | } 89 | 90 | auto init_wndparams(HWND hWnd) -> HRESULT 91 | { 92 | if (FAILED(Direct3DCreate9Ex(D3D_SDK_VERSION, &p_Object))) 93 | exit(3); 94 | 95 | ZeroMemory(&p_Params, sizeof(p_Params)); 96 | p_Params.Windowed = TRUE; 97 | p_Params.SwapEffect = D3DSWAPEFFECT_DISCARD; 98 | p_Params.hDeviceWindow = hWnd; 99 | p_Params.MultiSampleQuality = D3DMULTISAMPLE_NONE; 100 | p_Params.BackBufferFormat = D3DFMT_A8R8G8B8; 101 | p_Params.BackBufferWidth = Width; 102 | p_Params.BackBufferHeight = Height; 103 | p_Params.EnableAutoDepthStencil = TRUE; 104 | p_Params.AutoDepthStencilFormat = D3DFMT_D16; 105 | p_Params.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; 106 | 107 | if (FAILED(p_Object->CreateDeviceEx(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &p_Params, 0, &p_Device))) { 108 | p_Object->Release(); 109 | exit(4); 110 | } 111 | 112 | IMGUI_CHECKVERSION(); 113 | ImGui::CreateContext(); 114 | 115 | ImGuiIO& io = ImGui::GetIO(); (void)io; 116 | ImGuiStyle& s = ImGui::GetStyle(); 117 | io.IniFilename = NULL; 118 | 119 | DefaultTheme(); 120 | 121 | ImGui_ImplWin32_Init(hWnd); 122 | ImGui_ImplDX9_Init(p_Device); 123 | return S_OK; 124 | } 125 | 126 | auto get_process_wnd(uint32_t pid) -> HWND 127 | { 128 | std::pair params = { 0, pid }; 129 | BOOL bResult = EnumWindows([](HWND hwnd, LPARAM lParam) -> BOOL { 130 | auto pParams = (std::pair*)(lParam); 131 | uint32_t processId = 0; 132 | 133 | if (GetWindowThreadProcessId(hwnd, reinterpret_cast(&processId)) && processId == pParams->second) { 134 | SetLastError((uint32_t)-1); 135 | pParams->first = hwnd; 136 | return FALSE; 137 | } 138 | 139 | return TRUE; 140 | 141 | }, (LPARAM)¶ms); 142 | 143 | if (!bResult && GetLastError() == -1 && params.first) 144 | return params.first; 145 | 146 | return NULL; 147 | } 148 | 149 | auto cleanup_d3d() -> void 150 | { 151 | if (p_Device != NULL) { 152 | p_Device->EndScene(); 153 | p_Device->Release(); 154 | } 155 | if (p_Object != NULL) { 156 | p_Object->Release(); 157 | } 158 | } 159 | 160 | auto set_window_target() -> void 161 | { 162 | while (true) { 163 | GameWnd = get_process_wnd(processid); 164 | if (GameWnd) { 165 | ZeroMemory(&GameRect, sizeof(GameRect)); 166 | GetWindowRect(GameWnd, &GameRect); 167 | DWORD dwStyle = GetWindowLong(GameWnd, GWL_STYLE); 168 | if (dwStyle & WS_BORDER) 169 | { 170 | GameRect.top += 32; 171 | Height -= 39; 172 | } 173 | ScreenCenterX = Width / 2; 174 | ScreenCenterY = Height / 2; 175 | MoveWindow(MyWnd, GameRect.left, GameRect.top, Width, Height, true); 176 | } 177 | } 178 | } 179 | 180 | auto setup_window() -> void 181 | { 182 | CreateThread(0, 0, (LPTHREAD_START_ROUTINE)set_window_target, 0, 0, 0); 183 | 184 | WNDCLASSEXA wcex = { 185 | sizeof(WNDCLASSEXA), 186 | 0, 187 | DefWindowProcA, 188 | 0, 189 | 0, 190 | nullptr, 191 | LoadIcon(nullptr, IDI_APPLICATION), 192 | LoadCursor(nullptr, IDC_ARROW), 193 | nullptr, 194 | nullptr, 195 | ("MirakaKindaCuteNgl"), 196 | LoadIcon(nullptr, IDI_APPLICATION) 197 | }; 198 | 199 | RECT Rect; 200 | GetWindowRect(GetDesktopWindow(), &Rect); 201 | 202 | RegisterClassExA(&wcex); 203 | 204 | MyWnd = CreateWindowExA(NULL, ("MirakaKindaCuteNgl"), ("MirakaKindaCuteNgl"), WS_POPUP, Rect.left, Rect.top, Rect.right, Rect.bottom, NULL, NULL, wcex.hInstance, NULL); 205 | SetWindowLong(MyWnd, GWL_EXSTYLE, WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW); 206 | SetLayeredWindowAttributes(MyWnd, RGB(0, 0, 0), 255, LWA_ALPHA); 207 | 208 | MARGINS margin = { -1 }; 209 | DwmExtendFrameIntoClientArea(MyWnd, &margin); 210 | 211 | ShowWindow(MyWnd, SW_SHOW); 212 | UpdateWindow(MyWnd); 213 | } 214 | 215 | using namespace ColorStructs; 216 | 217 | void DrawFilledRect(int x, int y, int w, int h, RGBA* color) 218 | { 219 | ImGui::GetForegroundDrawList()->AddRectFilled(ImVec2(x, y), ImVec2(x + w, y + h), ImGui::ColorConvertFloat4ToU32(ImVec4(color->R / 255.0, color->G / 153.0, color->B / 51.0, color->A / 255.0)), 0, 0); 220 | } 221 | 222 | void DrawFilledRect2(int x, int y, int w, int h, ImColor color) 223 | { 224 | ImGui::GetForegroundDrawList()->AddRectFilled(ImVec2(x, y), ImVec2(x + w, y + h), color, 0, 0); 225 | } 226 | 227 | void DrawCornerBox(float x, float y, float w, float h, const ImColor& color) 228 | { 229 | ImGui::GetForegroundDrawList()->AddLine(ImVec2(x, y), ImVec2(x + w / 4.f, y), color); 230 | ImGui::GetForegroundDrawList()->AddLine(ImVec2(x, y), ImVec2(x, y + h / 4.f), color); 231 | 232 | ImGui::GetForegroundDrawList()->AddLine(ImVec2(x + w, y), ImVec2(x + w - w / 4.f, y), color); 233 | ImGui::GetForegroundDrawList()->AddLine(ImVec2(x + w, y), ImVec2(x + w, y + h / 4.f), color); 234 | 235 | ImGui::GetForegroundDrawList()->AddLine(ImVec2(x, y + h), ImVec2(x + w / 4.f, y + h), color); 236 | ImGui::GetForegroundDrawList()->AddLine(ImVec2(x, y + h), ImVec2(x, y + h - h / 4.f), color); 237 | 238 | ImGui::GetForegroundDrawList()->AddLine(ImVec2(x + w, y + h), ImVec2(x + w, y + h - h / 4.f), color); 239 | ImGui::GetForegroundDrawList()->AddLine(ImVec2(x + w, y + h), ImVec2(x + w - w / 4.f, y + h), color); 240 | } 241 | 242 | void DrawNormalBox(int x, int y, int w, int h, int borderPx, ImColor color) 243 | { 244 | DrawFilledRect2(x + borderPx, y, w, borderPx, color); 245 | DrawFilledRect2(x + w - w + borderPx, y, w, borderPx, color); 246 | DrawFilledRect2(x, y, borderPx, h, color); 247 | DrawFilledRect2(x, y + h - h + borderPx * 2, borderPx, h, color); 248 | DrawFilledRect2(x + borderPx, y + h + borderPx, w, borderPx, color); 249 | DrawFilledRect2(x + w - w + borderPx, y + h + borderPx, w, borderPx, color); 250 | DrawFilledRect2(x + w + borderPx, y, borderPx, h, color); 251 | DrawFilledRect2(x + w + borderPx, y + h - h + borderPx * 2, borderPx, h, color); 252 | } 253 | 254 | using namespace UE4Structs; 255 | 256 | auto Draw2DBox(FVector RootPosition, float Width, float Height, ImColor Color) -> void 257 | { 258 | DrawNormalBox(RootPosition.x - Width / 2, RootPosition.y - Height / 2, Width, Height, Settings::Visuals::BoxWidth, Color); 259 | } 260 | 261 | void DrawRect(int x, int y, int w, int h, RGBA* color, int thickness) 262 | { 263 | ImGui::GetForegroundDrawList()->AddRect(ImVec2(x, y), ImVec2(x + w, y + h), ImGui::ColorConvertFloat4ToU32(ImVec4(color->R / 255.0, color->G / 255.0, color->B / 255.0, color->A / 255.0)), 0, 0, thickness); 264 | } 265 | 266 | auto DrawOutlinedBox(FVector RootPosition, float Width, float Height, ImColor Color) -> void 267 | { 268 | DrawCornerBox(RootPosition.x - Width / 2, RootPosition.y - Height / 2, Width, Height, Color); 269 | DrawCornerBox(RootPosition.x - Width / 2 - 1, RootPosition.y - Height / 2 - 1, Width, Height, ImColor(0, 0, 0)); 270 | DrawCornerBox(RootPosition.x - Width / 2 + 1, RootPosition.y - Height / 2 + 1, Width, Height, ImColor(0, 0, 0)); 271 | } 272 | 273 | auto DrawDistance(FVector Location, float Distance) -> void 274 | { 275 | char dist[64]; 276 | sprintf_s(dist, "%.fm", Distance); 277 | 278 | ImVec2 TextSize = ImGui::CalcTextSize(dist); 279 | ImGui::GetForegroundDrawList()->AddText(ImVec2(Location.x - TextSize.x / 2, Location.y - TextSize.y / 2), ImGui::GetColorU32({ 255, 255, 255, 255 }), dist); 280 | } 281 | 282 | auto DrawTracers(FVector Target, ImColor Color) -> void 283 | { 284 | ImGui::GetForegroundDrawList()->AddLine( 285 | ImVec2(ScreenCenterX, Height), 286 | ImVec2(Target.x, Target.y), 287 | Color, 288 | 0.1f 289 | ); 290 | } 291 | 292 | auto DrawHealthBar(FVector RootPosition, float Width, float Height, float Health, float RelativeDistance)-> void 293 | { 294 | auto HPBoxWidth = 1 / RelativeDistance; 295 | 296 | auto HPBox_X = RootPosition.x - Width / 2 - 5 - HPBoxWidth; 297 | auto HPBox_Y = RootPosition.y - Height / 2 + (Height - Height * (Health / 100)); 298 | 299 | int HPBoxHeight = Height * (Health / 100); 300 | 301 | DrawFilledRect(HPBox_X, HPBox_Y, HPBoxWidth, HPBoxHeight, &ColorStructs::Col.green); 302 | DrawRect(HPBox_X - 1, HPBox_Y - 1, HPBoxWidth + 2, HPBoxHeight + 2, &ColorStructs::Col.black, 1); 303 | } -------------------------------------------------------------------------------- /Valorant/Valorant.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {101afe41-beeb-4fb0-816c-0c4e5283a567} 25 | PixelFortnite 26 | 10.0 27 | Valorant 28 | 29 | 30 | 31 | Application 32 | true 33 | v143 34 | Unicode 35 | 36 | 37 | Application 38 | false 39 | v143 40 | true 41 | Unicode 42 | 43 | 44 | Application 45 | true 46 | v143 47 | Unicode 48 | 49 | 50 | Application 51 | false 52 | v142 53 | true 54 | Unicode 55 | false 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | true 77 | 78 | 79 | false 80 | 81 | 82 | true 83 | 84 | 85 | false 86 | ..\Includes\Direct3d;$(IncludePath) 87 | ..\Includes\Direct3d;$(LibraryPath) 88 | 89 | 90 | 91 | Level3 92 | true 93 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 94 | true 95 | 96 | 97 | Console 98 | true 99 | 100 | 101 | 102 | 103 | Level3 104 | true 105 | true 106 | true 107 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 108 | true 109 | 110 | 111 | Console 112 | true 113 | true 114 | true 115 | 116 | 117 | 118 | 119 | Level3 120 | true 121 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 122 | true 123 | 124 | 125 | Console 126 | true 127 | 128 | 129 | 130 | 131 | TurnOffAllWarnings 132 | true 133 | true 134 | true 135 | NDEBUG;_CONSOLE;CURL_STATICLIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 136 | true 137 | stdcpp17 138 | false 139 | %(AdditionalIncludeDirectories) 140 | 141 | 142 | Console 143 | true 144 | true 145 | true 146 | RequireAdministrator 147 | C:\Users\MellowNight\Desktop\VALORANTGR\UE4 Usermode\Includes\ProxineAuth\curl;%(AdditionalLibraryDirectories) 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | -------------------------------------------------------------------------------- /Valorant/Valorant.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Framework 7 | 8 | 9 | Framework 10 | 11 | 12 | Framework 13 | 14 | 15 | Framework 16 | 17 | 18 | Framework 19 | 20 | 21 | Framework 22 | 23 | 24 | Framework 25 | 26 | 27 | 28 | 29 | Game 30 | 31 | 32 | Game 33 | 34 | 35 | Game 36 | 37 | 38 | Game 39 | 40 | 41 | Framework 42 | 43 | 44 | Framework 45 | 46 | 47 | Framework 48 | 49 | 50 | Framework 51 | 52 | 53 | Framework 54 | 55 | 56 | Framework 57 | 58 | 59 | Framework 60 | 61 | 62 | Framework 63 | 64 | 65 | Overlay 66 | 67 | 68 | Overlay 69 | 70 | 71 | Driver 72 | 73 | 74 | 75 | 76 | {ed75c461-8a8c-41e2-9551-a85b4de83294} 77 | 78 | 79 | {a5b155fc-b019-457e-a4d7-c391f30143d0} 80 | 81 | 82 | {7d2a3ee2-ed36-43a4-81ec-8059b47d6c41} 83 | 84 | 85 | {39406d82-fe78-47f5-8e04-b83774d34cd4} 86 | 87 | 88 | -------------------------------------------------------------------------------- /Valorant/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "overlay/render.hpp" 8 | #include "overlay/menu.hpp" 9 | 10 | #include "game/cheat.hpp" 11 | 12 | #include 13 | #include 14 | 15 | #include "driver/driver.hpp" 16 | 17 | DWORD GetProcessID(const std::wstring processName) 18 | { 19 | PROCESSENTRY32 processInfo; 20 | processInfo.dwSize = sizeof(processInfo); 21 | 22 | HANDLE processesSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL); 23 | if (processesSnapshot == INVALID_HANDLE_VALUE) 24 | { 25 | return 0; 26 | } 27 | 28 | Process32First(processesSnapshot, &processInfo); 29 | if (!processName.compare(processInfo.szExeFile)) 30 | { 31 | CloseHandle(processesSnapshot); 32 | return processInfo.th32ProcessID; 33 | } 34 | 35 | while (Process32Next(processesSnapshot, &processInfo)) 36 | { 37 | if (!processName.compare(processInfo.szExeFile)) 38 | { 39 | CloseHandle(processesSnapshot); 40 | return processInfo.th32ProcessID; 41 | } 42 | } 43 | 44 | CloseHandle(processesSnapshot); 45 | return 0; 46 | } 47 | 48 | int main() 49 | { 50 | while (Entryhwnd == NULL) 51 | { 52 | printf("Waiting for Valorant...\r"); 53 | Sleep(1); 54 | processid = GetProcessID(L"VALORANT-Win64-Shipping.exe"); 55 | Entryhwnd = get_process_wnd(processid); 56 | Sleep(1); 57 | } 58 | 59 | driver.initdriver(processid); 60 | 61 | setup_window(); 62 | init_wndparams(MyWnd); 63 | 64 | std::thread(CacheGame).detach(); 65 | 66 | while (true) main_loop(); 67 | 68 | exit(0); 69 | } 70 | 71 | auto render() -> void 72 | { 73 | ImGui_ImplDX9_NewFrame(); 74 | ImGui_ImplWin32_NewFrame(); 75 | ImGui::NewFrame(); 76 | 77 | CheatLoop(); 78 | drawmenu(); 79 | 80 | ImGui::EndFrame(); 81 | p_Device->SetRenderState(D3DRS_ZENABLE, false); 82 | p_Device->SetRenderState(D3DRS_ALPHABLENDENABLE, false); 83 | p_Device->SetRenderState(D3DRS_SCISSORTESTENABLE, false); 84 | p_Device->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0, 0, 0, 0), 1.0f, 0); 85 | 86 | if (p_Device->BeginScene() >= 0) 87 | { 88 | ImGui::Render(); 89 | ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData()); 90 | p_Device->EndScene(); 91 | } 92 | 93 | HRESULT result = p_Device->Present(NULL, NULL, NULL, NULL); 94 | 95 | if (result == D3DERR_DEVICELOST && p_Device->TestCooperativeLevel() == D3DERR_DEVICENOTRESET) 96 | { 97 | ImGui_ImplDX9_InvalidateDeviceObjects(); 98 | p_Device->Reset(&d3dpp); 99 | ImGui_ImplDX9_CreateDeviceObjects(); 100 | } 101 | } 102 | 103 | auto main_loop() -> WPARAM 104 | { 105 | static RECT old_rc; 106 | ZeroMemory(&Message, sizeof(MSG)); 107 | 108 | while (Message.message != WM_QUIT) 109 | { 110 | if (PeekMessage(&Message, MyWnd, 0, 0, PM_REMOVE)) { 111 | TranslateMessage(&Message); 112 | DispatchMessage(&Message); 113 | } 114 | 115 | HWND hwnd_active = GetForegroundWindow(); 116 | if (GetAsyncKeyState(0x23) & 1) 117 | exit(8); 118 | 119 | if (hwnd_active == GameWnd) { 120 | HWND hwndtest = GetWindow(hwnd_active, GW_HWNDPREV); 121 | SetWindowPos(MyWnd, hwndtest, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); 122 | } 123 | RECT rc; 124 | POINT xy; 125 | 126 | ZeroMemory(&rc, sizeof(RECT)); 127 | ZeroMemory(&xy, sizeof(POINT)); 128 | GetClientRect(GameWnd, &rc); 129 | ClientToScreen(GameWnd, &xy); 130 | rc.left = xy.x; 131 | rc.top = xy.y; 132 | 133 | ImGuiIO& io = ImGui::GetIO(); 134 | io.ImeWindowHandle = GameWnd; 135 | io.DeltaTime = 1.0f / 60.0f; 136 | 137 | POINT p; 138 | GetCursorPos(&p); 139 | io.MousePos.x = p.x - xy.x; 140 | io.MousePos.y = p.y - xy.y; 141 | 142 | if (GetAsyncKeyState(0x1)) { 143 | io.MouseDown[0] = true; 144 | io.MouseClicked[0] = true; 145 | io.MouseClickedPos[0].x = io.MousePos.x; 146 | io.MouseClickedPos[0].x = io.MousePos.y; 147 | } 148 | else io.MouseDown[0] = false; 149 | 150 | if (rc.left != old_rc.left || rc.right != old_rc.right || rc.top != old_rc.top || rc.bottom != old_rc.bottom) { 151 | 152 | old_rc = rc; 153 | 154 | Width = rc.right; 155 | Height = rc.bottom; 156 | 157 | p_Params.BackBufferWidth = Width; 158 | p_Params.BackBufferHeight = Height; 159 | SetWindowPos(MyWnd, (HWND)0, xy.x, xy.y, Width, Height, SWP_NOREDRAW); 160 | p_Device->Reset(&p_Params); 161 | } 162 | render(); 163 | } 164 | 165 | ImGui_ImplDX9_Shutdown(); 166 | ImGui_ImplWin32_Shutdown(); 167 | ImGui::DestroyContext(); 168 | 169 | cleanup_d3d(); 170 | DestroyWindow(MyWnd); 171 | 172 | return Message.wParam; 173 | } --------------------------------------------------------------------------------