...
 
Commits (6)
......@@ -9,9 +9,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SkyXEngine", "SkyXEngine.vc
{236F4A16-78D8-42E4-86C0-30265CA2D84D} = {236F4A16-78D8-42E4-86C0-30265CA2D84D}
{B9656841-7734-4D0B-8619-1BED5E2ED7AE} = {B9656841-7734-4D0B-8619-1BED5E2ED7AE}
{C1C1F046-C839-4602-AF70-923CDD237C1B} = {C1C1F046-C839-4602-AF70-923CDD237C1B}
{D2386C4E-7032-487B-8EAD-951778AD6EBC} = {D2386C4E-7032-487B-8EAD-951778AD6EBC}
{6FE14C5C-6052-4D96-A89F-0843D91F89AD} = {6FE14C5C-6052-4D96-A89F-0843D91F89AD}
{718C186E-9155-41DF-B8AB-74ED03E204CD} = {718C186E-9155-41DF-B8AB-74ED03E204CD}
{709D8A7A-D3E0-4070-A493-EFDF7A8E9D73} = {709D8A7A-D3E0-4070-A493-EFDF7A8E9D73}
{16D78A7B-8EE9-4FD3-84C9-B71D8723E718} = {16D78A7B-8EE9-4FD3-84C9-B71D8723E718}
{6A402480-C09B-4CBF-A6BD-115CE4BFF2D8} = {6A402480-C09B-4CBF-A6BD-115CE4BFF2D8}
{2B3BA583-D5EC-4DC2-91CF-42B1C7ADFD9D} = {2B3BA583-D5EC-4DC2-91CF-42B1C7ADFD9D}
{5145958A-F75F-4F6D-9793-7384B616CF76} = {5145958A-F75F-4F6D-9793-7384B616CF76}
......@@ -350,6 +352,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "core", "core", "{4408F4BE-1
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xWindow", "..\..\xWindow\vs2013\xWindow.vcxproj", "{16D78A7B-8EE9-4FD3-84C9-B71D8723E718}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xEngine", "..\..\xEngine\vs2013\xEngine.vcxproj", "{D2386C4E-7032-487B-8EAD-951778AD6EBC}"
ProjectSection(ProjectDependencies) = postProject
{C1C1F046-C839-4602-AF70-923CDD237C1B} = {C1C1F046-C839-4602-AF70-923CDD237C1B}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -995,6 +1002,20 @@ Global
{16D78A7B-8EE9-4FD3-84C9-B71D8723E718}.Release|Win32.Build.0 = Release|Win32
{16D78A7B-8EE9-4FD3-84C9-B71D8723E718}.Release|x64.ActiveCfg = Release|x64
{16D78A7B-8EE9-4FD3-84C9-B71D8723E718}.Release|x64.Build.0 = Release|x64
{D2386C4E-7032-487B-8EAD-951778AD6EBC}.Debug|Any CPU.ActiveCfg = Debug|Win32
{D2386C4E-7032-487B-8EAD-951778AD6EBC}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{D2386C4E-7032-487B-8EAD-951778AD6EBC}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{D2386C4E-7032-487B-8EAD-951778AD6EBC}.Debug|Win32.ActiveCfg = Debug|Win32
{D2386C4E-7032-487B-8EAD-951778AD6EBC}.Debug|Win32.Build.0 = Debug|Win32
{D2386C4E-7032-487B-8EAD-951778AD6EBC}.Debug|x64.ActiveCfg = Debug|x64
{D2386C4E-7032-487B-8EAD-951778AD6EBC}.Debug|x64.Build.0 = Debug|x64
{D2386C4E-7032-487B-8EAD-951778AD6EBC}.Release|Any CPU.ActiveCfg = Release|Win32
{D2386C4E-7032-487B-8EAD-951778AD6EBC}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{D2386C4E-7032-487B-8EAD-951778AD6EBC}.Release|Mixed Platforms.Build.0 = Release|Win32
{D2386C4E-7032-487B-8EAD-951778AD6EBC}.Release|Win32.ActiveCfg = Release|Win32
{D2386C4E-7032-487B-8EAD-951778AD6EBC}.Release|Win32.Build.0 = Release|Win32
{D2386C4E-7032-487B-8EAD-951778AD6EBC}.Release|x64.ActiveCfg = Release|x64
{D2386C4E-7032-487B-8EAD-951778AD6EBC}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......@@ -1055,5 +1076,6 @@ Global
{C3CAABF6-9239-4133-86E3-44DF79A67AF6} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{4408F4BE-1F9D-4861-881A-AF9869C3D663} = {E6B16854-D4A4-4B56-8E1C-482DD523F205}
{16D78A7B-8EE9-4FD3-84C9-B71D8723E718} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{D2386C4E-7032-487B-8EAD-951778AD6EBC} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
EndGlobalSection
EndGlobal
......@@ -182,7 +182,12 @@
<ClCompile Include="..\..\..\source\common\file_utils.cpp" />
<ClCompile Include="..\..\..\source\common\string.cpp" />
<ClCompile Include="..\..\..\source\common\string_utils.cpp" />
<ClCompile Include="..\..\..\source\skyxengine.cpp" />
<ClCompile Include="..\..\..\source\skyxengine.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\source\SkyXEngine_Build\SkyXEngine_Build.cpp" />
</ItemGroup>
<ItemGroup>
......
......@@ -82,6 +82,7 @@
<ClInclude Include="..\..\..\source\core\FileExtIterator.h" />
<ClInclude Include="..\..\..\source\core\FileSystem.h" />
<ClInclude Include="..\..\..\source\core\IFile.h" />
<ClInclude Include="..\..\..\source\core\ITask.h" />
<ClInclude Include="..\..\..\source\core\ModelPhysbox.h" />
<ClInclude Include="..\..\..\source\core\ModelProvider.h" />
<ClInclude Include="..\..\..\source\core\PerfMon.h" />
......
......@@ -230,5 +230,8 @@
<ClInclude Include="..\..\..\source\core\DirIterator.h">
<Filter>Header</Filter>
</ClInclude>
<ClInclude Include="..\..\..\source\core\ITask.h">
<Filter>Header</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
......@@ -102,7 +102,7 @@
</PrecompiledHeader>
<WarningLevel>TurnOffAllWarnings</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;SX_TERRAX;_DEBUG;_WINDOWS;SX_LEVEL_EDITOR;%(PreprocessorDefinitions);SX_LIB_NAME="LEd"</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;SX_TERRAX;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);SX_LIB_NAME="LEd"</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<TreatSpecificWarningsAsErrors>4316</TreatSpecificWarningsAsErrors>
......@@ -122,7 +122,7 @@
</PrecompiledHeader>
<WarningLevel>TurnOffAllWarnings</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN64;SX_TERRAX;_DEBUG;_WINDOWS;SX_LEVEL_EDITOR;%(PreprocessorDefinitions);SX_LIB_NAME="LEd"</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN64;SX_TERRAX;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);SX_LIB_NAME="LEd"</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<TreatSpecificWarningsAsErrors>4316</TreatSpecificWarningsAsErrors>
......@@ -144,7 +144,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;SX_TERRAX;NDEBUG;_WINDOWS;SX_LEVEL_EDITOR;%(PreprocessorDefinitions);SX_LIB_NAME="LEd"</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;SX_TERRAX;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);SX_LIB_NAME="LEd"</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<TreatSpecificWarningsAsErrors>4316</TreatSpecificWarningsAsErrors>
</ClCompile>
......@@ -166,7 +166,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN64;SX_TERRAX;NDEBUG;_WINDOWS;SX_LEVEL_EDITOR;%(PreprocessorDefinitions);SX_LIB_NAME="LEd"</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN64;SX_TERRAX;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);SX_LIB_NAME="LEd"</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<TreatSpecificWarningsAsErrors>4316</TreatSpecificWarningsAsErrors>
</ClCompile>
......@@ -185,7 +185,12 @@
<ClCompile Include="..\..\..\source\common\string.cpp" />
<ClCompile Include="..\..\..\source\common\string_utils.cpp" />
<ClCompile Include="..\..\..\source\editors_utils\axes_helper.cpp" />
<ClCompile Include="..\..\..\source\skyxengine.cpp" />
<ClCompile Include="..\..\..\source\skyxengine.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\source\terrax\CommandCreate.cpp" />
<ClCompile Include="..\..\..\source\terrax\CommandDelete.cpp" />
<ClCompile Include="..\..\..\source\terrax\CommandMove.cpp" />
......
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{64F1C0A1-FD70-4BB3-A416-9E837DB83ABF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{9716DBB9-40A3-4B19-9021-6A43891C7C47}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{D803C3FB-1FFC-48E8-96BC-B4BAF6677D26}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\source\xEngine\Engine.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\source\xEngine\dllmain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\source\xEngine\CommandLineToArgvA.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\source\common\string.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\source\xEngine\Engine.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\source\xEngine\IXEngine.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
Subproject commit 0a387ab423ddb88a8f3afb2acffe84fe4954c880
Subproject commit 1b61ddaa21f3f9a943026d04b39fa6cc834436e5
......@@ -387,12 +387,12 @@ QT стиль документирования (!) и QT_AUTOBRIEF - корот
#endif
#include <decals/sxdecals.h>
#if defined(_DEBUG)
#pragma comment(lib, "sxlevel_d.lib")
#else
#pragma comment(lib, "sxlevel.lib")
#endif
#include <level/sxlevel.h>
//#if defined(_DEBUG)
//#pragma comment(lib, "sxlevel_d.lib")
//#else
//#pragma comment(lib, "sxlevel.lib")
//#endif
//#include <level/sxlevel.h>
#if defined(_DEBUG)
#pragma comment(lib, "sxgame_d.lib")
......@@ -446,7 +446,7 @@ QT стиль документирования (!) и QT_AUTOBRIEF - корот
@{*/
//! инициализация движка
void SkyXEngine_Init(HWND hWnd3D = 0, HWND hWndParent3D = 0, const char * szCmdLine = NULL);
// void SkyXEngine_Init(HWND hWnd3D = 0, HWND hWndParent3D = 0, const char * szCmdLine = NULL);
//! инициализация путей в регистрах
void SkyXEngine_InitPaths();
......@@ -489,7 +489,7 @@ int SkyXEngine_CycleMain();
bool SkyXEngine_CycleMainIteration();
//! уничтожение данных движка, освобождение памяти
void SkyXEngine_Kill();
// void SkyXEngine_Kill();
//**************************************************************************
......
......@@ -9,73 +9,151 @@ See the license in LICENSE
#include <SkyXEngine.h>
//#include <common/string_func.h>
#if 0
#include <xWindow/IXWindowSystem.h>
#include <xEngine/IXEngine.h>
#ifdef _DEBUG
# pragma comment(lib, "xWindow_d.lib")
# pragma comment(lib, "xEngine_d.lib")
#else
# pragma comment(lib, "xWindow.lib")
# pragma comment(lib, "xEngine.lib")
#endif
class CWindowCallback: public IXWindowCallback
{
public:
INT_PTR XMETHODCALLTYPE onMessage(UINT msg, WPARAM wParam, LPARAM lParam, IXWindow *pWindow)
CWindowCallback(IXEngine *pEngine):
m_pEngine(pEngine)
{
return(pWindow->runDefaultCallback(msg, wParam, lParam));
}
INT_PTR XMETHODCALLTYPE onMessage(UINT msg, WPARAM wParam, LPARAM lParam, IXWindow *pWindow) override
{
if(m_pEngine->onMessage(msg, wParam, lParam))
{
return(TRUE);
}
switch(msg)
{
case WM_CLOSE:
PostQuitMessage(0);
break;
case WM_SYSKEYDOWN:
case WM_SYSKEYUP:
// системная обработка F10 (вызов меню) не надо, останавливает главный цикл
if(wParam == VK_F10)
{
return(0);
}
// системная обработка Alt (вызов меню) не надо, останавливает главный цикл
if((wParam == VK_MENU || wParam == VK_LMENU || wParam == VK_RMENU)
&& GetKeyState(VK_TAB) < 0)
{
return(0);
}
break;
default:
return(pWindow->runDefaultCallback(msg, wParam, lParam));
}
return(0);
}
protected:
IXEngine *m_pEngine;
};
class CEngineCallback: public IXEngineCallback
{
public:
CEngineCallback(IXWindowSystem *pWindowSystem, IXWindow *pWindow):
m_pWindow(pWindow),
m_pWindowSystem(pWindowSystem)
{}
void XMETHODCALLTYPE onGraphicsResize(UINT uWidth, UINT uHeight, bool isFullscreen, bool isBorderless, IXEngine *pEngine) override
{
XWINDOW_DESC wdesc = *m_pWindow->getDesc();
if(isFullscreen || isBorderless)
{
wdesc.iPosX = 0;
wdesc.iPosY = 0;
}
else if(wdesc.iPosX == 0 && wdesc.iPosY == 0)
{
wdesc.iPosX = XCW_CENTER;
wdesc.iPosY = XCW_CENTER;
}
wdesc.iSizeX = (int)uWidth;
wdesc.iSizeY = (int)uHeight;
wdesc.flags = XWF_BUTTON_CLOSE | XWF_BUTTON_MINIMIZE | XWF_NORESIZE;
if(isFullscreen || isBorderless)
{
wdesc.flags |= XWF_NOBORDER;
}
else
{
wdesc.flags &= ~XWF_NOBORDER;
}
m_pWindow->update(&wdesc);
}
bool XMETHODCALLTYPE processWindowMessages() override
{
return(m_pWindowSystem->processMessages());
}
ICamera* XMETHODCALLTYPE getCameraForFrame() override
{
return(SGame_GetActiveCamera());
}
protected:
IXWindowSystem *m_pWindowSystem;
IXWindow *m_pWindow;
};
#endif
#if defined(_WINDOWS)
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
#if 0
UNREFERENCED_PARAMETER(hPrevInstance);
int argc;
char **argv = CommandLineToArgvA(lpCmdLine, &argc);
#else
int main(int argc, char **argv)
{
#endif
IXEngine *pEngine = XEngineInit(argc, argv, "build");
IXWindowSystem *pWindowSystem = XWindowInit();
CWindowCallback cb(pEngine);
XWINDOW_DESC wdesc;
wdesc.iPosX = XCW_USEDEFAULT;
wdesc.iPosY = XCW_USEDEFAULT;
wdesc.iPosX = XCW_CENTER;
wdesc.iPosY = XCW_CENTER;
wdesc.iSizeX = 800;
wdesc.iSizeY = 600;
wdesc.szTitle = "xWindow";
wdesc.szTitle = "SkyXEngine build";
wdesc.flags = XWF_BUTTON_CLOSE | XWF_BUTTON_MINIMIZE | XWF_NORESIZE;
CWindowCallback cb;
IXWindow *pWindow = pWindowSystem->createWindow(&wdesc, &cb);
CEngineCallback engineCb(pWindowSystem, pWindow);
while(pWindowSystem->processMessages())
{
Sleep(10);
}
mem_release(pWindow);
mem_release(pWindowSystem);
return(0);
#endif
pEngine->initGraphics(pWindow->getOSHandle(), &engineCb);
// pEngine->initServer();
//MessageBox(0, 0, 0, 0);
SkyXEngine_PreviewCreate();
SkyXEngine_Init(0, 0, lpCmdLine);
SkyXEngine_PreviewKill();
SGCore_SkyBoxLoadTex("sky_2_cube.dds");
SGCore_SkyCloudsLoadTex("sky_oblaka.dds");
SGCore_SkyBoxSetUse(false);
SGCore_SkyCloudsSetUse(false);
//SGCore_OC_SetEnable(false);
pEngine->getCore()->execCmd("exec ../config_game.cfg");
pEngine->getCore()->execCmd("exec ../config_game_user.cfg");
SGreen_0SettSetFreqGrass(100);
int ret = pEngine->start();
SGCore_ShaderAllLoad();
SGCore_LoadTexAllLoad();
SetWindowPos((HWND)SGCore_GetHWND(), HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
SLevel_AmbientSndPlay();
SLevel_WeatherSndPlay();
int result = SkyXEngine_CycleMain();
SkyXEngine_Kill();
return result;
}
\ No newline at end of file
mem_release(pWindow);
mem_release(pEngine);
return(ret);
}
......@@ -2517,13 +2517,13 @@ void CAIGrid::renderQuads(const IFrustum * frustum, const float3 * viewpos, floa
RTGPUArrVerteces[tmpkey].m_vPos = aq->m_vPos;
if(quadSelectedExists(aq->m_id))
RTGPUArrVerteces[tmpkey].m_vColor = GXCOLOR_COLORVECTOR_ARGB(AIGRID_COLOR_SEL_MAIN);
RTGPUArrVerteces[tmpkey].m_vColor = GXCOLOR_COLOR_TO_F4(AIGRID_COLOR_SEL_MAIN);
else if(quadSelectedExistsNeightborDirect(aq->m_id))
RTGPUArrVerteces[tmpkey].m_vColor = GXCOLOR_COLORVECTOR_ARGB(AIGRID_COLOR_SEL_ADD);
RTGPUArrVerteces[tmpkey].m_vColor = GXCOLOR_COLOR_TO_F4(AIGRID_COLOR_SEL_ADD);
else if(m_uiCountSplits > 0 && m_isMarkSplits)
RTGPUArrVerteces[tmpkey].m_vColor = GXCOLOR_COLORVECTOR_ARGB(m_aSplitsColor[aq->m_iSplit - 1]);
RTGPUArrVerteces[tmpkey].m_vColor = GXCOLOR_COLOR_TO_F4(m_aSplitsColor[aq->m_iSplit - 1]);
else
RTGPUArrVerteces[tmpkey].m_vColor = GXCOLOR_COLORVECTOR_ARGB(m_aQuadColors[aq->m_id]);
RTGPUArrVerteces[tmpkey].m_vColor = GXCOLOR_COLOR_TO_F4(m_aQuadColors[aq->m_id]);
/*if (aq->m_iSplit > 1)
{
......@@ -2571,7 +2571,7 @@ void CAIGrid::renderQuads(const IFrustum * frustum, const float3 * viewpos, floa
else
{
RTGPUArrVerteces[tmpkey].m_vTC = float4_t(1, 1, 0, 0);
RTGPUArrVerteces[tmpkey].m_vColor = GXCOLOR_COLORVECTOR_ARGB(GXCOLOR_ARGB(255, 255, 0, 0));
RTGPUArrVerteces[tmpkey].m_vColor = GXCOLOR_COLOR_TO_F4(GXCOLOR_ARGB(255, 255, 0, 0));
}
++tmpkey;
......@@ -2664,7 +2664,7 @@ void CAIGrid::renderGraphPoints(const float3 * viewpos, float dist)
else
RTGPUArrVerteces[tmpkey].m_vTC = float4_t(1, 1, 0, 0);
RTGPUArrVerteces[tmpkey].m_vColor = GXCOLOR_COLORVECTOR_ARGB(GXCOLOR_ARGB(200, 0, 0, 255));
RTGPUArrVerteces[tmpkey].m_vColor = GXCOLOR_COLOR_TO_F4(GXCOLOR_ARGB(200, 0, 0, 255));
++tmpkey;
}
}
......
Subproject commit 2a6e670568d82f84ac13dab3e0d3ba1f3f5b62d8
Subproject commit 7cede65f80bedb0747835179fd6fbab89509f9a1
......@@ -6,7 +6,7 @@
#include "TaskManager.h"
extern CTaskManager *g_pTaskManager;
class CIOTask: public ITask
class CIOTask: public ITaskImpl<ITask>
{
public:
CIOTask(const char *szFile, IFileSystem *pFileSystem, IAsyncFileReaderCallback *pCallback):
......@@ -71,9 +71,9 @@ CAsyncFileReader::~CAsyncFileReader()
void CAsyncFileReader::loadFile(const char *szFile, IAsyncFileReaderCallback *pCallback)
{
CIOTask *pTask = new CIOTask(szFile, m_pFileSystem, pCallback);
ITask::TaskPtr ptr(pTask);
m_vpQueue.push_back(ptr);
g_pTaskManager->addTaskIO(ptr);
m_vpQueue.push_back(pTask);
pTask->AddRef();
g_pTaskManager->addTaskIO(pTask);
}
void CAsyncFileReader::runCallbacks()
......@@ -81,7 +81,7 @@ void CAsyncFileReader::runCallbacks()
CIOTask *pTask;
for(UINT i = 0, l = m_vpQueue.size(); i < l; ++i)
{
pTask = (CIOTask*)m_vpQueue[i].get();
pTask = (CIOTask*)m_vpQueue[i];
if(pTask->isDone())
{
if(pTask->m_pResult)
......@@ -93,6 +93,7 @@ void CAsyncFileReader::runCallbacks()
{
pTask->m_pCallback->onError();
}
mem_release(pTask);
m_vpQueue.erase(i);
--i; --l;
......
......@@ -18,7 +18,7 @@ protected:
IXCore *m_pCore;
IFileSystem *m_pFileSystem = NULL;
Array<ITask::TaskPtr> m_vpQueue;
Array<ITask*> m_vpQueue;
};
#endif
......@@ -4,8 +4,40 @@
#include "FileSystem.h"
#include "ModelProvider.h"
CCore::CCore()
#include "concmd.h"
#include "TaskManager.h"
#include "PerfMon.h"
#include "time.h"
#include <GRegisterIndex.h>
extern CTimeManager *g_pTimers;
extern CPerfMon *g_pPerfMon;
extern CCore *g_pCore;
extern CTaskManager *g_pTaskManager;
CCore::CCore(const char *szName)
{
ConsoleConnect(szName);
ConsoleRegisterCmds();
Core_0RegisterCVarBool("g_time_run", true, "Запущено ли игрвоое время?", FCVAR_NOTIFY);
Core_0RegisterCVarFloat("g_time_speed", 1.f, "Скорость/соотношение течения игрового времени", FCVAR_NOTIFY);
Core_0RegisterCVarBool("dbg_config_save", false, "Отладочный вывод процесса сохранения конфига");
Core_0RegisterCVarInt("r_stats", 1, "Показывать ли статистику? 0 - нет, 1 - fps и игровое время, 2 - показать полностью");
Core_0RegisterConcmd("on_g_time_run_change", []()
{
static const bool * g_time_run = GET_PCVAR_BOOL("g_time_run");
Core_TimeWorkingSet(Core_RIntGet(G_RI_INT_TIMER_GAME), *g_time_run);
});
Core_0RegisterConcmd("on_g_time_speed_change", []()
{
static const float * g_time_speed = GET_PCVAR_FLOAT("g_time_speed");
Core_TimeSpeedSet(Core_RIntGet(G_RI_INT_TIMER_GAME), *g_time_speed);
});
m_pPluginManager = new CPluginManager();
m_pFileSystem = new CFileSystem();
......@@ -13,12 +45,46 @@ CCore::CCore()
m_pModelProvider = new CModelProvider(this);
m_pPluginManager->registerInterface(IXMODELPROVIDER_GUID, m_pModelProvider);
g_pPerfMon = m_pPerfMon = new CPerfMon();
g_pTimers = m_pTimers = new CTimeManager();
ID idTimerRender = Core_TimeAdd();
ID idTimerGame = Core_TimeAdd();
Core_RIntSet(G_RI_INT_TIMER_RENDER, idTimerRender);
Core_RIntSet(G_RI_INT_TIMER_GAME, idTimerGame);
tm ct = {0, 0, 10, 27, 5, 2030 - 1900, 0, 0, 0};
Core_TimeUnixStartSet(idTimerGame, mktime(&ct));
Core_TimeWorkingSet(idTimerRender, true);
Core_TimeWorkingSet(idTimerGame, true);
Core_TimeSpeedSet(idTimerGame, 10);
int iThreadNum = 0;
if(!sscanf(Core_0GetCommandLineArg("threads", "0"), "%d", &iThreadNum) || iThreadNum < 0)
{
LibReport(REPORT_MSG_LEVEL_WARNING, "Invalid -threads value! Defaulting to 0\n");
}
g_pTaskManager = m_pTaskManager = new CTaskManager(iThreadNum);
if(strcasecmp(Core_0GetCommandLineArg("no-threads", "no"), "no"))
{
m_pTaskManager->forceSinglethreaded();
}
loadPlugins();
}
CCore::~CCore()
{
shutdownUpdatable();
mem_delete(m_pTaskManager);
mem_delete(m_pTimers);
mem_delete(m_pPerfMon);
mem_delete(m_pModelProvider);
mem_delete(m_pResourceManager);
mem_delete(m_pFileSystem);
......@@ -27,12 +93,8 @@ CCore::~CCore()
{
mem_delete(*i.second);
}
}
void CCore::Release()
{
--m_uRefCount;
assert(m_uRefCount && "You MUST NOT explicitly call Release on IXCore interface");
ConsoleDisconnect();
}
IPluginManager *CCore::getPluginManager()
......@@ -182,7 +244,97 @@ void CCore::shutdownUpdatable()
}
}
UINT_PTR CCore::getCrtOutputHandler()
UINT_PTR XMETHODCALLTYPE CCore::getCrtOutputHandler()
{
return(Core_ConsoleGetOutHandler());
}
//! @FIXME Remove that!
extern std::mutex g_conUpdMtx;
extern CConcurrentQueue<char*> g_vCommandBuffer;
void XMETHODCALLTYPE CCore::execCmd(const char *szCommand)
{
execCmd2("%s", szCommand);
}
void CCore::execCmd2(const char * szFormat, ...)
{
va_list va;
va_start(va, szFormat);
size_t len = _vscprintf(szFormat, va) + 1;
char * buf, *cbuf = NULL;
if(len < 4096)
{
buf = (char*)alloca(len * sizeof(char));
}
else
{
cbuf = buf = new char[len];
}
vsprintf(buf, szFormat, va);
va_end(va);
//g_vCommandBuffer
char * nl;
do
{
nl = strstr(buf, "\n");
if(nl)
{
*nl = 0;
++nl;
while(isspace(*buf))
{
++buf;
}
if(!(*buf == '/' && *(buf + 1) == '/') && (len = strlen(buf)))
{
char * str = new char[len + 1];
memcpy(str, buf, len + 1);
g_conUpdMtx.lock();
g_vCommandBuffer.push(str);
g_conUpdMtx.unlock();
}
buf = nl;
}
}
while(nl);
while(isspace(*buf))
{
++buf;
}
if(!(*buf == '/' && *(buf + 1) == '/') && (len = strlen(buf)))
{
char * str = new char[len + 1];
memcpy(str, buf, len + 1);
g_conUpdMtx.lock();
g_vCommandBuffer.push(str);
g_conUpdMtx.unlock();
}
mem_delete_a(cbuf);
}
//##########################################################################
C SXCORE_API IXCore* XCoreInit(const char *szName)
{
return(g_pCore = new CCore(szName));
}
C SXCORE_API void XCoreStart()
{
g_pTaskManager->start();
}
C SXCORE_API void XCoreStop()
{
g_pTaskManager->stop();
}
C SXCORE_API void XCoreAddTask(ITask *pTask)
{
g_pTaskManager->addTask(pTask);
}
......@@ -9,15 +9,16 @@
#include "ResourceManager.h"
class CModelProvider;
class CPerfMon;
class CTimeManager;
class CTaskManager;
class CCore: public IXCore
{
public:
CCore();
CCore(const char *szName);
~CCore();
void XMETHODCALLTYPE Release() override;
IPluginManager * XMETHODCALLTYPE getPluginManager() override;
IFileSystem * XMETHODCALLTYPE getFileSystem() override;
IXResourceManager * XMETHODCALLTYPE getResourceManager() override;
......@@ -34,7 +35,10 @@ public:
void shutdownUpdatable();
void runUpdate() override;
UINT_PTR getCrtOutputHandler() override;
UINT_PTR XMETHODCALLTYPE getCrtOutputHandler() override;
void XMETHODCALLTYPE execCmd(const char *szCommand) override;
void execCmd2(const char * szFormat, ...) override;
protected:
IBaseEventChannel *getEventChannelInternal(const XGUID &guid) override;
......@@ -54,6 +58,10 @@ protected:
};
Array<_update_sys> m_aUpdatables;
CPerfMon *m_pPerfMon = NULL;
CTimeManager *m_pTimers = NULL;
CTaskManager *m_pTaskManager = NULL;
};
#endif
/***********************************************************
Copyright © Vitaliy Buturlin, Evgeny Danilovich, 2017, 2018
See the license in LICENSE
***********************************************************/
#ifndef __ITASK_H
#define __ITASK_H
#include "sxcore.h"
#include <memory>
#define _NTASKMANAGER
class ITask: public IXUnknown
{
public:
virtual ~ITask() = default;
virtual void run() = 0;
virtual void stopRepeating() = 0;
virtual UINT getFlags() = 0;
};
template<class T>
class ITaskImpl: public T
{
public:
ITaskImpl(UINT uFlags = CORE_TASK_FLAG_MAINTHREAD_REPEATING):
m_uFlags(uFlags)
{
}
void stopRepeating() override
{
m_uFlags &= ~CORE_TASK_FLAG_REPEATING;
}
UINT getFlags() override
{
return(m_uFlags);
}
private:
UINT m_uFlags;
};
#endif
......@@ -6,8 +6,6 @@
CPluginManager::~CPluginManager()
{
//@FIXME: !!!
return;
for(UINT i = 0, l = m_aPlugins.size(); i < l; ++i)
{
m_aPlugins[i]->shutdown();
......
/***********************************************************
Copyright Vitaliy Buturlin, Evgeny Danilovich, 2017, 2018
Copyright © Vitaliy Buturlin, Evgeny Danilovich, 2017, 2018
See the license in LICENSE
***********************************************************/
#include "task.h"
ITask::ITask(UINT flags):
m_iFlags(flags)
{
}
UINT ITask::getFlags() const
{
return(m_iFlags);
}
//##########################################################################
CTask::CTask(THREAD_UPDATE_FUNCTION func, UINT flags):
ITask(flags),
ITaskImpl(flags),
m_fnUpdateFunc(func)
{
assert(m_fnUpdateFunc);
}
void CTask::run()
{
if(m_fnUpdateFunc)
{
m_fnUpdateFunc();
}
m_fnUpdateFunc();
}
......@@ -7,36 +7,12 @@ See the license in LICENSE
#ifndef __TASK_H
#define __TASK_H
#include "sxcore.h"
#include <memory>
#define _NTASKMANAGER
class ITask
{
public:
typedef std::shared_ptr<ITask> TaskPtr;
ITask(UINT iFlags = CORE_TASK_FLAG_MAINTHREAD_REPEATING);
virtual ~ITask(){}
virtual void run() = 0;
void stopRepeating()
{
m_iFlags &= ~CORE_TASK_FLAG_REPEATING;
}
UINT getFlags() const;
private:
UINT m_iFlags;
};
#include "ITask.h"
// Ѕазовый класс задачи
class CTask: public ITask
class CTask: public ITaskImpl<ITask>
{
public:
CTask(THREAD_UPDATE_FUNCTION fnFunc, UINT iFlags = CORE_TASK_FLAG_MAINTHREAD_REPEATING);
void run();
......
......@@ -30,11 +30,11 @@ static void SetThreadName(DWORD dwThreadID, const char *threadName)
}
#endif
class CTaskForLoop: public ITask
class CTaskForLoop: public ITaskImpl<ITask>
{
public:
CTaskForLoop(ID id, const IParallelForBody *pBody, int iStart, int iEnd, UINT iFlags = CORE_TASK_FLAG_FOR_LOOP | CORE_TASK_FLAG_THREADSAFE):
ITask(iFlags),
ITaskImpl(iFlags),
m_id(id),
m_pBody(pBody),
m_iStart(iStart),
......@@ -59,6 +59,23 @@ protected:
int m_iEnd;
};
//##########################################################################
class CTaskStub: public ITaskImpl<ITask>
{
public:
CTaskStub():
ITaskImpl(CORE_TASK_FLAG_BACKGROUND)
{
}
void run()
{
}
};
//##########################################################################
CTaskManager::CTaskManager(unsigned int numThreads):
m_isSingleThreaded(false),
m_isRunning(false)
......@@ -92,7 +109,7 @@ void CTaskManager::forceSinglethreaded()
return;
}
m_isSingleThreaded = true;
m_iNumThreads = 0;
m_iNumThreads = 1;
}
void CTaskManager::addTask(TaskPtr task)
......@@ -121,7 +138,8 @@ void CTaskManager::addTask(TaskPtr task)
m_TaskList[m_iWriteList].push(task);
}
}
//notifyWorkers();
//printf("addTask()\n");
notifyWorkers();
}
void CTaskManager::addTaskIO(TaskPtr task)
......@@ -133,7 +151,9 @@ void CTaskManager::addTaskIO(TaskPtr task)
void CTaskManager::add(THREAD_UPDATE_FUNCTION fnFunc, DWORD dwFlag)
{
addTask(CTaskManager::TaskPtr(new CTask(fnFunc, dwFlag)));
TaskPtr pTask = new CTask(fnFunc, dwFlag);
addTask(pTask);
// mem_release(pTask);
}
void CTaskManager::start()
......@@ -146,7 +166,7 @@ void CTaskManager::start()
assert(idThread == 0);
//< Инициализируем пул рабочих потоков
for(unsigned int i = 0; i < m_iNumThreads; ++i)
for(unsigned int i = 0; i < m_iNumThreads - 1; ++i)
{
std::thread * t = new std::thread(std::bind(&CTaskManager::workerMain, this));
#if defined(_WINDOWS)
......@@ -172,34 +192,39 @@ void CTaskManager::start()
}
else
{
if(m_isSingleThreaded)
{
// if(m_isSingleThreaded)
// {
worker(true);
}
// }
synchronize();
std::swap(m_iReadList, m_iWriteList);
if(m_isSingleThreaded)
/*if(m_isSingleThreaded)
{
worker(true);
}
*/
m_aiNumWaitFor.clearFast();
sheduleNextBunch();
}
std::this_thread::yield();
//std::this_thread::yield();
}
}
void CTaskManager::synchronize()
{
std::unique_lock<std::mutex> lock(m_mutexSync);
while(!m_OnSyncTasks.empty())
{
execute(m_OnSyncTasks.pop());
}
/*std::unique_lock<std::mutex> lock(m_mutexSync);
while(m_iNumTasksToWaitFor > 0)
{
......@@ -213,7 +238,9 @@ void CTaskManager::synchronize()
m_BackgroundTasks.push(m_OnSyncTasks.pop());
++m_iNumTasksToWaitFor;
}
//notifyWorkers();
//printf("synchronize()\n");
notifyWorkers();
*/
}
void CTaskManager::sheduleNextBunch()
......@@ -232,18 +259,30 @@ void CTaskManager::sheduleNextBunch()
m_BackgroundTasks.push(m_SyncTasks.pop());
++m_iNumTasksToWaitFor;
}
//notifyWorkers();
//printf("sheduleNextBunch()\n");
notifyWorkers(min(getThreadCount(), m_iNumTasksToWaitFor));
}
void CTaskManager::stop()
{
m_isRunning = false;
m_ConditionIOThread.notify_all();
m_ConditionWorker.notify_all();
ITask *pStubTask = new CTaskStub();
for(int i = 0, l = m_aThreads.size() - 1; i < l; ++i)
{
pStubTask->AddRef();
}
for(int i = 0, l = m_aThreads.size(); i < l; ++i)
{
addTask(pStubTask);
}
for(int i = 0, l = m_aThreads.size(); i < l; ++i)
{
m_aThreads[i]->join();
delete m_aThreads[i];
mem_delete(m_aThreads[i]);
}
m_aThreads.clear();
if(m_pIOThread)
......@@ -261,6 +300,10 @@ void CTaskManager::execute(TaskPtr t)
{
addTask(t);
}
else
{
mem_release(t);
}
}
void CTaskManager::workerMain()
......@@ -281,11 +324,24 @@ void CTaskManager::worker(bool bOneRun)
while(m_isRunning)
{
if(m_BackgroundTasks.tryPop(task))
if(bOneRun)
{
if(!m_BackgroundTasks.tryPop(task))
{
return;
}
}
else
{
task = m_BackgroundTasks.pop();
}
//if(m_BackgroundTasks.tryPop(task))
{
//printf("#%d: Executing task\n", Core_MGetThreadID());
task->AddRef();
execute(task);
if(task->getFlags() & (CORE_TASK_FLAG_FRAME_SYNC | CORE_TASK_FLAG_ON_SYNC))
if(task->getFlags() & (CORE_TASK_FLAG_FRAME_SYNC/* | CORE_TASK_FLAG_ON_SYNC*/))
{
{
std::lock_guard<std::mutex> lock(m_mutexSync);
......@@ -299,29 +355,32 @@ void CTaskManager::worker(bool bOneRun)
{
{
std::lock_guard<std::mutex> lock(m_mutexFor);
m_aiNumWaitFor[std::static_pointer_cast<CTaskForLoop, ITask>(task)->getID()] -= 1;
m_aiNumWaitFor[((CTaskForLoop*)task)->getID()] -= 1;
//m_aiNumWaitFor[std::static_pointer_cast<CTaskForLoop, ITask>(task)->getID()] -= 1;
}
m_ConditionFor.notify_one();
}
std::this_thread::yield();
mem_release(task);
//std::this_thread::yield();
}
else
/*else
{
if(bOneRun)
{
return;
}
//{
// std::unique_lock<std::mutex> lock(m_mutexWorker[Core_MGetThreadID()]);
// m_ConditionWorker[Core_MGetThreadID()].wait(lock);
//}
std::this_thread::yield();
//printf("#%d: Sleeping\n", Core_MGetThreadID());
{
std::unique_lock<std::mutex> lock(m_mutexWorker);
m_ConditionWorker.wait(lock);
}
//printf("#%d: Waked up\n", Core_MGetThreadID());
// std::this_thread::yield();
//std::this_thread::sleep_for(std::chrono::microseconds(166));
}
}*/
}
}
......@@ -372,7 +431,9 @@ ID CTaskManager::forLoop(int iStart, int iEnd, const IParallelForBody *pBody, in
while(iTotal > 0)
{
iCur = (std::min)(iTotal, iChunkSize);
addTask(TaskPtr(new CTaskForLoop(id, pBody, iStart, iStart + iCur)));
TaskPtr pTask = new CTaskForLoop(id, pBody, iStart, iStart + iCur);
addTask(pTask);
// mem_release(pTask);
iTotal -= iCur;
iStart += iCur;
}
......@@ -392,13 +453,13 @@ void CTaskManager::waitFor(ID id)
}
}
//void CTaskManager::notifyWorkers()
//{
// for(int i = 0; i < m_iNumThreads; ++i)
// {
// m_ConditionWorker[i].notify_one();
// }
//}
void CTaskManager::notifyWorkers(UINT uCount)
{
for(UINT i = 0; i < uCount; ++i)
{
m_ConditionWorker.notify_one();
}
}
//##########################################################################
......
......@@ -22,7 +22,7 @@ const DWORD MS_VC_EXCEPTION = 0x406D1388;
typedef struct tagTHREADNAME_INFO
{
DWORD dwType; // Must be 0x1000.
const char * szName; // Pointer to name (in user addr space).
const char *szName; // Pointer to name (in user addr space).
DWORD dwThreadID; // Thread ID (-1=caller thread).
DWORD dwFlags; // Reserved for future use, must be zero.
} THREADNAME_INFO;
......@@ -33,7 +33,7 @@ typedef struct tagTHREADNAME_INFO
class CTaskManager
{
public:
typedef std::shared_ptr<ITask> TaskPtr;
typedef ITask *TaskPtr;
typedef CConcurrentQueue<TaskPtr> TaskList;
CTaskManager(unsigned int numThreads = 0); //< Количество рабочих потоков, 0 для автоопределения
......@@ -65,7 +65,7 @@ private:
void execute(TaskPtr task);
void synchronize();
void sheduleNextBunch();
//void notifyWorkers();
void notifyWorkers(UINT uCount = 1);
Array<std::thread*> m_aThreads;
std::thread* m_pIOThread;
......@@ -73,7 +73,7 @@ private:
bool m_isRunning;
TaskList m_TaskList[2]; //!< В главном потоке (сонхронно)
TaskList m_TaskList[2]; //!< В главном потоке (синхронно)
TaskList m_BackgroundTasks; //!< Фоновые задачи
TaskList m_SyncTasks; //!< Синхронные задачи
TaskList m_OnSyncTasks; //!< Задачи синхронизации
......@@ -90,8 +90,8 @@ private:
mutable std::mutex m_mutexIOThread;
Condition m_Condition;
Condition m_ConditionIOThread;
//mutable std::mutex m_mutexWorker[8];
//Condition m_ConditionWorker[8];
mutable std::mutex m_mutexWorker;
Condition m_ConditionWorker;
Condition m_ConditionFor;
int m_iNumTasksToWaitFor;
......
......@@ -38,7 +38,7 @@ SOCKET CommandSocket = INVALID_SOCKET;
bool g_bRunning = false;
bool g_bRunningCmd = false;
typedef CConcurrentQueue<char *> CommandBuffer;
typedef CConcurrentQueue<char*> CommandBuffer;
typedef std::mutex Mutex;
CommandBuffer g_vCommandBuffer;
Stack<CommandBuffer> g_cbufStack;
......
......@@ -32,8 +32,6 @@ See the license in LICENSE
//##########################################################################
char g_szCoreName[CORE_NAME_MAX_LEN];
#if !defined(DEF_STD_REPORT)
#define DEF_STD_REPORT
report_func g_fnReportf = DefReport;
......@@ -62,7 +60,7 @@ if (!(id >= 0 && id < CORE_REGISTRY_SIZE))\
//**************************************************************************
CTimeManager* g_pTimers = 0;
CTimeManager *g_pTimers = NULL;
CCore *g_pCore = NULL;
#define CORE_TIME_PRECOND(retval) if(!g_pTimers){LibReport(REPORT_MSG_LEVEL_ERROR, "%s - sxcore is not init", GEN_MSG_LOCATION); return retval;}
......@@ -156,7 +154,7 @@ bool Core_0IsProcessRun(const char* process)
if(!Process32Next(hSnapshot, &pe)) return false;
}
}
#if 0
void Core_0Create(const char* name, const char *szNameConsole, bool is_unic)
{
if(name && strlen(name) > 1)
......@@ -207,7 +205,9 @@ void Core_AKill()
mem_delete(g_pTimers);
ConsoleDisconnect();
}
#endif
#if 0
void Core_AGetName(char* name)
{
SXCORE_PRECOND(_VOID);
......@@ -217,6 +217,7 @@ void Core_AGetName(char* name)
else
LibReport(REPORT_MSG_LEVEL_ERROR, "%s - invalid argument", GEN_MSG_LOCATION);
}
#endif
SX_LIB_API IXCore *Core_GetIXCore()
{
......
......@@ -23,6 +23,17 @@ See the license in LICENSE
#undef SX_LIB_API
#define SX_LIB_API extern "C" __declspec (dllexport)
#if defined(_WINDOWS)
# if defined(SXCORE_EXPORTS)
# define SXCORE_API __declspec(dllexport)
# else
# define SXCORE_API __declspec(dllimport)
# endif
#else
# define SXCORE_API
#endif
#define C extern "C"
#include <io.h>
#include <fcntl.h>
#include <tlhelp32.h>
......@@ -61,6 +72,13 @@ enum CORE_TASK_FLAG
/*! \name Базовые функции ядра
!@{*/
//! @FIXME: Убрать это!
class ITask;
C SXCORE_API IXCore* XCoreInit(const char *szName);
C SXCORE_API void XCoreStart();
C SXCORE_API void XCoreStop();
C SXCORE_API void XCoreAddTask(ITask *pTask);
//! возвращает версию ядра
SX_LIB_API long Core_0GetVersion();
......@@ -526,23 +544,23 @@ SX_LIB_API void Core_0RegisterCVarPointer(
//! Получает указатель на значение строкового квара. При отсутствии квара запрошенного типа возвращает NULL
SX_LIB_API const char ** Core_0GetPCVarString(const char * name);
#define GET_PCVAR_STRING(k) Core_0GetPCVarString(k);
#define GET_PCVAR_STRING(k) Core_0GetPCVarString(k)
//! Получает указатель на значение целочисленного квара. При отсутствии квара запрошенного типа возвращает NULL
SX_LIB_API const int * Core_0GetPCVarInt(const char * name);
#define GET_PCVAR_INT(k) Core_0GetPCVarInt(k);
#define GET_PCVAR_INT(k) Core_0GetPCVarInt(k)
//! Получает указатель на значение дробного квара. При отсутствии квара запрошенного типа возвращает NULL
SX_LIB_API const float * Core_0GetPCVarFloat(const char * name);
#define GET_PCVAR_FLOAT(k) Core_0GetPCVarFloat(k);
#define GET_PCVAR_FLOAT(k) Core_0GetPCVarFloat(k)
//! Получает указатель на значение логического квара. При отсутствии квара запрошенного типа возвращает NULL
SX_LIB_API const bool * Core_0GetPCVarBool(const char * name);
#define GET_PCVAR_BOOL(k) Core_0GetPCVarBool(k);
#define GET_PCVAR_BOOL(k) Core_0GetPCVarBool(k)
//! Получает указатель по имени. При отсутствии квара запрошенного типа возвращает NULL
SX_LIB_API UINT_PTR * Core_0GetPCVarPointer(const char * name);
#define GET_PCVAR_POINTER(k) Core_0GetPCVarPointer(k);
#define GET_PCVAR_POINTER(k) Core_0GetPCVarPointer(k)
//! Устанавливает новое значение квара. Должен существовать
SX_LIB_API void Core_0SetCVarString(const char * name, const char * value);
......
......@@ -102,13 +102,13 @@ DecalManager::DecalManager():
GXBLEND_DESC blendDesc;
memset(&blendDesc, 0, sizeof(blendDesc));
blendDesc.renderTarget[0].u8RenderTargetWriteMask = GXCOLOR_WRITE_ENABLE_ALL;
blendDesc.renderTarget[0].srcBlend = GXBLEND_DEST_COLOR;
blendDesc.renderTarget[0].destBlend = GXBLEND_SRC_COLOR;
blendDesc.renderTarget[0].srcBlendAlpha = GXBLEND_DEST_ALPHA;
blendDesc.renderTarget[0].destBlendAlpha = GXBLEND_SRC_ALPHA;
blendDesc.renderTarget[0].blendOp = GXBLEND_OP_ADD;
blendDesc.renderTarget[0].blendSrcColor = GXBLEND_DEST_COLOR;
blendDesc.renderTarget[0].blendDestColor = GXBLEND_SRC_COLOR;
blendDesc.renderTarget[0].blendSrcAlpha = GXBLEND_DEST_ALPHA;
blendDesc.renderTarget[0].blendDestAlpha = GXBLEND_SRC_ALPHA;
blendDesc.renderTarget[0].blendOpColor = GXBLEND_OP_ADD;
blendDesc.renderTarget[0].blendOpAlpha = GXBLEND_OP_ADD;
blendDesc.renderTarget[0].bBlendEnable = TRUE;
blendDesc.renderTarget[0].useBlend = TRUE;
m_pBlendState = dev->createBlendState(&blendDesc);
......
......@@ -17,9 +17,9 @@ void CEditable::startup(IGXContext *pDevice)
m_pDevice = pDevice;
GXBLEND_DESC blendDesc;
blendDesc.renderTarget[0].bBlendEnable = true;
blendDesc.renderTarget[0].srcBlend = blendDesc.renderTarget[0].srcBlendAlpha = GXBLEND_BLEND_FACTOR;
blendDesc.renderTarget[0].destBlend = blendDesc.renderTarget[0].destBlendAlpha = GXBLEND_INV_BLEND_FACTOR;
blendDesc.renderTarget[0].useBlend = true;
blendDesc.renderTarget[0].blendSrcColor = blendDesc.renderTarget[0].blendSrcAlpha = GXBLEND_BLEND_FACTOR;
blendDesc.renderTarget[0].blendDestColor = blendDesc.renderTarget[0].blendDestAlpha = GXBLEND_INV_BLEND_FACTOR;
m_pBlendColorFactor = m_pDevice->createBlendState(&blendDesc);
GXRASTERIZER_DESC rsDesc;
......
......@@ -320,9 +320,11 @@ GameData::GameData(HWND hWnd, bool isGame):
LibReport(REPORT_MSG_LEVEL_ERROR, "The procedure entry point InitInstance could not be located in the dynamic link library sxgui.dll");
}
m_pGUI = pfnGUIInit(SGCore_GetDXDevice(), "./gui/", hWnd);
m_pHUDcontroller = new CHUDcontroller();
if(hWnd)
{
m_pGUI = pfnGUIInit(SGCore_GetDXDevice(), "./gui/", hWnd);
m_pHUDcontroller = new CHUDcontroller();
}
m_pMgr = new CEntityManager();
......@@ -525,8 +527,9 @@ GameData::GameData(HWND hWnd, bool isGame):
//Core_0RegisterCVarFloat("r_default_fov", 45.0f, "Default FOV value");
Core_0RegisterCVarBool("cl_mode_editor", false, "Editor control mode");
Core_0RegisterCVarBool("cl_grab_cursor", true, "Grab cursor on move");
Core_0RegisterCVarBool("cl_grab_cursor", false, "Grab cursor on move");
Core_0RegisterCVarFloat("cl_mousesense", 0.001f, "Mouse sense value");
Core_0RegisterCVarBool("cl_bob", true, "View bobbing");
Core_0RegisterCVarFloat("cl_bob_walk_y", 0.1f, "View bobbing walk y amplitude");
......@@ -1007,9 +1010,9 @@ GameData::GameData(HWND hWnd, bool isGame):
g_idTextKit = SGCore_ShaderCreateKit(g_idTextVS, g_idTextPS);
GXBLEND_DESC bsDesc;
bsDesc.renderTarget[0].bBlendEnable = true;
bsDesc.renderTarget[0].srcBlend = bsDesc.renderTarget[0].srcBlendAlpha = GXBLEND_SRC_ALPHA;
bsDesc.renderTarget[0].destBlend = bsDesc.renderTarget[0].destBlendAlpha = GXBLEND_INV_SRC_ALPHA;
bsDesc.renderTarget[0].useBlend = true;
bsDesc.renderTarget[0].blendSrcColor = bsDesc.renderTarget[0].blendSrcAlpha = GXBLEND_SRC_ALPHA;
bsDesc.renderTarget[0].blendDestColor = bsDesc.renderTarget[0].blendDestAlpha = GXBLEND_INV_SRC_ALPHA;
g_pTextBlendState = SGCore_GetDXDevice()->createBlendState(&bsDesc);
GXSAMPLER_DESC sampDesc;
......@@ -1020,7 +1023,7 @@ GameData::GameData(HWND hWnd, bool isGame):
g_pTextPSConstantBuffer = SGCore_GetDXDevice()->createConstantBuffer(sizeof(float4));
GXDEPTH_STENCIL_DESC dsDesc;
dsDesc.bDepthEnable = dsDesc.bEnableDepthWrite = false;
dsDesc.useDepthTest = dsDesc.useDepthWrite = false;
g_pTextDepthState = SGCore_GetDXDevice()->createDepthStencilState(&dsDesc);
//m_pStatsUI = m_pGUI->createDesktopA("stats", "sys/stats.html");
......@@ -1153,14 +1156,14 @@ void GameData::render()
, g_uFPS,
pAdapterDesc->szDescription,
pAdapterDesc->uTotalGPUMemory / 1024 / 1024,
(float)(pMemoryStats->uIndexBufferBytes + pMemoryStats->uRenderTargetBytes + pMemoryStats->uShaderConstBytes + pMemoryStats->uTextureBytes + pMemoryStats->uVertexBufferBytes) / 1024.0f / 1024.0f,
(float)pMemoryStats->uTextureBytes / 1024.0f / 1024.0f,
(float)pMemoryStats->uRenderTargetBytes / 1024.0f / 1024.0f,
(float)pMemoryStats->uVertexBufferBytes / 1024.0f / 1024.0f,
(float)pMemoryStats->uIndexBufferBytes / 1024.0f / 1024.0f,
(float)pMemoryStats->uShaderConstBytes / 1024.0f,
pAdapterDesc->sizeTotalGPUmemory / 1024 / 1024,
(float)(pMemoryStats->sizeIndexBufferBytes + pMemoryStats->sizeRenderTargetBytes + pMemoryStats->sizeShaderConstBytes + pMemoryStats->sizeTextureBytes + pMemoryStats->sizeVertexBufferBytes) / 1024.0f / 1024.0f,
(float)pMemoryStats->sizeTextureBytes / 1024.0f / 1024.0f,
(float)pMemoryStats->sizeRenderTargetBytes / 1024.0f / 1024.0f,
(float)pMemoryStats->sizeVertexBufferBytes / 1024.0f / 1024.0f,
(float)pMemoryStats->sizeIndexBufferBytes / 1024.0f / 1024.0f,
(float)pMemoryStats->sizeShaderConstBytes / 1024.0f,
pFrameStats->uUploadedBuffersIndices + pFrameStats->uUploadedBuffersTextures + pFrameStats->uUploadedBuffersVertexes + pFrameStats->uUploadedBuffersShaderConst,
pFrameStats->uUploadedBuffersTextures,
......
......@@ -54,14 +54,14 @@ CCrosshair::CCrosshair():
m_idShaderKit = SGCore_ShaderCreateKit(m_idVS, m_idPS);
GXBLEND_DESC blendDesc;
blendDesc.renderTarget[0].srcBlend = blendDesc.renderTarget[0].srcBlendAlpha = GXBLEND_SRC_ALPHA;
blendDesc.renderTarget[0].destBlend = blendDesc.renderTarget[0].destBlendAlpha = GXBLEND_INV_SRC_ALPHA;
blendDesc.renderTarget[0].bBlendEnable = TRUE;
blendDesc.renderTarget[0].blendSrcColor = blendDesc.renderTarget[0].blendSrcAlpha = GXBLEND_SRC_ALPHA;
blendDesc.renderTarget[0].blendDestColor = blendDesc.renderTarget[0].blendDestAlpha = GXBLEND_INV_SRC_ALPHA;
blendDesc.renderTarget[0].useBlend = TRUE;
m_pBlendState = m_pDev->createBlendState(&blendDesc);
GXDEPTH_STENCIL_DESC dsDesc;
dsDesc.bDepthEnable = FALSE;
dsDesc.bEnableDepthWrite = FALSE;
dsDesc.useDepthTest = FALSE;
dsDesc.useDepthWrite = FALSE;
m_pDepthState = m_pDev->createDepthStencilState(&dsDesc);
}
......
......@@ -49,8 +49,6 @@ void QuadGetSphere(const float2 &vMin, const float2 &vMax, float &fRadius, float
COcclusionCulling::COcclusionCulling()
{
m_isEnable = true;
m_pFrustum = 0;
m_iCountFC = 0;
m_iCountFCfail = 0;
......
/***********************************************************
Copyright Vitaliy Buturlin, Evgeny Danilovich, 2017, 2018
Copyright © Vitaliy Buturlin, Evgeny Danilovich, 2017, 2018
See the license in LICENSE
***********************************************************/
......@@ -16,19 +16,19 @@ See the license in LICENSE
extern IGXContext *g_pDevice;
//! occlusion culling
//! коэффициент размера буфера глубины occlusion culling
#define OC_SIZE_COEF 0.25f
//! ( ) occlusion culling true
//! дистанция (в метрах) при которой тест occlusion culling всегда будет давать true
#define OC_DIST_NEAR_NOT_CULL 4.f
//! occlusion culling
//! погрешность разниц глубин для теста occlusion culling
//static float g_fOCbiasDepth = 0.0001f;
//!
//! количество пикселей расширения треугольников для
const float g_fOCextTriangle = 2.f;
//! occlusion culling
//! небольшео расширение бокса для теста occlusion culling
const float3 g_cvOCext(0.05f, 0.05f, 0.05f);
#define OC_MAX_MUTEX_COUNT 512
......@@ -56,31 +56,31 @@ public:
COcclusionCulling();
~COcclusionCulling();
//!
//! инициализация на основании размеров рендера
void init(int iWidth, int iHeight);
//!