support.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. LICENSE
  3. -------
  4. Copyright 2005-2013 Nullsoft, Inc.
  5. All rights reserved.
  6. Redistribution and use in source and binary forms, with or without modification,
  7. are permitted provided that the following conditions are met:
  8. * Redistributions of source code must retain the above copyright notice,
  9. this list of conditions and the following disclaimer.
  10. * Redistributions in binary form must reproduce the above copyright notice,
  11. this list of conditions and the following disclaimer in the documentation
  12. and/or other materials provided with the distribution.
  13. * Neither the name of Nullsoft nor the names of its contributors may be used to
  14. endorse or promote products derived from this software without specific prior written permission.
  15. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
  16. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  17. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  18. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  19. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  20. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  21. IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  22. OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. */
  24. #ifndef __NULLSOFT_DX9_EXAMPLE_PLUGIN_SUPPORT_H__
  25. #define __NULLSOFT_DX9_EXAMPLE_PLUGIN_SUPPORT_H__ 1
  26. #include <d3dx9.h>
  27. void MakeWorldMatrix( D3DXMATRIX* pOut,
  28. float xpos, float ypos, float zpos,
  29. float sx, float sy, float sz,
  30. float pitch, float yaw, float roll);
  31. void MakeProjectionMatrix( D3DXMATRIX* pOut,
  32. const float near_plane, // Distance to near clipping plane
  33. const float far_plane, // Distance to far clipping plane
  34. const float fov_horiz, // Horizontal field of view angle, in radians
  35. const float fov_vert); // Vertical field of view angle, in radians
  36. void PrepareFor3DDrawing(
  37. IDirect3DDevice9 *pDevice,
  38. int viewport_width,
  39. int viewport_height,
  40. float fov_in_degrees,
  41. float near_clip,
  42. float far_clip,
  43. D3DXVECTOR3* pvEye,
  44. D3DXVECTOR3* pvLookat,
  45. D3DXVECTOR3* pvUp
  46. );
  47. void PrepareFor2DDrawing(IDirect3DDevice9 *pDevice);
  48. // Define vertex formats you'll be using here:
  49. // note: layout must match the vertex declaration in plugin.cpp!
  50. typedef struct _MYVERTEX
  51. {
  52. float x, y, z; // screen position + Z-buffer depth
  53. DWORD Diffuse; // diffuse color
  54. float tu, tv; // DYNAMIC
  55. float tu_orig, tv_orig; // STATIC
  56. float rad, ang; // STATIC
  57. } MYVERTEX, *LPMYVERTEX;
  58. // note: layout must match the vertex declaration in plugin.cpp!
  59. typedef struct _WFVERTEX
  60. {
  61. float x, y, z;
  62. DWORD Diffuse; // diffuse color. also acts as filler; aligns struct to 16 bytes (good for random access/indexed prims)
  63. } WFVERTEX, *LPWFVERTEX;
  64. // note: layout must match the vertex declaration in plugin.cpp!
  65. typedef struct _SPRITEVERTEX
  66. {
  67. float x, y; // screen position
  68. float z; // Z-buffer depth
  69. DWORD Diffuse; // diffuse color. also acts as filler; aligns struct to 16 bytes (good for random access/indexed prims)
  70. float tu, tv; // texture coordinates for texture #0
  71. } SPRITEVERTEX, *LPSPRITEVERTEX;
  72. // Also prepare vertex format descriptors for each
  73. // of the 3 kinds of vertices we'll be using:
  74. // note: D3DFVF_TEXCOORDSIZEm(n): m = the dimension, n = the index
  75. // AVOID D3DFVF_TEXCOORDSIZE4 - I've seen probs (blending between shader and non-shader presets) on vaio laptop w/6200!
  76. #define MYVERTEX_FORMAT (D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX3 | D3DFVF_TEXCOORDSIZE2(0) | D3DFVF_TEXCOORDSIZE2(1) | D3DFVF_TEXCOORDSIZE2(2))
  77. #define WFVERTEX_FORMAT (D3DFVF_XYZ | D3DFVF_DIFFUSE )
  78. #define SPRITEVERTEX_FORMAT (D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE2(0) )
  79. void GetWinampSongTitle(HWND hWndWinamp, wchar_t *szSongTitle, int nSize);
  80. void GetWinampSongPosAsText(HWND hWndWinamp, wchar_t *szSongPos);
  81. void GetWinampSongLenAsText(HWND hWndWinamp, wchar_t *szSongLen);
  82. float GetWinampSongPos(HWND hWndWinamp); // returns answer in seconds
  83. float GetWinampSongLen(HWND hWndWinamp); // returns answer in seconds
  84. //#define PROFILING
  85. #ifdef PROFILING
  86. #define PROFILE_BEGIN LARGE_INTEGER tx, freq, ty; QueryPerformanceCounter(&tx); QueryPerformanceFrequency(&freq);
  87. #define PROFILE_END(s) { QueryPerformanceCounter(&ty); float dt = (float)((double)(ty.QuadPart - tx.QuadPart) / (double)freq.QuadPart); char buf[256]; sprintf(buf, " %s = %.1f ms\n", s, dt*1000 ); OutputDebugString(buf); tx = ty; }
  88. #else
  89. #define PROFILE_BEGIN
  90. #define PROFILE_END(s)
  91. #endif
  92. int GetDX9TexFormatBitsPerPixel(D3DFORMAT fmt);
  93. #endif