d3d8_main.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* Direct3D 8
  2. *
  3. * This library is free software; you can redistribute it and/or
  4. * modify it under the terms of the GNU Lesser General Public
  5. * License as published by the Free Software Foundation; either
  6. * version 2.1 of the License, or (at your option) any later version.
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * Lesser General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Lesser General Public
  14. * License along with this library; if not, write to the Free Software
  15. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. *
  17. */
  18. #include "config.h"
  19. #include <stdarg.h>
  20. #include "windef.h"
  21. #include "winbase.h"
  22. #include "winreg.h"
  23. #include "wingdi.h"
  24. #include "winuser.h"
  25. #include "wine/debug.h"
  26. #include "d3d8.h"
  27. #include "d3d8_private.h"
  28. WINE_DEFAULT_DEBUG_CHANNEL(d3d);
  29. int num_lock = 0;
  30. void (*wine_tsx11_lock_ptr)(void) = NULL;
  31. void (*wine_tsx11_unlock_ptr)(void) = NULL;
  32. int vs_mode = VS_HW; /* Hardware by default */
  33. int ps_mode = PS_NONE; /* Disabled by default */
  34. HRESULT WINAPI D3D8GetSWInfo(void)
  35. {
  36. FIXME("(void): stub\n");
  37. return 0;
  38. }
  39. void WINAPI DebugSetMute(void)
  40. {
  41. /* nothing to do */
  42. }
  43. IDirect3D8* WINAPI Direct3DCreate8(UINT SDKVersion)
  44. {
  45. IDirect3D8Impl *object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3D8Impl));
  46. object->lpVtbl = &Direct3D8_Vtbl;
  47. object->direct3d8 = object;
  48. object->ref = 1;
  49. object->WineD3D = WineDirect3DCreate(SDKVersion, 8, (IUnknown *)object);
  50. TRACE("SDKVersion = %x, Created Direct3D object @ %p, WineObj @ %p\n", SDKVersion, object, object->WineD3D);
  51. return (IDirect3D8 *)object;
  52. }
  53. /* At process attach */
  54. BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
  55. {
  56. TRACE("D3D8 DLLMain Reason=%ld\n", fdwReason);
  57. if (fdwReason == DLL_PROCESS_ATTACH)
  58. {
  59. HMODULE mod;
  60. char buffer[32];
  61. DWORD size = sizeof(buffer);
  62. HKEY hkey = 0;
  63. DisableThreadLibraryCalls(hInstDLL);
  64. mod = GetModuleHandleA( "x11drv.dll" );
  65. if (mod)
  66. {
  67. wine_tsx11_lock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_lock" );
  68. wine_tsx11_unlock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_unlock" );
  69. }
  70. if ( !RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Direct3D", &hkey) )
  71. {
  72. if ( !RegQueryValueExA( hkey, "VertexShaderMode", 0, NULL, buffer, &size) )
  73. {
  74. if (!strcmp(buffer,"none"))
  75. {
  76. TRACE("Disable vertex shaders\n");
  77. vs_mode = VS_NONE;
  78. }
  79. else if (!strcmp(buffer,"emulation"))
  80. {
  81. TRACE("Force SW vertex shaders\n");
  82. vs_mode = VS_SW;
  83. }
  84. }
  85. if ( !RegQueryValueExA( hkey, "PixelShaderMode", 0, NULL, buffer, &size) )
  86. {
  87. if (!strcmp(buffer,"enabled"))
  88. {
  89. TRACE("Allow pixel shaders\n");
  90. ps_mode = PS_HW;
  91. }
  92. }
  93. }
  94. if (vs_mode == VS_HW)
  95. TRACE("Allow HW vertex shaders\n");
  96. if (ps_mode == PS_NONE)
  97. TRACE("Disable pixel shaders\n");
  98. }
  99. return TRUE;
  100. }