46#define WW3D_DEVTYPE D3DDEVTYPE_HAL
102static HWND _Hwnd =
NULL;
182static unsigned last_frame_matrix_changes = 0;
183static unsigned last_frame_material_changes = 0;
184static unsigned last_frame_vertex_buffer_changes = 0;
185static unsigned last_frame_index_buffer_changes = 0;
186static unsigned last_frame_light_changes = 0;
187static unsigned last_frame_texture_changes = 0;
188static unsigned last_frame_render_state_changes = 0;
189static unsigned last_frame_texture_stage_state_changes = 0;
190static unsigned last_frame_number_of_DX8_calls = 0;
191static unsigned last_frame_draw_calls = 0;
193static D3DDISPLAYMODE DesktopMode;
195static D3DPRESENT_PARAMETERS _PresentParameters;
207DX8_Stats DX8Wrapper::stats;
219 HRESULT new_res=D3DXGetErrorStringA(
224 if (new_res==D3D_OK) {
235 HRESULT new_res=D3DXGetErrorStringA(
240 if (new_res==D3D_OK) {
241 WWDEBUG_SAY((
"DX8 Error: %s, File: %s, Line: %d\n",tmp,file,line));
277 ::ZeroMemory(&
old_world,
sizeof(D3DMATRIX));
278 ::ZeroMemory(&
old_view,
sizeof(D3DMATRIX));
279 ::ZeroMemory(&
old_prj,
sizeof(D3DMATRIX));
297 D3D8Lib = LoadLibrary(
"D3D8.DLL");
342 for (
int i = 0; i <
max; i++)
362 _RenderDeviceNameTable.Clear();
363 _RenderDeviceShortNameTable.Clear();
364 _RenderDeviceDescriptionTable.Clear();
423 return (hRes == D3D_OK);
436 for (
int b=0; b<32;b++)
456 for (
int i=0; i<D3DTS_WORLD+1; i++) {
531 D3DENUM_NO_WHQL_LEVEL,
543 D3DCREATE_MIXED_VERTEXPROCESSING : D3DCREATE_SOFTWARE_VERTEXPROCESSING;
555#ifdef CREATE_DX8_MULTI_THREADED
565#ifdef CREATE_DX8_FPU_PRESERVE
584 if ((_PresentParameters.BackBufferFormat==D3DFMT_R5G6B5 ||
585 _PresentParameters.BackBufferFormat==D3DFMT_X1R5G5B5 ||
586 _PresentParameters.BackBufferFormat==D3DFMT_A1R5G5B5) &&
587 (_PresentParameters.AutoDepthStencilFormat==D3DFMT_D32 ||
588 _PresentParameters.AutoDepthStencilFormat==D3DFMT_D24S8 ||
589 _PresentParameters.AutoDepthStencilFormat==D3DFMT_D24X8))
591 _PresentParameters.AutoDepthStencilFormat=D3DFMT_D16;
648 if (hr != D3DERR_DEVICELOST )
716 for (
int adapter_index=0; adapter_index<adapter_count; adapter_index++) {
718 D3DADAPTER_IDENTIFIER8 id;
719 ::ZeroMemory(&
id,
sizeof(D3DADAPTER_IDENTIFIER8));
720 HRESULT res =
D3DInterface->GetAdapterIdentifier(adapter_index,D3DENUM_NO_WHQL_LEVEL,&
id);
729 desc.set_device_name(
id.Description);
730 desc.set_driver_name(
id.Driver);
733 sprintf(buf,
"%d.%d.%d.%d",
734 HIWORD(
id.DriverVersion.HighPart),
735 LOWORD(
id.DriverVersion.HighPart),
736 HIWORD(
id.DriverVersion.LowPart),
737 LOWORD(
id.DriverVersion.LowPart));
739 desc.set_driver_version(buf);
742 D3DInterface->GetAdapterIdentifier(adapter_index,D3DENUM_NO_WHQL_LEVEL,&desc.AdapterIdentifier);
749 desc.reset_resolution_list();
750 int mode_count =
D3DInterface->GetAdapterModeCount(adapter_index);
751 for (
int mode_index=0; mode_index<mode_count; mode_index++) {
752 D3DDISPLAYMODE d3dmode;
753 ::ZeroMemory(&d3dmode,
sizeof(D3DDISPLAYMODE));
754 HRESULT res =
D3DInterface->EnumAdapterModes(adapter_index,mode_index,&d3dmode);
758 switch (d3dmode.Format)
761 case D3DFMT_A8R8G8B8:
762 case D3DFMT_X8R8G8B8: bits = 32;
break;
765 case D3DFMT_X1R5G5B5: bits = 16;
break;
778 desc.add_resolution(d3dmode.Width,d3dmode.Height,bits);
791 _RenderDeviceNameTable.Add(device_name);
792 _RenderDeviceShortNameTable.Add(device_name);
797 _RenderDeviceDescriptionTable.Add(desc);
806 for (
int dev_number = 0; dev_number < _RenderDeviceNameTable.Count(); dev_number++) {
813 for (dev_number = 0; dev_number < _RenderDeviceNameTable.Count(); dev_number++) {
824 const char * dev_name,
832 for (
int dev_number = 0; dev_number < _RenderDeviceNameTable.Count(); dev_number++) {
833 if ( strcmp( dev_name, _RenderDeviceNameTable[dev_number]) == 0) {
834 return Set_Render_Device( dev_number, width, height, bits, windowed, resize_window );
837 if ( strcmp( dev_name, _RenderDeviceShortNameTable[dev_number]) == 0) {
838 return Set_Render_Device( dev_number, width, height, bits, windowed, resize_window );
846 *tex_format=
"Unknown";
848 case D3DFMT_A8R8G8B8: *tex_format=
"D3DFMT_A8R8G8B8";
break;
849 case D3DFMT_R8G8B8: *tex_format=
"D3DFMT_R8G8B8";
break;
850 case D3DFMT_A4R4G4B4: *tex_format=
"D3DFMT_A4R4G4B4";
break;
851 case D3DFMT_A1R5G5B5: *tex_format=
"D3DFMT_A1R5G5B5";
break;
852 case D3DFMT_R5G6B5: *tex_format=
"D3DFMT_R5G6B5";
break;
853 case D3DFMT_L8: *tex_format=
"D3DFMT_L8";
break;
854 case D3DFMT_A8: *tex_format=
"D3DFMT_A8";
break;
855 case D3DFMT_P8: *tex_format=
"D3DFMT_P8";
break;
856 case D3DFMT_X8R8G8B8: *tex_format=
"D3DFMT_X8R8G8B8";
break;
857 case D3DFMT_X1R5G5B5: *tex_format=
"D3DFMT_X1R5G5B5";
break;
858 case D3DFMT_R3G3B2: *tex_format=
"D3DFMT_R3G3B2";
break;
859 case D3DFMT_A8R3G3B2: *tex_format=
"D3DFMT_A8R3G3B2";
break;
860 case D3DFMT_X4R4G4B4: *tex_format=
"D3DFMT_X4R4G4B4";
break;
861 case D3DFMT_A8P8: *tex_format=
"D3DFMT_A8P8";
break;
862 case D3DFMT_A8L8: *tex_format=
"D3DFMT_A8L8";
break;
863 case D3DFMT_A4L4: *tex_format=
"D3DFMT_A4L4";
break;
864 case D3DFMT_V8U8: *tex_format=
"D3DFMT_V8U8";
break;
865 case D3DFMT_L6V5U5: *tex_format=
"D3DFMT_L6V5U5";
break;
866 case D3DFMT_X8L8V8U8: *tex_format=
"D3DFMT_X8L8V8U8";
break;
867 case D3DFMT_Q8W8V8U8: *tex_format=
"D3DFMT_Q8W8V8U8";
break;
868 case D3DFMT_V16U16: *tex_format=
"D3DFMT_V16U16";
break;
869 case D3DFMT_W11V11U10: *tex_format=
"D3DFMT_W11V11U10";
break;
870 case D3DFMT_UYVY: *tex_format=
"D3DFMT_UYVY";
break;
871 case D3DFMT_YUY2: *tex_format=
"D3DFMT_YUY2";
break;
872 case D3DFMT_DXT1: *tex_format=
"D3DFMT_DXT1";
break;
873 case D3DFMT_DXT2: *tex_format=
"D3DFMT_DXT2";
break;
874 case D3DFMT_DXT3: *tex_format=
"D3DFMT_DXT3";
break;
875 case D3DFMT_DXT4: *tex_format=
"D3DFMT_DXT4";
break;
876 case D3DFMT_DXT5: *tex_format=
"D3DFMT_DXT5";
break;
877 case D3DFMT_D16_LOCKABLE: *tex_format=
"D3DFMT_D16_LOCKABLE";
break;
878 case D3DFMT_D32: *tex_format=
"D3DFMT_D32";
break;
879 case D3DFMT_D15S1: *tex_format=
"D3DFMT_D15S1";
break;
880 case D3DFMT_D24S8: *tex_format=
"D3DFMT_D24S8";
break;
881 case D3DFMT_D16: *tex_format=
"D3DFMT_D16";
break;
882 case D3DFMT_D24X8: *tex_format=
"D3DFMT_D24X8";
break;
883 case D3DFMT_D24X4S4: *tex_format=
"D3DFMT_D24X4S4";
break;
889 bool resize_window,
bool reset_device,
bool restore_assets)
893 WWASSERT(dev < _RenderDeviceNameTable.Count());
900 }
else if (dev != -1) {
915 if (windowed != -1)
IsWindowed = (windowed != 0);
918 WWDEBUG_SAY((
"Attempting Set_Render_Device: name: %s (%s:%s), width: %d, height: %d, windowed: %d\n",
932 ::GetClientRect (_Hwnd, &rect);
944 DWORD dwstyle = ::GetWindowLong (_Hwnd, GWL_STYLE);
945 AdjustWindowRect (&rect, dwstyle,
FALSE);
949 ::SetWindowPos(_Hwnd, HWND_TOPMOST, 0, 0, rect.right-rect.left, rect.bottom-rect.top,SWP_NOSIZE |SWP_NOMOVE);
951 ::SetWindowPos (_Hwnd,
955 rect.right-rect.left,
956 rect.bottom-rect.top,
957 SWP_NOZORDER | SWP_NOMOVE);
967 ::ZeroMemory(&_PresentParameters,
sizeof(D3DPRESENT_PARAMETERS));
971 _PresentParameters.BackBufferCount =
IsWindowed ? 1 : 2;
973 _PresentParameters.MultiSampleType = D3DMULTISAMPLE_NONE;
975 _PresentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
976 _PresentParameters.hDeviceWindow = _Hwnd;
979 _PresentParameters.EnableAutoDepthStencil =
TRUE;
980 _PresentParameters.Flags=0;
982 _PresentParameters.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
983 _PresentParameters.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
992 D3DDISPLAYMODE desktop_mode;
993 ::ZeroMemory(&desktop_mode,
sizeof(D3DDISPLAYMODE));
996 DisplayFormat=_PresentParameters.BackBufferFormat = desktop_mode.Format;
999 switch (_PresentParameters.BackBufferFormat) {
1000 case D3DFMT_X8R8G8B8:
1001 case D3DFMT_A8R8G8B8:
1002 case D3DFMT_R8G8B8:
BitDepth=32;
break;
1003 case D3DFMT_A4R4G4B4:
1004 case D3DFMT_A1R5G5B5:
1005 case D3DFMT_R5G6B5:
BitDepth=16;
break;
1014 if (
BitDepth==32 &&
D3DInterface->CheckDeviceType(0,D3DDEVTYPE_HAL,desktop_mode.Format,D3DFMT_A8R8G8B8,
TRUE) == D3D_OK)
1016 _PresentParameters.BackBufferFormat = D3DFMT_A8R8G8B8;
1027 _PresentParameters.BackBufferFormat=D3DFMT_R5G6B5;
1028 if (!
Find_Z_Mode(_PresentParameters.BackBufferFormat,_PresentParameters.BackBufferFormat,&_PresentParameters.AutoDepthStencilFormat)) {
1029 _PresentParameters.AutoDepthStencilFormat=D3DFMT_UNKNOWN;
1033 _PresentParameters.AutoDepthStencilFormat=D3DFMT_UNKNOWN;
1043 &_PresentParameters.BackBufferFormat,&_PresentParameters.AutoDepthStencilFormat);
1049 if (_PresentParameters.AutoDepthStencilFormat==D3DFMT_UNKNOWN) {
1051 _PresentParameters.AutoDepthStencilFormat=D3DFMT_D32;
1054 _PresentParameters.AutoDepthStencilFormat=D3DFMT_D16;
1062 Get_Format_Name(_PresentParameters.BackBufferFormat,&backbufferFormat);
1064 WWDEBUG_SAY((
"Using Display/BackBuffer Formats: %s/%s\n",displayFormat,backbufferFormat));
1073 WWDEBUG_SAY((
"Reset/Create_Device done, reset_device=%d, restore_assets=%d\n", reset_device, restore_assets));
1101 (res < resolutions.
Count ()) && (curr_res == -1);
1112 if (curr_res == -1) {
1117 resolutions[0].Height,
1134 case 0: _PresentParameters.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
break;
1135 case 1: _PresentParameters.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_ONE ;
break;
1136 case 2: _PresentParameters.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_TWO;
break;
1137 case 3: _PresentParameters.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_THREE;
break;
1138 default: _PresentParameters.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_ONE ;
break;
1146 return _PresentParameters.FullScreen_PresentationInterval;
1151 bool has_stencil = (_PresentParameters.AutoDepthStencilFormat == D3DFMT_D24S8 ||
1152 _PresentParameters.AutoDepthStencilFormat == D3DFMT_D24X4S4);
1158 return _RenderDeviceNameTable.Count();
1176 if (deviceidx == -1) {
1185 WWASSERT(deviceidx < _RenderDeviceNameTable.Count());
1186 return _RenderDeviceDescriptionTable[deviceidx];
1191 device_index = device_index % _RenderDeviceShortNameTable.Count();
1192 return _RenderDeviceShortNameTable[device_index];
1210 ::GetClientRect (_Hwnd, &rect);
1223 DWORD dwstyle = ::GetWindowLong (_Hwnd, GWL_STYLE);
1224 AdjustWindowRect (&rect, dwstyle,
FALSE);
1228 ::SetWindowPos(_Hwnd, HWND_TOPMOST, 0, 0, rect.right-rect.left, rect.bottom-rect.top,SWP_NOSIZE |SWP_NOMOVE);
1230 ::SetWindowPos (_Hwnd,
1234 rect.right-rect.left,
1235 rect.bottom-rect.top,
1236 SWP_NOZORDER | SWP_NOMOVE);
1239#pragma message("TODO: support changing windowed status and changing the bit depth")
1263 D3DSURFACE_DESC info;
1267 set_h = info.Height;
1280 int width, height, depth;
1298 _RenderDeviceShortNameTable[device] );
1312 int width,height,depth,windowed;
1324 WWDEBUG_SAY((
"Device %s (%d X %d) %d bit windowed:%d\n", name,width,height,depth,windowed));
1337 if (
Set_Render_Device( name, width,height,depth,windowed, resize_window ) !=
true) {
1338 if (depth==16) depth=32;
1340 if (
Set_Render_Device( name, width,height,depth,windowed, resize_window ) ==
true) {
1343 if (depth==16) depth=32;
1355 else if (width>1920) {
1359 else if (width>1600) {
1363 else if (width>1280) {
1367 else if (width>1024) {
1371 else if (width>800) {
1375 else if (width!=640) {
1382 for (
int i=0;i<2;++i) {
1383 if (
Set_Render_Device( name, width,height,depth,windowed, resize_window ) ==
true) {
1386 if (depth==16) depth=32;
1406 device, device_len);
1427 static D3DFORMAT _formats16[] =
1434 static D3DFORMAT _formats32[] =
1444 D3DFORMAT * format_table =
NULL;
1445 int format_count = 0;
1448 format_table = _formats16;
1449 format_count =
sizeof(_formats16) /
sizeof(D3DFORMAT);
1451 format_table = _formats32;
1452 format_count =
sizeof(_formats32) /
sizeof(D3DFORMAT);
1459 unsigned int mode = 0;
1461 for (
int format_index=0; format_index < format_count; format_index++) {
1469 *set_backbuffer=*set_colorbuffer = format_table[format_index];
1472 if (bitdepth==32 && *set_colorbuffer == D3DFMT_X8R8G8B8 &&
D3DInterface->CheckDeviceType(0,D3DDEVTYPE_HAL,*set_colorbuffer,D3DFMT_A8R8G8B8,
TRUE) == D3D_OK)
1474 *set_backbuffer = D3DFMT_A8R8G8B8;
1480 return Find_Z_Mode(*set_colorbuffer,*set_backbuffer, set_zmode);
1490 D3DDISPLAYMODE dmode;
1491 ::ZeroMemory(&dmode,
sizeof(D3DDISPLAYMODE));
1493 rx=(
unsigned int) resx;
1494 ry=(
unsigned int) resy;
1498 modemax=
D3DInterface->GetAdapterModeCount(D3DADAPTER_DEFAULT);
1502 while (i<modemax && !found)
1504 D3DInterface->EnumAdapterModes(D3DADAPTER_DEFAULT, i, &dmode);
1505 if (dmode.Width==rx && dmode.Height==ry && dmode.Format==colorbuffer) {
1506 WWDEBUG_SAY((
"Found valid color mode. Width = %d Height = %d Format = %d\r\n",dmode.Width,dmode.Height,dmode.Format));
1516 WWDEBUG_SAY((
"Failed to find a valid color mode\r\n"));
1524 while (j<modemax && stillok)
1526 D3DInterface->EnumAdapterModes(D3DADAPTER_DEFAULT, j, &dmode);
1527 if (dmode.Width==rx && dmode.Height==ry && dmode.Format==colorbuffer)
1528 stillok=
true;
else stillok=
false;
1532 if (stillok==
false) *mode=j-2;
1543 if (
Test_Z_Mode(colorbuffer,backbuffer,D3DFMT_D24S8))
1545 *zmode=D3DFMT_D24S8;
1546 WWDEBUG_SAY((
"Found zbuffer mode D3DFMT_D24S8\n"));
1550 if (
Test_Z_Mode(colorbuffer,backbuffer,D3DFMT_D32))
1557 if (
Test_Z_Mode(colorbuffer,backbuffer,D3DFMT_D24X8))
1559 *zmode=D3DFMT_D24X8;
1560 WWDEBUG_SAY((
"Found zbuffer mode D3DFMT_D24X8\n"));
1564 if (
Test_Z_Mode(colorbuffer,backbuffer,D3DFMT_D24X4S4))
1566 *zmode=D3DFMT_D24X4S4;
1567 WWDEBUG_SAY((
"Found zbuffer mode D3DFMT_D24X4S4\n"));
1571 if (
Test_Z_Mode(colorbuffer,backbuffer,D3DFMT_D16))
1578 if (
Test_Z_Mode(colorbuffer,backbuffer,D3DFMT_D15S1))
1580 *zmode=D3DFMT_D15S1;
1581 WWDEBUG_SAY((
"Found zbuffer mode D3DFMT_D15S1\n"));
1586 WWDEBUG_SAY((
"Failed to find a valid zbuffer mode\r\n"));
1594 colorbuffer,D3DUSAGE_DEPTHSTENCIL,D3DRTYPE_SURFACE,zmode)))
1596 WWDEBUG_SAY((
"CheckDeviceFormat failed. Colorbuffer format = %d Zbufferformat = %d\n",colorbuffer,zmode));
1602 colorbuffer,backbuffer,zmode)))
1604 WWDEBUG_SAY((
"CheckDepthStencilMatch failed. Colorbuffer format = %d Backbuffer format = %d Zbufferformat = %d\n",colorbuffer,backbuffer,zmode));
1624 last_frame_matrix_changes = 0;
1625 last_frame_material_changes = 0;
1626 last_frame_vertex_buffer_changes = 0;
1627 last_frame_index_buffer_changes = 0;
1628 last_frame_light_changes = 0;
1629 last_frame_texture_changes = 0;
1630 last_frame_render_state_changes = 0;
1631 last_frame_texture_stage_state_changes = 0;
1632 last_frame_number_of_DX8_calls = 0;
1633 last_frame_draw_calls =0;
1686#if ENABLE_EMBEDDED_BROWSER
1712 if (SUCCEEDED(hr)) {
1713#ifdef EXTENDED_STATS
1714 if (stats.m_sleepTime) {
1715 ::Sleep(stats.m_sleepTime);
1726 if (hr==D3DERR_DEVICELOST) {
1728 if (hr==D3DERR_DEVICENOTRESET) {
1757 int numBuffers = (_PresentParameters.BackBufferCount + 1);
1758 int visibleBuffer = (
FrameCount % numBuffers);
1759 int flipCount = ((numBuffers - visibleBuffer) % numBuffers);
1760 int resetAttempts = 0;
1762 while ((flipCount > 0) && (resetAttempts < 3)) {
1768 if (D3DERR_DEVICELOST == hr) {
1770 WWDEBUG_SAY((
"DEVICELOST: Cannot flip to primary.\n"));
1775 if (D3DERR_DEVICENOTRESET == hr) {
1784 if (SUCCEEDED(hr)) {
1814 bool has_stencil=
false;
1815 IDirect3DSurface8* depthbuffer;
1822 D3DSURFACE_DESC desc;
1823 depthbuffer->GetDesc(&desc);
1826 desc.Format==D3DFMT_D15S1 ||
1827 desc.Format==D3DFMT_D24S8 ||
1828 desc.Format==D3DFMT_D24X4S4
1832 depthbuffer->Release();
1836 if (clear_color) flags |= D3DCLEAR_TARGET;
1837 if (clear_z_stencil) flags |= D3DCLEAR_ZBUFFER;
1838 if (clear_z_stencil && has_stencil) flags |= D3DCLEAR_STENCIL;
1848 DX8CALL(SetViewport(pViewport));
1864 render_state.vertex_buffers[stream]->Release_Engine_Ref();
1953void DX8Wrapper::Draw_Sorting_IB_VB(
1954 unsigned primitive_type,
1955 unsigned short start_index,
1956 unsigned short polygon_count,
1957 unsigned short min_vertex_index,
1958 unsigned short vertex_count)
1970 unsigned size = dyn_vb_access.FVF_Info().Get_FVF_Size()*vertex_count/
sizeof(unsigned);
1971 unsigned *dest_u =(
unsigned*) dest;
1972 unsigned *src_u = (
unsigned*) src;
1974 for (
unsigned i=0;i<size;++i) {
1982 dyn_vb_access.FVF_Info().Get_FVF_Size()));
1984 unsigned fvf=dyn_vb_access.FVF_Info().Get_FVF();
1986 DX8CALL(SetVertexShader(fvf));
1990 unsigned index_count=0;
1991 switch (primitive_type) {
1992 case D3DPT_TRIANGLELIST: index_count=polygon_count*3;
break;
1993 case D3DPT_TRIANGLESTRIP: index_count=polygon_count+2;
break;
1994 case D3DPT_TRIANGLEFAN: index_count=polygon_count+2;
break;
2002 unsigned short* dest=lock.Get_Index_Array();
2003 unsigned short* src=
NULL;
2004 src=
static_cast<SortingIndexBufferClass*
>(
render_state.index_buffer)->index_buffer;
2008 for (
unsigned short i=0;i<index_count;++i) {
2009 unsigned short index=*src++;
2010 index-=min_vertex_index;
2022 dyn_vb_access.VertexBufferOffset));
2030 dyn_ib_access.IndexBufferOffset,
2042void DX8Wrapper::Draw(
2043 unsigned primitive_type,
2044 unsigned short start_index,
2045 unsigned short polygon_count,
2046 unsigned short min_vertex_index,
2047 unsigned short vertex_count)
2059#ifdef MESH_RENDER_SNAPSHOT_ENABLED
2061 unsigned long passes=0;
2063 HRESULT res=
D3DDevice->ValidateDevice(&passes);
2069 case D3DERR_CONFLICTINGTEXTUREFILTER:
2072 case D3DERR_CONFLICTINGTEXTUREPALETTE:
2075 case D3DERR_DEVICELOST:
2078 case D3DERR_TOOMANYOPERATIONS:
2081 case D3DERR_UNSUPPORTEDALPHAARG:
2084 case D3DERR_UNSUPPORTEDALPHAOPERATION:
2087 case D3DERR_UNSUPPORTEDCOLORARG:
2090 case D3DERR_UNSUPPORTEDCOLOROPERATION:
2093 case D3DERR_UNSUPPORTEDFACTORVALUE:
2096 case D3DERR_UNSUPPORTEDTEXTUREFILTER:
2099 case D3DERR_WRONGTEXTUREFORMAT:
2110 SNAPSHOT_SAY((
"DX8 - draw %d polygons (%d vertices)\n",polygon_count,vertex_count));
2112 if (vertex_count<3) {
2141 (D3DPRIMITIVETYPE)primitive_type,
2150 WWASSERT_PRINT(0,
"VB and IB must of same type (sorting or dx8)");
2162 WWASSERT_PRINT(0,
"VB and IB must of same type (sorting or dx8)");
2166 Draw_Sorting_IB_VB(primitive_type,start_index,polygon_count,min_vertex_index,vertex_count);
2186 unsigned buffer_type,
2187 unsigned short start_index,
2188 unsigned short polygon_count,
2189 unsigned short min_vertex_index,
2190 unsigned short vertex_count)
2196 Draw(D3DPT_TRIANGLELIST,start_index,polygon_count,min_vertex_index,vertex_count);
2207 unsigned short start_index,
2208 unsigned short polygon_count,
2209 unsigned short min_vertex_index,
2210 unsigned short vertex_count)
2212 Draw(D3DPT_TRIANGLELIST,start_index,polygon_count,min_vertex_index,vertex_count);
2222 unsigned short start_index,
2223 unsigned short polygon_count,
2224 unsigned short min_vertex_index,
2225 unsigned short vertex_count)
2227 Draw(D3DPT_TRIANGLESTRIP,start_index,polygon_count,min_vertex_index,vertex_count);
2238 SNAPSHOT_SAY((
"DX8Wrapper::Apply_Render_State_Changes()\n"));
2246 unsigned mask=TEXTURE0_CHANGED;
2247 for (
int i=0;i<
CurrentCaps->Get_Max_Textures_Per_Pass();++i,mask<<=1)
2272 else VertexMaterialClass::Apply_Null();
2277 unsigned mask=LIGHT0_CHANGED;
2278 for (
unsigned index=0;index<4;++index,mask<<=1) {
2282#ifdef MESH_RENDER_SNAPSHOT_ENABLED
2285 static char * _light_types[] = {
"Unknown",
"Point",
"Spot",
"Directional" };
2286 WWASSERT((light->Type >= 0) && (light->Type <= 3));
2288 SNAPSHOT_SAY((
" type = %s amb = %4.2f,%4.2f,%4.2f diff = %4.2f,%4.2f,%4.2f spec = %4.2f, %4.2f, %4.2f\n",
2289 _light_types[light->Type],
2290 light->Ambient.r,light->Ambient.g,light->Ambient.b,
2291 light->Diffuse.r,light->Diffuse.g,light->Diffuse.b,
2292 light->Specular.r,light->Specular.g,light->Specular.b ));
2294 light->Position.x, light->Position.y, light->Position.z,
2295 light->Direction.x, light->Direction.y, light->Direction.z ));
2327 render_state.vertex_buffers[i]->FVF_Info().Get_FVF_Size()));
2331 unsigned fvf=
render_state.vertex_buffers[i]->FVF_Info().Get_FVF();
2377 SNAPSHOT_SAY((
"DX8Wrapper::Apply_Render_State_Changes() - finished\n"));
2383 unsigned int height,
2392 IDirect3DTexture8 *texture =
NULL;
2403 unsigned ret=D3DXCreateTexture(
2408 D3DUSAGE_RENDERTARGET,
2413 if (ret==D3DERR_NOTAVAILABLE) {
2419 if (ret==D3DERR_OUTOFVIDEOMEMORY) {
2420 WWDEBUG_SAY((
"Error: Out of memory while creating render target. Trying to release assets...\n"));
2427 ret=D3DXCreateTexture(
2432 D3DUSAGE_RENDERTARGET,
2437 if (SUCCEEDED(ret)) {
2438 WWDEBUG_SAY((
"...Render target creation succesful.\n"));
2441 WWDEBUG_SAY((
"...Render target creation failed.\n"));
2443 if (ret==D3DERR_OUTOFVIDEOMEMORY) {
2458 unsigned ret=D3DXCreateTexture(
2469 if (ret==D3DERR_OUTOFVIDEOMEMORY) {
2470 WWDEBUG_SAY((
"Error: Out of memory while creating texture. Trying to release assets...\n"));
2477 ret=D3DXCreateTexture(
2486 if (SUCCEEDED(ret)) {
2487 WWDEBUG_SAY((
"...Texture creation succesful.\n"));
2492 WWDEBUG_SAY((
"...Texture creation failed. (%d x %d, format: %s, mips: %d\n",width,height,format_name,mip_level_count));
2503 const char *filename,
2509 IDirect3DTexture8 *texture =
NULL;
2516 unsigned result = D3DXCreateTextureFromFileExA(
2532 if (result != D3D_OK) {
2537 D3DSURFACE_DESC desc;
2538 texture->GetLevelDesc(0,&desc);
2539 if (desc.Format==D3DFMT_P8) {
2548 IDirect3DSurface8 *surface,
2554 IDirect3DTexture8 *texture =
NULL;
2556 D3DSURFACE_DESC surface_desc;
2557 ::ZeroMemory(&surface_desc,
sizeof(D3DSURFACE_DESC));
2558 surface->GetDesc(&surface_desc);
2563 texture =
_Create_DX8_Texture(surface_desc.Width, surface_desc.Height, format, mip_level_count);
2566 IDirect3DSurface8 *tex_surface =
NULL;
2567 texture->GetSurfaceLevel(0, &tex_surface);
2569 tex_surface->Release();
2587 unsigned int height,
2595 IDirect3DTexture8* texture =
NULL;
2604 D3DUSAGE_DEPTHSTENCIL,
2610 if (ret==D3DERR_NOTAVAILABLE)
2617 if (ret==D3DERR_OUTOFVIDEOMEMORY)
2619 WWDEBUG_SAY((
"Error: Out of memory while creating render target. Trying to release assets...\n"));
2631 D3DUSAGE_DEPTHSTENCIL,
2639 WWDEBUG_SAY((
"...Render target creation succesful.\n"));
2643 WWDEBUG_SAY((
"...Render target creation failed.\n"));
2645 if (ret==D3DERR_OUTOFVIDEOMEMORY)
2668 unsigned int height,
2678 IDirect3DCubeTexture8* texture=
NULL;
2690 unsigned ret=D3DXCreateCubeTexture
2695 D3DUSAGE_RENDERTARGET,
2701 if (ret==D3DERR_NOTAVAILABLE)
2708 if (ret==D3DERR_OUTOFVIDEOMEMORY)
2710 WWDEBUG_SAY((
"Error: Out of memory while creating render target. Trying to release assets...\n"));
2717 ret=D3DXCreateCubeTexture
2722 D3DUSAGE_RENDERTARGET,
2730 WWDEBUG_SAY((
"...Render target creation succesful.\n"));
2734 WWDEBUG_SAY((
"...Render target creation failed.\n"));
2736 if (ret==D3DERR_OUTOFVIDEOMEMORY)
2752 unsigned ret=D3DXCreateCubeTexture
2764 if (ret==D3DERR_OUTOFVIDEOMEMORY)
2766 WWDEBUG_SAY((
"Error: Out of memory while creating texture. Trying to release assets...\n"));
2773 ret=D3DXCreateCubeTexture
2785 WWDEBUG_SAY((
"...Texture creation succesful.\n"));
2791 WWDEBUG_SAY((
"...Texture creation failed. (%d x %d, format: %s, mips: %d\n",width,height,format_name,mip_level_count));
2806 unsigned int height,
2815 IDirect3DVolumeTexture8* texture=
NULL;
2827 unsigned ret=D3DXCreateVolumeTexture
2841 if (ret==D3DERR_OUTOFVIDEOMEMORY)
2843 WWDEBUG_SAY((
"Error: Out of memory while creating texture. Trying to release assets...\n"));
2850 ret=D3DXCreateVolumeTexture
2864 WWDEBUG_SAY((
"...Texture creation succesful.\n"));
2870 WWDEBUG_SAY((
"...Texture creation failed. (%d x %d, format: %s, mips: %d\n",width,height,format_name,mip_level_count));
2885 IDirect3DSurface8 *surface =
NULL;
2909 IDirect3DSurface8 *surface =
NULL;
2919 char compressed_name[200];
2920 strncpy(compressed_name,filename_, 200);
2921 char *ext = strstr(compressed_name,
".");
2922 if ( (strlen(ext)==4) &&
2923 ( (ext[1] ==
't') || (ext[1] ==
'T') ) &&
2924 ( (ext[2] ==
'g') || (ext[2] ==
'G') ) &&
2925 ( (ext[3] ==
'a') || (ext[3] ==
'A') ) ) {
2994 memset(&dlight,0,
sizeof(D3DLIGHT8));
3000 dlight.Type=D3DLIGHT_POINT;
3005 dlight.Type=D3DLIGHT_DIRECTIONAL;
3010 dlight.Type=D3DLIGHT_SPOT;
3017 dlight.Diffuse.r=temp.
X;
3018 dlight.Diffuse.g=temp.
Y;
3019 dlight.Diffuse.b=temp.
Z;
3020 dlight.Diffuse.a=1.0f;
3024 dlight.Specular.r=temp.
X;
3025 dlight.Specular.g=temp.
Y;
3026 dlight.Specular.b=temp.
Z;
3027 dlight.Specular.a=1.0f;
3031 dlight.Ambient.r=temp.
X;
3032 dlight.Ambient.g=temp.
Y;
3033 dlight.Ambient.b=temp.
Z;
3034 dlight.Ambient.a=1.0f;
3037 dlight.Position=*(D3DVECTOR*) &temp;
3040 dlight.Direction=*(D3DVECTOR*) &temp;
3050 dlight.Attenuation0=1.0f;
3053 dlight.Attenuation1=0.0f;
3056 dlight.Attenuation1=(float) 1.0/a;
3057 dlight.Attenuation2=0.0f;
3088 for (
int l=0;l<light_count;++l) {
3090 ::ZeroMemory(&light,
sizeof(D3DLIGHT8));
3092 light.Type=D3DLIGHT_DIRECTIONAL;
3095 light.Direction=(
const D3DVECTOR&)(
dir);
3099 light.Specular.r = light.Specular.g = light.Specular.b = 1.0f;
3103 light.Type = D3DLIGHT_POINT;
3117 light.Attenuation0=0.01f;
3119 light.Attenuation0=1.0f;
3123 light.Attenuation1=0.0f;
3126 light.Attenuation1=(float) 0.1/a;
3128 light.Attenuation2=8.0f/(b*b);
3149 D3DDISPLAYMODE mode;
3151 DX8CALL(GetDisplayMode(&mode));
3153 IDirect3DSurface8 * fb=
NULL;
3155 DX8CALL(CreateImageSurface(mode.Width,mode.Height,D3DFMT_A8R8G8B8,&fb));
3165 IDirect3DSurface8 * bb;
3167 DX8CALL(GetBackBuffer(num,D3DBACKBUFFER_TYPE_MONO,&bb));
3187 D3DDISPLAYMODE mode;
3188 DX8CALL(GetDisplayMode(&mode));
3194 WWDEBUG_SAY((
"DX8Wrapper - Render target format is not supported\r\n"));
3202 float poweroftwosize = width;
3203 if (height > 0 && height < width) {
3204 poweroftwosize = height;
3206 poweroftwosize =
::Find_POT (poweroftwosize);
3208 if (poweroftwosize>dx8caps.MaxTextureWidth) {
3209 poweroftwosize=dx8caps.MaxTextureWidth;
3211 if (poweroftwosize>dx8caps.MaxTextureHeight) {
3212 poweroftwosize=dx8caps.MaxTextureHeight;
3215 width = height = poweroftwosize;
3226 WWDEBUG_SAY((
"DX8Wrapper - Render target creation failed!\r\n"));
3266 WWDEBUG_SAY((
"DX8Wrapper - Render target with depth format is not supported\r\n"));
3272 float poweroftwosize = width;
3273 if (height > 0 && height < width)
3275 poweroftwosize = height;
3277 poweroftwosize =
::Find_POT (poweroftwosize);
3279 if (poweroftwosize>dx8caps.MaxTextureWidth)
3281 poweroftwosize=dx8caps.MaxTextureWidth;
3284 if (poweroftwosize>dx8caps.MaxTextureHeight)
3286 poweroftwosize=dx8caps.MaxTextureHeight;
3289 width = height = poweroftwosize;
3298 WWDEBUG_SAY((
"DX8Wrapper - Render target creation failed!\r\n"));
3332 IDirect3DSurface8* d3d_zbuf=
NULL;
3339 d3d_zbuf->Release();
3345 d3d_surf->Release();
3359 LPDIRECT3DSURFACE8 render_target =
NULL;
3360 swap_chain->GetBackBuffer (0, D3DBACKBUFFER_TYPE_MONO, &render_target);
3370 if (render_target !=
NULL) {
3371 render_target->Release ();
3372 render_target =
NULL;
3477 if (use_default_depth_buffer)
3508 IDirect3DSurface8* render_target,
3509 IDirect3DSurface8* depth_buffer
3616IDirect3DSwapChain8 *
3624 D3DPRESENT_PARAMETERS params = { 0 };
3625 params.BackBufferFormat = _PresentParameters.BackBufferFormat;
3626 params.BackBufferCount = 1;
3627 params.MultiSampleType = D3DMULTISAMPLE_NONE;
3628 params.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC;
3629 params.hDeviceWindow = render_window;
3630 params.Windowed =
TRUE;
3631 params.EnableAutoDepthStencil =
TRUE;
3632 params.AutoDepthStencilFormat = _PresentParameters.AutoDepthStencilFormat;
3634 params.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
3635 params.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
3640 IDirect3DSwapChain8 *swap_chain =
NULL;
3641 DX8CALL(CreateAdditionalSwapChain(¶ms, &swap_chain));
3648 DX8CALL(ResourceManagerDiscardBytes(bytes));
3664 gamma=
Bound(gamma,0.6f,6.0f);
3665 bright=
Bound(bright,-0.5f,0.5f);
3666 contrast=
Bound(contrast,0.5f,2.0f);
3667 float oo_gamma=1.0f/gamma;
3672 DWORD flag=(calibrate?D3DSGR_CALIBRATE:D3DSGR_NO_CALIBRATION);
3679 limit=(contrast-1)/2*contrast;
3685 for (
int i=0; i<256; i++) {
3689 x=
Bound(x,0.0f,1.0f);
3691 out=contrast*x+bright;
3692 out=
Bound(out,0.0f,1.0f);
3693 ramp.red[i]=(
WORD) (out*65535);
3694 ramp.green[i]=(
WORD) (out*65535);
3695 ramp.blue[i]=(
WORD) (out*65535);
3701 HWND hwnd = GetDesktopWindow();
3702 HDC hdc = GetDC(hwnd);
3705 SetDeviceGammaRamp (hdc, &ramp);
3706 ReleaseDC (hwnd, hdc);
3801 for (i=0; i<
CurrentCaps->Get_Max_Textures_Per_Pass(); i++)
3840 VertexMaterialClass::Apply_Null();
3842 for (
unsigned index=0;index<4;++index) {
3865 case D3DRS_ZENABLE :
return "D3DRS_ZENABLE";
3866 case D3DRS_FILLMODE :
return "D3DRS_FILLMODE";
3867 case D3DRS_SHADEMODE :
return "D3DRS_SHADEMODE";
3868 case D3DRS_LINEPATTERN :
return "D3DRS_LINEPATTERN";
3869 case D3DRS_ZWRITEENABLE :
return "D3DRS_ZWRITEENABLE";
3870 case D3DRS_ALPHATESTENABLE :
return "D3DRS_ALPHATESTENABLE";
3871 case D3DRS_LASTPIXEL :
return "D3DRS_LASTPIXEL";
3872 case D3DRS_SRCBLEND :
return "D3DRS_SRCBLEND";
3873 case D3DRS_DESTBLEND :
return "D3DRS_DESTBLEND";
3874 case D3DRS_CULLMODE :
return "D3DRS_CULLMODE";
3875 case D3DRS_ZFUNC :
return "D3DRS_ZFUNC";
3876 case D3DRS_ALPHAREF :
return "D3DRS_ALPHAREF";
3877 case D3DRS_ALPHAFUNC :
return "D3DRS_ALPHAFUNC";
3878 case D3DRS_DITHERENABLE :
return "D3DRS_DITHERENABLE";
3879 case D3DRS_ALPHABLENDENABLE :
return "D3DRS_ALPHABLENDENABLE";
3880 case D3DRS_FOGENABLE :
return "D3DRS_FOGENABLE";
3881 case D3DRS_SPECULARENABLE :
return "D3DRS_SPECULARENABLE";
3882 case D3DRS_ZVISIBLE :
return "D3DRS_ZVISIBLE";
3883 case D3DRS_FOGCOLOR :
return "D3DRS_FOGCOLOR";
3884 case D3DRS_FOGTABLEMODE :
return "D3DRS_FOGTABLEMODE";
3885 case D3DRS_FOGSTART :
return "D3DRS_FOGSTART";
3886 case D3DRS_FOGEND :
return "D3DRS_FOGEND";
3887 case D3DRS_FOGDENSITY :
return "D3DRS_FOGDENSITY";
3888 case D3DRS_EDGEANTIALIAS :
return "D3DRS_EDGEANTIALIAS";
3889 case D3DRS_ZBIAS :
return "D3DRS_ZBIAS";
3890 case D3DRS_RANGEFOGENABLE :
return "D3DRS_RANGEFOGENABLE";
3891 case D3DRS_STENCILENABLE :
return "D3DRS_STENCILENABLE";
3892 case D3DRS_STENCILFAIL :
return "D3DRS_STENCILFAIL";
3893 case D3DRS_STENCILZFAIL :
return "D3DRS_STENCILZFAIL";
3894 case D3DRS_STENCILPASS :
return "D3DRS_STENCILPASS";
3895 case D3DRS_STENCILFUNC :
return "D3DRS_STENCILFUNC";
3896 case D3DRS_STENCILREF :
return "D3DRS_STENCILREF";
3897 case D3DRS_STENCILMASK :
return "D3DRS_STENCILMASK";
3898 case D3DRS_STENCILWRITEMASK :
return "D3DRS_STENCILWRITEMASK";
3899 case D3DRS_TEXTUREFACTOR :
return "D3DRS_TEXTUREFACTOR";
3900 case D3DRS_WRAP0 :
return "D3DRS_WRAP0";
3901 case D3DRS_WRAP1 :
return "D3DRS_WRAP1";
3902 case D3DRS_WRAP2 :
return "D3DRS_WRAP2";
3903 case D3DRS_WRAP3 :
return "D3DRS_WRAP3";
3904 case D3DRS_WRAP4 :
return "D3DRS_WRAP4";
3905 case D3DRS_WRAP5 :
return "D3DRS_WRAP5";
3906 case D3DRS_WRAP6 :
return "D3DRS_WRAP6";
3907 case D3DRS_WRAP7 :
return "D3DRS_WRAP7";
3908 case D3DRS_CLIPPING :
return "D3DRS_CLIPPING";
3909 case D3DRS_LIGHTING :
return "D3DRS_LIGHTING";
3910 case D3DRS_AMBIENT :
return "D3DRS_AMBIENT";
3911 case D3DRS_FOGVERTEXMODE :
return "D3DRS_FOGVERTEXMODE";
3912 case D3DRS_COLORVERTEX :
return "D3DRS_COLORVERTEX";
3913 case D3DRS_LOCALVIEWER :
return "D3DRS_LOCALVIEWER";
3914 case D3DRS_NORMALIZENORMALS :
return "D3DRS_NORMALIZENORMALS";
3915 case D3DRS_DIFFUSEMATERIALSOURCE :
return "D3DRS_DIFFUSEMATERIALSOURCE";
3916 case D3DRS_SPECULARMATERIALSOURCE :
return "D3DRS_SPECULARMATERIALSOURCE";
3917 case D3DRS_AMBIENTMATERIALSOURCE :
return "D3DRS_AMBIENTMATERIALSOURCE";
3918 case D3DRS_EMISSIVEMATERIALSOURCE :
return "D3DRS_EMISSIVEMATERIALSOURCE";
3919 case D3DRS_VERTEXBLEND :
return "D3DRS_VERTEXBLEND";
3920 case D3DRS_CLIPPLANEENABLE :
return "D3DRS_CLIPPLANEENABLE";
3921 case D3DRS_SOFTWAREVERTEXPROCESSING :
return "D3DRS_SOFTWAREVERTEXPROCESSING";
3922 case D3DRS_POINTSIZE :
return "D3DRS_POINTSIZE";
3923 case D3DRS_POINTSIZE_MIN :
return "D3DRS_POINTSIZE_MIN";
3924 case D3DRS_POINTSPRITEENABLE :
return "D3DRS_POINTSPRITEENABLE";
3925 case D3DRS_POINTSCALEENABLE :
return "D3DRS_POINTSCALEENABLE";
3926 case D3DRS_POINTSCALE_A :
return "D3DRS_POINTSCALE_A";
3927 case D3DRS_POINTSCALE_B :
return "D3DRS_POINTSCALE_B";
3928 case D3DRS_POINTSCALE_C :
return "D3DRS_POINTSCALE_C";
3929 case D3DRS_MULTISAMPLEANTIALIAS :
return "D3DRS_MULTISAMPLEANTIALIAS";
3930 case D3DRS_MULTISAMPLEMASK :
return "D3DRS_MULTISAMPLEMASK";
3931 case D3DRS_PATCHEDGESTYLE :
return "D3DRS_PATCHEDGESTYLE";
3932 case D3DRS_PATCHSEGMENTS :
return "D3DRS_PATCHSEGMENTS";
3933 case D3DRS_DEBUGMONITORTOKEN :
return "D3DRS_DEBUGMONITORTOKEN";
3934 case D3DRS_POINTSIZE_MAX :
return "D3DRS_POINTSIZE_MAX";
3935 case D3DRS_INDEXEDVERTEXBLENDENABLE :
return "D3DRS_INDEXEDVERTEXBLENDENABLE";
3936 case D3DRS_COLORWRITEENABLE :
return "D3DRS_COLORWRITEENABLE";
3937 case D3DRS_TWEENFACTOR :
return "D3DRS_TWEENFACTOR";
3938 case D3DRS_BLENDOP :
return "D3DRS_BLENDOP";
3941 default :
return "UNKNOWN";
3948 case D3DTSS_COLOROP :
return "D3DTSS_COLOROP";
3949 case D3DTSS_COLORARG1 :
return "D3DTSS_COLORARG1";
3950 case D3DTSS_COLORARG2 :
return "D3DTSS_COLORARG2";
3951 case D3DTSS_ALPHAOP :
return "D3DTSS_ALPHAOP";
3952 case D3DTSS_ALPHAARG1 :
return "D3DTSS_ALPHAARG1";
3953 case D3DTSS_ALPHAARG2 :
return "D3DTSS_ALPHAARG2";
3954 case D3DTSS_BUMPENVMAT00 :
return "D3DTSS_BUMPENVMAT00";
3955 case D3DTSS_BUMPENVMAT01 :
return "D3DTSS_BUMPENVMAT01";
3956 case D3DTSS_BUMPENVMAT10 :
return "D3DTSS_BUMPENVMAT10";
3957 case D3DTSS_BUMPENVMAT11 :
return "D3DTSS_BUMPENVMAT11";
3958 case D3DTSS_TEXCOORDINDEX :
return "D3DTSS_TEXCOORDINDEX";
3959 case D3DTSS_ADDRESSU :
return "D3DTSS_ADDRESSU";
3960 case D3DTSS_ADDRESSV :
return "D3DTSS_ADDRESSV";
3961 case D3DTSS_BORDERCOLOR :
return "D3DTSS_BORDERCOLOR";
3962 case D3DTSS_MAGFILTER :
return "D3DTSS_MAGFILTER";
3963 case D3DTSS_MINFILTER :
return "D3DTSS_MINFILTER";
3964 case D3DTSS_MIPFILTER :
return "D3DTSS_MIPFILTER";
3965 case D3DTSS_MIPMAPLODBIAS :
return "D3DTSS_MIPMAPLODBIAS";
3966 case D3DTSS_MAXMIPLEVEL :
return "D3DTSS_MAXMIPLEVEL";
3967 case D3DTSS_MAXANISOTROPY :
return "D3DTSS_MAXANISOTROPY";
3968 case D3DTSS_BUMPENVLSCALE :
return "D3DTSS_BUMPENVLSCALE";
3969 case D3DTSS_BUMPENVLOFFSET :
return "D3DTSS_BUMPENVLOFFSET";
3970 case D3DTSS_TEXTURETRANSFORMFLAGS :
return "D3DTSS_TEXTURETRANSFORMFLAGS";
3971 case D3DTSS_ADDRESSW :
return "D3DTSS_ADDRESSW";
3972 case D3DTSS_COLORARG0 :
return "D3DTSS_COLORARG0";
3973 case D3DTSS_ALPHAARG0 :
return "D3DTSS_ALPHAARG0";
3974 case D3DTSS_RESULTARG :
return "D3DTSS_RESULTARG";
3975 default :
return "UNKNOWN";
3986 case D3DRS_FILLMODE:
3990 case D3DRS_SHADEMODE:
3994 case D3DRS_LINEPATTERN:
3995 case D3DRS_FOGCOLOR:
3996 case D3DRS_ALPHAREF:
3997 case D3DRS_STENCILMASK:
3998 case D3DRS_STENCILWRITEMASK:
3999 case D3DRS_TEXTUREFACTOR:
4001 case D3DRS_CLIPPLANEENABLE:
4002 case D3DRS_MULTISAMPLEMASK:
4006 case D3DRS_ZWRITEENABLE:
4007 case D3DRS_ALPHATESTENABLE:
4008 case D3DRS_LASTPIXEL:
4009 case D3DRS_DITHERENABLE:
4010 case D3DRS_ALPHABLENDENABLE:
4011 case D3DRS_FOGENABLE:
4012 case D3DRS_SPECULARENABLE:
4013 case D3DRS_STENCILENABLE:
4014 case D3DRS_RANGEFOGENABLE:
4015 case D3DRS_EDGEANTIALIAS:
4016 case D3DRS_CLIPPING:
4017 case D3DRS_LIGHTING:
4018 case D3DRS_COLORVERTEX:
4019 case D3DRS_LOCALVIEWER:
4020 case D3DRS_NORMALIZENORMALS:
4021 case D3DRS_SOFTWAREVERTEXPROCESSING:
4022 case D3DRS_POINTSPRITEENABLE:
4023 case D3DRS_POINTSCALEENABLE:
4024 case D3DRS_MULTISAMPLEANTIALIAS:
4025 case D3DRS_INDEXEDVERTEXBLENDENABLE:
4026 name=
value ?
"TRUE" :
"FALSE";
4029 case D3DRS_SRCBLEND:
4030 case D3DRS_DESTBLEND:
4034 case D3DRS_CULLMODE:
4039 case D3DRS_ALPHAFUNC:
4040 case D3DRS_STENCILFUNC:
4044 case D3DRS_ZVISIBLE:
4045 name=
"NOTSUPPORTED";
4048 case D3DRS_FOGTABLEMODE:
4049 case D3DRS_FOGVERTEXMODE:
4053 case D3DRS_FOGSTART:
4055 case D3DRS_FOGDENSITY:
4056 case D3DRS_POINTSIZE:
4057 case D3DRS_POINTSIZE_MIN:
4058 case D3DRS_POINTSCALE_A:
4059 case D3DRS_POINTSCALE_B:
4060 case D3DRS_POINTSCALE_C:
4061 case D3DRS_PATCHSEGMENTS:
4062 case D3DRS_POINTSIZE_MAX:
4063 case D3DRS_TWEENFACTOR:
4068 case D3DRS_STENCILREF:
4072 case D3DRS_STENCILFAIL:
4073 case D3DRS_STENCILZFAIL:
4074 case D3DRS_STENCILPASS:
4087 if (
value&D3DWRAP_U) name+=
"|D3DWRAP_U";
4088 if (
value&D3DWRAP_V) name+=
"|D3DWRAP_V";
4089 if (
value&D3DWRAP_W) name+=
"|D3DWRAP_W";
4092 case D3DRS_DIFFUSEMATERIALSOURCE:
4093 case D3DRS_SPECULARMATERIALSOURCE:
4094 case D3DRS_AMBIENTMATERIALSOURCE:
4095 case D3DRS_EMISSIVEMATERIALSOURCE:
4099 case D3DRS_VERTEXBLEND:
4103 case D3DRS_PATCHEDGESTYLE:
4107 case D3DRS_DEBUGMONITORTOKEN:
4111 case D3DRS_COLORWRITEENABLE:
4113 if (
value&D3DCOLORWRITEENABLE_RED) name+=
"|D3DCOLORWRITEENABLE_RED";
4114 if (
value&D3DCOLORWRITEENABLE_GREEN) name+=
"|D3DCOLORWRITEENABLE_GREEN";
4115 if (
value&D3DCOLORWRITEENABLE_BLUE) name+=
"|D3DCOLORWRITEENABLE_BLUE";
4116 if (
value&D3DCOLORWRITEENABLE_ALPHA) name+=
"|D3DCOLORWRITEENABLE_ALPHA";
4130 case D3DTSS_COLOROP:
4131 case D3DTSS_ALPHAOP:
4135 case D3DTSS_COLORARG0:
4136 case D3DTSS_COLORARG1:
4137 case D3DTSS_COLORARG2:
4138 case D3DTSS_ALPHAARG0:
4139 case D3DTSS_ALPHAARG1:
4140 case D3DTSS_ALPHAARG2:
4141 case D3DTSS_RESULTARG:
4145 case D3DTSS_ADDRESSU:
4146 case D3DTSS_ADDRESSV:
4147 case D3DTSS_ADDRESSW:
4151 case D3DTSS_MAGFILTER:
4152 case D3DTSS_MINFILTER:
4153 case D3DTSS_MIPFILTER:
4157 case D3DTSS_TEXTURETRANSFORMFLAGS:
4161 case D3DTSS_MIPMAPLODBIAS:
4162 case D3DTSS_BUMPENVMAT00:
4163 case D3DTSS_BUMPENVMAT01:
4164 case D3DTSS_BUMPENVMAT10:
4165 case D3DTSS_BUMPENVMAT11:
4166 case D3DTSS_BUMPENVLSCALE:
4167 case D3DTSS_BUMPENVLOFFSET:
4171 case D3DTSS_TEXCOORDINDEX:
4172 if ((
value&0xffff0000)==D3DTSS_TCI_CAMERASPACENORMAL) {
4173 name.
Format(
"D3DTSS_TCI_CAMERASPACENORMAL|%d",
value&0xffff);
4175 else if ((
value&0xffff0000)==D3DTSS_TCI_CAMERASPACEPOSITION) {
4176 name.
Format(
"D3DTSS_TCI_CAMERASPACEPOSITION|%d",
value&0xffff);
4178 else if ((
value&0xffff0000)==D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR) {
4179 name.
Format(
"D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR|%d",
value&0xffff);
4187 case D3DTSS_MAXMIPLEVEL:
4188 case D3DTSS_MAXANISOTROPY:
4192 case D3DTSS_BORDERCOLOR:
4205 case D3DTOP_DISABLE :
return "D3DTOP_DISABLE";
4206 case D3DTOP_SELECTARG1 :
return "D3DTOP_SELECTARG1";
4207 case D3DTOP_SELECTARG2 :
return "D3DTOP_SELECTARG2";
4208 case D3DTOP_MODULATE :
return "D3DTOP_MODULATE";
4209 case D3DTOP_MODULATE2X :
return "D3DTOP_MODULATE2X";
4210 case D3DTOP_MODULATE4X :
return "D3DTOP_MODULATE4X";
4211 case D3DTOP_ADD :
return "D3DTOP_ADD";
4212 case D3DTOP_ADDSIGNED :
return "D3DTOP_ADDSIGNED";
4213 case D3DTOP_ADDSIGNED2X :
return "D3DTOP_ADDSIGNED2X";
4214 case D3DTOP_SUBTRACT :
return "D3DTOP_SUBTRACT";
4215 case D3DTOP_ADDSMOOTH :
return "D3DTOP_ADDSMOOTH";
4216 case D3DTOP_BLENDDIFFUSEALPHA :
return "D3DTOP_BLENDDIFFUSEALPHA";
4217 case D3DTOP_BLENDTEXTUREALPHA :
return "D3DTOP_BLENDTEXTUREALPHA";
4218 case D3DTOP_BLENDFACTORALPHA :
return "D3DTOP_BLENDFACTORALPHA";
4219 case D3DTOP_BLENDTEXTUREALPHAPM :
return "D3DTOP_BLENDTEXTUREALPHAPM";
4220 case D3DTOP_BLENDCURRENTALPHA :
return "D3DTOP_BLENDCURRENTALPHA";
4221 case D3DTOP_PREMODULATE :
return "D3DTOP_PREMODULATE";
4222 case D3DTOP_MODULATEALPHA_ADDCOLOR :
return "D3DTOP_MODULATEALPHA_ADDCOLOR";
4223 case D3DTOP_MODULATECOLOR_ADDALPHA :
return "D3DTOP_MODULATECOLOR_ADDALPHA";
4224 case D3DTOP_MODULATEINVALPHA_ADDCOLOR :
return "D3DTOP_MODULATEINVALPHA_ADDCOLOR";
4225 case D3DTOP_MODULATEINVCOLOR_ADDALPHA :
return "D3DTOP_MODULATEINVCOLOR_ADDALPHA";
4226 case D3DTOP_BUMPENVMAP :
return "D3DTOP_BUMPENVMAP";
4227 case D3DTOP_BUMPENVMAPLUMINANCE :
return "D3DTOP_BUMPENVMAPLUMINANCE";
4228 case D3DTOP_DOTPRODUCT3 :
return "D3DTOP_DOTPRODUCT3";
4229 case D3DTOP_MULTIPLYADD :
return "D3DTOP_MULTIPLYADD";
4230 case D3DTOP_LERP :
return "D3DTOP_LERP";
4231 default :
return "UNKNOWN";
4238 case D3DTA_CURRENT :
return "D3DTA_CURRENT";
4239 case D3DTA_DIFFUSE :
return "D3DTA_DIFFUSE";
4240 case D3DTA_SELECTMASK :
return "D3DTA_SELECTMASK";
4241 case D3DTA_SPECULAR :
return "D3DTA_SPECULAR";
4242 case D3DTA_TEMP :
return "D3DTA_TEMP";
4243 case D3DTA_TEXTURE :
return "D3DTA_TEXTURE";
4244 case D3DTA_TFACTOR :
return "D3DTA_TFACTOR";
4245 case D3DTA_ALPHAREPLICATE :
return "D3DTA_ALPHAREPLICATE";
4246 case D3DTA_COMPLEMENT :
return "D3DTA_COMPLEMENT";
4247 default :
return "UNKNOWN";
4254 case D3DTEXF_NONE :
return "D3DTEXF_NONE";
4255 case D3DTEXF_POINT :
return "D3DTEXF_POINT";
4256 case D3DTEXF_LINEAR :
return "D3DTEXF_LINEAR";
4257 case D3DTEXF_ANISOTROPIC :
return "D3DTEXF_ANISOTROPIC";
4258 case D3DTEXF_FLATCUBIC :
return "D3DTEXF_FLATCUBIC";
4259 case D3DTEXF_GAUSSIANCUBIC :
return "D3DTEXF_GAUSSIANCUBIC";
4260 default :
return "UNKNOWN";
4267 case D3DTADDRESS_WRAP :
return "D3DTADDRESS_WRAP";
4268 case D3DTADDRESS_MIRROR :
return "D3DTADDRESS_MIRROR";
4269 case D3DTADDRESS_CLAMP :
return "D3DTADDRESS_CLAMP";
4270 case D3DTADDRESS_BORDER :
return "D3DTADDRESS_BORDER";
4271 case D3DTADDRESS_MIRRORONCE:
return "D3DTADDRESS_MIRRORONCE";
4272 default :
return "UNKNOWN";
4279 case D3DTTFF_DISABLE :
return "D3DTTFF_DISABLE";
4280 case D3DTTFF_COUNT1 :
return "D3DTTFF_COUNT1";
4281 case D3DTTFF_COUNT2 :
return "D3DTTFF_COUNT2";
4282 case D3DTTFF_COUNT3 :
return "D3DTTFF_COUNT3";
4283 case D3DTTFF_COUNT4 :
return "D3DTTFF_COUNT4";
4284 case D3DTTFF_PROJECTED :
return "D3DTTFF_PROJECTED";
4285 default :
return "UNKNOWN";
4292 case D3DZB_FALSE :
return "D3DZB_FALSE";
4293 case D3DZB_TRUE :
return "D3DZB_TRUE";
4294 case D3DZB_USEW :
return "D3DZB_USEW";
4295 default :
return "UNKNOWN";
4302 case D3DFILL_POINT :
return "D3DFILL_POINT";
4303 case D3DFILL_WIREFRAME :
return "D3DFILL_WIREFRAME";
4304 case D3DFILL_SOLID :
return "D3DFILL_SOLID";
4305 default :
return "UNKNOWN";
4312 case D3DSHADE_FLAT :
return "D3DSHADE_FLAT";
4313 case D3DSHADE_GOURAUD :
return "D3DSHADE_GOURAUD";
4314 case D3DSHADE_PHONG :
return "D3DSHADE_PHONG";
4315 default :
return "UNKNOWN";
4322 case D3DBLEND_ZERO :
return "D3DBLEND_ZERO";
4323 case D3DBLEND_ONE :
return "D3DBLEND_ONE";
4324 case D3DBLEND_SRCCOLOR :
return "D3DBLEND_SRCCOLOR";
4325 case D3DBLEND_INVSRCCOLOR :
return "D3DBLEND_INVSRCCOLOR";
4326 case D3DBLEND_SRCALPHA :
return "D3DBLEND_SRCALPHA";
4327 case D3DBLEND_INVSRCALPHA :
return "D3DBLEND_INVSRCALPHA";
4328 case D3DBLEND_DESTALPHA :
return "D3DBLEND_DESTALPHA";
4329 case D3DBLEND_INVDESTALPHA :
return "D3DBLEND_INVDESTALPHA";
4330 case D3DBLEND_DESTCOLOR :
return "D3DBLEND_DESTCOLOR";
4331 case D3DBLEND_INVDESTCOLOR :
return "D3DBLEND_INVDESTCOLOR";
4332 case D3DBLEND_SRCALPHASAT :
return "D3DBLEND_SRCALPHASAT";
4333 case D3DBLEND_BOTHSRCALPHA :
return "D3DBLEND_BOTHSRCALPHA";
4334 case D3DBLEND_BOTHINVSRCALPHA :
return "D3DBLEND_BOTHINVSRCALPHA";
4335 default :
return "UNKNOWN";
4342 case D3DCULL_NONE :
return "D3DCULL_NONE";
4343 case D3DCULL_CW :
return "D3DCULL_CW";
4344 case D3DCULL_CCW :
return "D3DCULL_CCW";
4345 default :
return "UNKNOWN";
4352 case D3DCMP_NEVER :
return "D3DCMP_NEVER";
4353 case D3DCMP_LESS :
return "D3DCMP_LESS";
4354 case D3DCMP_EQUAL :
return "D3DCMP_EQUAL";
4355 case D3DCMP_LESSEQUAL :
return "D3DCMP_LESSEQUAL";
4356 case D3DCMP_GREATER :
return "D3DCMP_GREATER";
4357 case D3DCMP_NOTEQUAL :
return "D3DCMP_NOTEQUAL";
4358 case D3DCMP_GREATEREQUAL :
return "D3DCMP_GREATEREQUAL";
4359 case D3DCMP_ALWAYS :
return "D3DCMP_ALWAYS";
4360 default :
return "UNKNOWN";
4367 case D3DFOG_NONE :
return "D3DFOG_NONE";
4368 case D3DFOG_EXP :
return "D3DFOG_EXP";
4369 case D3DFOG_EXP2 :
return "D3DFOG_EXP2";
4370 case D3DFOG_LINEAR :
return "D3DFOG_LINEAR";
4371 default :
return "UNKNOWN";
4378 case D3DSTENCILOP_KEEP :
return "D3DSTENCILOP_KEEP";
4379 case D3DSTENCILOP_ZERO :
return "D3DSTENCILOP_ZERO";
4380 case D3DSTENCILOP_REPLACE :
return "D3DSTENCILOP_REPLACE";
4381 case D3DSTENCILOP_INCRSAT :
return "D3DSTENCILOP_INCRSAT";
4382 case D3DSTENCILOP_DECRSAT :
return "D3DSTENCILOP_DECRSAT";
4383 case D3DSTENCILOP_INVERT :
return "D3DSTENCILOP_INVERT";
4384 case D3DSTENCILOP_INCR :
return "D3DSTENCILOP_INCR";
4385 case D3DSTENCILOP_DECR :
return "D3DSTENCILOP_DECR";
4386 default :
return "UNKNOWN";
4393 case D3DMCS_MATERIAL :
return "D3DMCS_MATERIAL";
4394 case D3DMCS_COLOR1 :
return "D3DMCS_COLOR1";
4395 case D3DMCS_COLOR2 :
return "D3DMCS_COLOR2";
4396 default :
return "UNKNOWN";
4403 case D3DVBF_DISABLE :
return "D3DVBF_DISABLE";
4404 case D3DVBF_1WEIGHTS :
return "D3DVBF_1WEIGHTS";
4405 case D3DVBF_2WEIGHTS :
return "D3DVBF_2WEIGHTS";
4406 case D3DVBF_3WEIGHTS :
return "D3DVBF_3WEIGHTS";
4407 case D3DVBF_TWEENING :
return "D3DVBF_TWEENING";
4408 case D3DVBF_0WEIGHTS :
return "D3DVBF_0WEIGHTS";
4409 default :
return "UNKNOWN";
4416 case D3DPATCHEDGE_DISCRETE :
return "D3DPATCHEDGE_DISCRETE";
4417 case D3DPATCHEDGE_CONTINUOUS:
return "D3DPATCHEDGE_CONTINUOUS";
4418 default :
return "UNKNOWN";
4425 case D3DDMT_ENABLE :
return "D3DDMT_ENABLE";
4426 case D3DDMT_DISABLE :
return "D3DDMT_DISABLE";
4427 default :
return "UNKNOWN";
4434 case D3DBLENDOP_ADD :
return "D3DBLENDOP_ADD";
4435 case D3DBLENDOP_SUBTRACT :
return "D3DBLENDOP_SUBTRACT";
4436 case D3DBLENDOP_REVSUBTRACT:
return "D3DBLENDOP_REVSUBTRACT";
4437 case D3DBLENDOP_MIN :
return "D3DBLENDOP_MIN";
4438 case D3DBLENDOP_MAX :
return "D3DBLENDOP_MAX";
4439 default :
return "UNKNOWN";
Int DX8Wrapper_PreserveFPU
bool DX8Wrapper_IsWindowed
#define DX8_RECORD_RENDER(polys, verts, shader)
T Bound(T original, T minval, T maxval)
static void Shutdown(void)
D3DCAPS8 const & Get_DX8_Caps() const
bool Is_Valid_Display_Format(int width, int height, WW3DFormat format)
static void Shutdown(void)
static void Recreate_Textures()
static void Release_Textures()
static void Render(int backbufferindex)
static int Get_Swap_Interval(void)
static const char * Get_DX8_Fill_Mode_Name(unsigned value)
static unsigned Get_Last_Frame_Texture_Stage_State_Changes()
static void Set_Vertex_Buffer(const VertexBufferClass *vb, unsigned stream=0)
static void Begin_Scene(void)
static const char * Get_DX8_Stencil_Op_Name(unsigned value)
static IDirect3DDevice8 * _Get_D3D_Device8()
static bool Test_Z_Mode(D3DFORMAT colorbuffer, D3DFORMAT backbuffer, D3DFORMAT zmode)
static void Begin_Statistics()
static unsigned TextureStageStates[MAX_TEXTURE_STAGES][32]
static unsigned Get_Last_Frame_Material_Changes()
static bool IsRenderToTexture
static LightEnvironmentClass * Light_Environment
static const char * Get_DX8_Vertex_Blend_Flag_Name(unsigned value)
static void Set_Vertex_Shader_Constant(int reg, const void *data, int count)
static int CurRenderDevice
static void Set_Texture(unsigned stage, TextureBaseClass *texture)
static DWORD Vertex_Processing_Behavior
static bool Set_Next_Render_Device(void)
static void _Update_Texture(TextureClass *system, TextureClass *video)
static void Clear(bool clear_color, bool clear_z_stencil, const Vector3 &color, float dest_alpha=0.0f, float z=1.0f, unsigned int stencil=0)
Clear current render device.
static const char * Get_DX8_Texture_Stage_State_Name(D3DTEXTURESTAGESTATETYPE state)
static IDirect3DTexture8 * _Create_DX8_Texture(unsigned int width, unsigned int height, WW3DFormat format, MipCountType mip_level_count, D3DPOOL pool=D3DPOOL_MANAGED, bool rendertarget=false)
static unsigned long FrameCount
static void Do_Onetime_Device_Dependent_Inits(void)
static RenderStateStruct render_state
static const char * Get_DX8_Fog_Mode_Name(unsigned value)
static void Get_Format_Name(unsigned int format, StringClass *tex_format)
static unsigned Get_Last_Frame_Vertex_Buffer_Changes()
static IDirect3DSurface8 * _Get_DX8_Front_Buffer()
static bool Validate_Device(void)
static bool Find_Color_Mode(D3DFORMAT colorbuffer, int resx, int resy, UINT *mode)
static IDirect3DSurface8 * CurrentDepthBuffer
friend class DX8IndexBufferClass
static const char * Get_DX8_ZBuffer_Type_Name(unsigned value)
static unsigned light_changes
static void Set_Default_Global_Render_States(void)
static D3DMATRIX old_world
static IDirect3D8 * _Get_D3D8()
static int Get_Render_Device(void)
static const DX8Caps * Get_Current_Caps()
static ZTextureClass * Shadow_Map[MAX_SHADOW_MAPS]
static void Shutdown(void)
static IDirect3DCubeTexture8 * _Create_DX8_Cube_Texture(unsigned int width, unsigned int height, WW3DFormat format, MipCountType mip_level_count, D3DPOOL pool=D3DPOOL_MANAGED, bool rendertarget=false)
static SurfaceClass * _Get_DX8_Back_Buffer(unsigned int num=0)
static unsigned RenderStates[256]
static D3DADAPTER_IDENTIFIER8 CurrentAdapterIdentifier
static bool world_identity
static DWORD Pixel_Shader
static void Set_Light(unsigned index, const D3DLIGHT8 *light)
static const char * Get_DX8_Shade_Mode_Name(unsigned value)
static void Get_Device_Resolution(int &set_w, int &set_h, int &set_bits, bool &set_windowed)
static unsigned _MainThreadID
static IDirect3DSwapChain8 * Create_Additional_Swap_Chain(HWND render_window)
static Vector4 Pixel_Shader_Constants[MAX_PIXEL_SHADER_CONSTANTS]
static DX8_CleanupHook * m_pCleanupHook
static const char * Get_DX8_Texture_Filter_Name(unsigned value)
static bool Set_Any_Render_Device(void)
static void Invalidate_Cached_Render_States(void)
static bool Init(void *hwnd, bool lite=false)
static void Set_Light_Environment(LightEnvironmentClass *light_env)
Set the light environment. This is a lighting model which used up to four directional lights to produ...
static int ResolutionWidth
static void Flip_To_Primary(void)
static unsigned texture_changes
static unsigned DrawPolygonLowBoundLimit
static void End_Scene(bool flip_frame=true)
static const char * Get_DX8_Texture_Op_Name(unsigned value)
static unsigned vertex_buffer_changes
static unsigned int Get_Free_Texture_RAM()
static bool Toggle_Windowed(void)
static void Set_Pixel_Shader_Constant(int reg, const void *data, int count)
static bool Create_Device(void)
static void Get_DX8_Texture_Stage_State_Value_Name(StringClass &name, D3DTEXTURESTAGESTATETYPE state, unsigned value)
static IDirect3DSurface8 * CurrentRenderTarget
static const char * Get_DX8_Material_Source_Name(unsigned value)
static bool Set_Render_Device(const char *dev_name, int width=-1, int height=-1, int bits=-1, int windowed=-1, bool resize_window=false)
static D3DFORMAT DisplayFormat
static void Enumerate_Devices()
static bool _Is_Triangle_Draw_Enabled()
static IDirect3DSurface8 * DefaultRenderTarget
static void Set_DX8_Texture_Stage_State(unsigned stage, D3DTEXTURESTAGESTATETYPE state, unsigned value)
static unsigned texture_stage_state_changes
static void Apply_Default_State()
Resets render device to default state.
static int TextureBitDepth
static const char * Get_DX8_Texture_Arg_Name(unsigned value)
static WW3DFormat getBackBufferFormat(void)
Returns the display format - added by TR for video playback - not part of W3D.
static unsigned long Get_FrameCount(void)
static const char * Get_DX8_Texture_Address_Name(unsigned value)
static void Compute_Caps(WW3DFormat display_format)
static void _Set_DX8_Transform(D3DTRANSFORMSTATETYPE transform, const Matrix4x4 &m)
static DX8Caps * CurrentCaps
static void Set_Index_Buffer(const IndexBufferClass *ib, unsigned short index_base_offset)
static RenderInfoClass * Render_Info
static void Set_Gamma(float gamma, float bright, float contrast, bool calibrate=true, bool uselimit=true)
static const char * Get_DX8_Cmp_Func_Name(unsigned value)
static IDirect3DSurface8 * _Create_DX8_Surface(unsigned int width, unsigned int height, WW3DFormat format)
static unsigned Get_Last_Frame_Light_Changes()
static unsigned Get_Last_Frame_Texture_Changes()
static bool Reset_Device(bool reload_assets=true)
static void Set_Vertex_Shader(DWORD vertex_shader)
static void Set_Pixel_Shader(DWORD pixel_shader)
static Vector4 Convert_Color(unsigned color)
static unsigned matrix_changes
static const char * Get_DX8_Patch_Edge_Style_Name(unsigned value)
static void Draw_Strip(unsigned short start_index, unsigned short index_count, unsigned short min_vertex_index, unsigned short vertex_count)
static Vector4 Vertex_Shader_Constants[MAX_VERTEX_SHADER_CONSTANTS]
static const char * Get_DX8_Debug_Monitor_Token_Name(unsigned value)
static const char * Get_DX8_Cull_Mode_Name(unsigned value)
static unsigned render_state_changes
static void End_Statistics()
static IDirect3DBaseTexture8 * Textures[MAX_TEXTURE_STAGES]
static unsigned Get_Last_Frame_Draw_Calls()
static int Get_Render_Device_Count(void)
static void Do_Onetime_Device_Dependent_Shutdowns(void)
static bool Set_Device_Resolution(int width=-1, int height=-1, int bits=-1, int windowed=-1, bool resize_window=false)
static const char * Get_DX8_Render_State_Name(D3DRENDERSTATETYPE state)
static void Set_Render_Target_With_Z(TextureClass *texture, ZTextureClass *ztexture=NULL)
static const char * Get_DX8_Blend_Name(unsigned value)
static IDirect3DDevice8 * D3DDevice
static void Get_Render_Target_Resolution(int &set_w, int &set_h, int &set_bits, bool &set_windowed)
static void Draw_Triangles(unsigned buffer_type, unsigned short start_index, unsigned short polygon_count, unsigned short min_vertex_index, unsigned short vertex_count)
static unsigned render_state_changed
static void Set_Viewport(CONST D3DVIEWPORT8 *pViewport)
static const char * Get_Render_Device_Name(int device_index)
static bool Has_Stencil(void)
static void Set_Material(const VertexMaterialClass *material)
static unsigned index_buffer_changes
static void Get_DX8_Render_State_Value_Name(StringClass &name, D3DRENDERSTATETYPE state, unsigned value)
static void Set_DX8_Light(int index, D3DLIGHT8 *light)
static unsigned Get_Last_Frame_Matrix_Changes()
static TextureClass * Create_Render_Target(int width, int height, WW3DFormat format=WW3D_FORMAT_UNKNOWN)
static IDirect3DTexture8 * _Create_DX8_ZTexture(unsigned int width, unsigned int height, WW3DZFormat zformat, MipCountType mip_level_count, D3DPOOL pool=D3DPOOL_MANAGED)
static void Set_Swap_Interval(int swap)
static const RenderDeviceDescClass & Get_Render_Device_Desc(int deviceidx)
friend class DX8VertexBufferClass
static bool CurrentDX8LightEnables[4]
static const D3DADAPTER_IDENTIFIER8 & Get_Current_Adapter_Identifier()
static bool Registry_Save_Render_Device(const char *sub_key)
static const char * Get_DX8_Blend_Op_Name(unsigned value)
static Matrix4x4 ProjectionMatrix
static void Apply_Render_State_Changes()
static void Set_DX8_Render_State(D3DRENDERSTATETYPE state, unsigned value)
static void Release_Render_State()
static IDirect3DSurface8 * DefaultDepthBuffer
static void Reset_Statistics()
static D3DMATRIX old_view
static Vector3 Ambient_Color
static bool Registry_Load_Render_Device(const char *sub_key, bool resize_window)
static DWORD Vertex_Shader
static unsigned Get_Last_Frame_Render_State_Changes()
static void Flush_DX8_Resource_Manager(unsigned int bytes=0)
static bool Find_Z_Mode(D3DFORMAT colorbuffer, D3DFORMAT backbuffer, D3DFORMAT *zmode)
static IDirect3D8 * D3DInterface
static IDirect3DVolumeTexture8 * _Create_DX8_Volume_Texture(unsigned int width, unsigned int height, unsigned int depth, WW3DFormat format, MipCountType mip_level_count, D3DPOOL pool=D3DPOOL_MANAGED)
static void Set_Render_Target(IDirect3DSurface8 *render_target, bool use_default_depth_buffer=false)
static const char * Get_DX8_Texture_Transform_Flag_Name(unsigned value)
static unsigned material_changes
static unsigned draw_calls
static Matrix4x4 DX8Transforms[D3DTS_WORLD+1]
static bool _EnableTriangleDraw
static bool Find_Color_And_Z_Mode(int resx, int resy, int bitdepth, D3DFORMAT *set_colorbuffer, D3DFORMAT *set_backbuffer, D3DFORMAT *set_zmode)
static int ResolutionHeight
static unsigned Get_Last_Frame_DX8_Calls()
static void Release_Device(void)
static unsigned Get_Last_Frame_Index_Buffer_Changes()
unsigned Get_Type() const
unsigned Get_Type() const
unsigned short Get_Vertex_Count() const
virtual bool Is_Available(int forced=false)=0
void Add_Engine_Ref() const
float Get_Intensity(void) const
void Get_Far_Attenuation_Range(double &fStart, double &fEnd) const
float Get_Spot_Exponent(void) const
void Get_Spot_Direction(Vector3 &dir) const
float Get_Spot_Angle(void) const
void Get_Ambient(Vector3 *set_c) const
void Get_Diffuse(Vector3 *set_c) const
void Get_Specular(Vector3 *set_c) const
float Get_Attenuation_Range(void) const
int Get_Light_Count(void) const
bool isPointLight(int i) const
const Vector3 & getPointDiffuse(int i) const
const Vector3 & getPointAmbient(int i) const
const Vector3 & Get_Light_Direction(int i) const
float getPointOrad(int i) const
const Vector3 & Get_Equivalent_Ambient(void) const
float getPointIrad(int i) const
const Vector3 & getPointCenter(int i) const
const Vector3 & Get_Light_Diffuse(int i) const
static IDirect3DSurface8 * _Create_Missing_Surface()
static IDirect3DTexture8 * _Get_Missing_Texture()
static void _Shutdown(void)
void Set_Int(const char *name, int value)
char * Get_String(const char *name, char *value, int value_size, const char *default_string=NULL)
void Set_String(const char *name, const char *value)
int Get_Int(const char *name, int def_value=0)
static void Set_Screen_Resolution(const RectClass &screen)
const DynamicVectorClass< ResolutionDescClass > & Enumerate_Resolutions(void) const
Vector3 Get_Position(void) const
static void Shutdown(void)
static void Insert_Triangles(const SphereClass &bounding_sphere, unsigned short start_index, unsigned short polygon_count, unsigned short min_vertex_index, unsigned short vertex_count)
int _cdecl Format(const TCHAR *format,...)
static void Apply_Null(unsigned int stage)
Apply NULL texture state.
IDirect3DBaseTexture8 * Peek_D3D_Base_Texture() const
Returns a pointer to the d3d texture.
static void Invalidate_Old_Unused_Textures(unsigned inactive_time_override)
Invalidate old unused textures.
PoolType Get_Pool() const
IDirect3DSurface8 * Get_D3D_Surface_Level(unsigned int level=0)
Get D3D surface from mip level.
static void _Init_Filters(TextureFilterMode texture_filter)
Init filters (legacy)
static IDirect3DSurface8 * Load_Surface_Immediate(const StringClass &filename, WW3DFormat surface_format, bool allow_compression)
static void Sleep_Ms(unsigned ms=0)
static unsigned _Get_Current_Thread_ID()
void Add_Engine_Ref() const
static bool Is_Snapshot_Activated()
static int Get_Texture_Filter()
static void _Invalidate_Textures()
static void _Invalidate_Mesh_Cache()
IDirect3DSurface8 * Get_D3D_Surface_Level(unsigned int level=0)
Get D3D surface from mip level.
int IndexBufferExceptionFunc(void)
DX8MeshRendererClass TheDX8MeshRenderer
const unsigned dynamic_fvf_type
IDirect3D8 *(WINAPI * Direct3DCreate8Type)(UINT SDKVersion)
const int DEFAULT_RESOLUTION_HEIGHT
const int DEFAULT_RESOLUTION_WIDTH
const int DEFAULT_BIT_DEPTH
void Log_DX8_ErrorCode(unsigned res)
void Non_Fatal_Log_DX8_ErrorCode(unsigned res, const char *file, int line)
const int DEFAULT_TEXTURE_BIT_DEPTH
Direct3DCreate8Type Direct3DCreate8Ptr
unsigned number_of_DX8_calls
const unsigned MAX_SHADOW_MAPS
#define DX8_RECORD_VERTEX_BUFFER_CHANGE()
@ BUFFER_TYPE_DYNAMIC_DX8
@ BUFFER_TYPE_DYNAMIC_SORTING
const unsigned MAX_PIXEL_SHADER_CONSTANTS
#define VALUE_NAME_RENDER_DEVICE_HEIGHT
const unsigned MAX_TEXTURE_STAGES
#define VALUE_NAME_RENDER_DEVICE_DEPTH
#define VALUE_NAME_RENDER_DEVICE_TEXTURE_DEPTH
#define DX8CALL_HRES(x, res)
#define DX8_RECORD_INDEX_BUFFER_CHANGE()
#define VALUE_NAME_RENDER_DEVICE_NAME
#define VALUE_NAME_RENDER_DEVICE_WINDOWED
#define DX8_RECORD_DRAW_CALLS()
unsigned number_of_DX8_calls
const unsigned MAX_VERTEX_STREAMS
#define DX8_THREAD_ASSERT()
WWINLINE void DX8_ErrorCode(unsigned res)
#define VALUE_NAME_RENDER_DEVICE_WIDTH
const unsigned MAX_VERTEX_SHADER_CONSTANTS
FileFactoryClass * _TheFileFactory
#define REF_PTR_RELEASE(x)
#define REF_PTR_SET(dst, src)
#define SHD_SHUTDOWN_SHADERS
unsigned vertex_buffer_types[MAX_VERTEX_STREAMS]
unsigned short index_base_offset
unsigned short vba_offset
unsigned index_buffer_type
VertexBufferClass * vertex_buffers[MAX_VERTEX_STREAMS]
#define WWASSERT_PRINT(expr, string)