Пример #1
0
bool BaseDemo::Init()
{
	if (!D3D11App::Init())
		return false;
	InitResource();
	return true;
}
Пример #2
0
HRESULT CD3D9ExUtils::Render (void* pDst[3], SBufferInfo* pInfo) {
  HRESULT hResult = E_FAIL;

  if (!pInfo)
    return E_FAIL;

  if (m_nWidth != pInfo->UsrData.sSystemBuffer.iWidth
      || m_nHeight != pInfo->UsrData.sSystemBuffer.iHeight) {
    m_nWidth = pInfo->UsrData.sSystemBuffer.iWidth;
    m_nHeight = pInfo->UsrData.sSystemBuffer.iHeight;
    MoveWindow(m_hWnd,0,0,pInfo->UsrData.sSystemBuffer.iWidth,pInfo->UsrData.sSystemBuffer.iHeight,true);
    SAFE_RELEASE (m_lpD3D9RawSurfaceShare);
    SAFE_RELEASE (m_lpD3D9Device);
  }
  hResult = InitResource (NULL, pInfo);
  if (SUCCEEDED (hResult))
    hResult = Dump2Surface (pDst, m_lpD3D9RawSurfaceShare, pInfo->UsrData.sSystemBuffer.iWidth,
                            pInfo->UsrData.sSystemBuffer.iHeight, pInfo->UsrData.sSystemBuffer.iStride);

  if (SUCCEEDED (hResult)) {
    IDirect3DSurface9* pBackBuffer = NULL;
    hResult = m_lpD3D9Device->GetBackBuffer (0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer);
    hResult = m_lpD3D9Device->StretchRect (m_lpD3D9RawSurfaceShare, NULL, pBackBuffer, NULL, D3DTEXF_NONE);
    hResult = m_lpD3D9Device->PresentEx (0, 0, NULL, NULL, 0);
  }

  return hResult;
}
Пример #3
0
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int nCmdShow)
{
	HRESULT Hr = ::CoInitialize(NULL);
	if( FAILED(Hr) ) return 0;
	HRESULT hRes = ::OleInitialize(NULL);
	// 初始化UI管理器
	CPaintManagerUI::SetInstance(hInstance);
	// 初始化资源
	InitResource();

	::SetCurrentDirectory(CPaintManagerUI::GetInstancePath());
#ifndef _DEBUG
	CPaintManagerUI::LoadPlugin(_T("TroyControls.dll"));
#else
	CPaintManagerUI::LoadPlugin(_T("TroyControls_d.dll"));
#endif
	CMainWnd* pFrame = new CMainWnd();
	if( pFrame == NULL ) return 0;
	pFrame->Create(NULL, _T("TroyBrowser"), UI_WNDSTYLE_FRAME, 0L, 0, 0, 990,690);
	pFrame->CenterWindow();
	pFrame->ShowModal();

	CPaintManagerUI::MessageLoop();
	OleUninitialize();
	::CoUninitialize();
	return 0;
}
Пример #4
0
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int nCmdShow)
{
	_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);

	HRESULT Hr = ::CoInitialize(NULL);
	if( FAILED(Hr) ) return 0;
	HRESULT hRes = ::OleInitialize(NULL);
	// 初始化UI管理器
	CPaintManagerUI::SetInstance(hInstance);
	// 初始化资源
	InitResource();

	CDemoFrame* pFrame = new CDemoFrame();
	if( pFrame == NULL ) return 0;
	pFrame->Create(NULL, _T("duilib使用例子集锦(By Troy)"), UI_WNDSTYLE_FRAME, 0L, 0, 0, 800, 572);
	pFrame->CenterWindow();
	ShowWindow(*pFrame, SW_SHOW);
	CPaintManagerUI::MessageLoop();
	delete pFrame;
	pFrame = NULL;
	CResourceManager::GetInstance()->Release();

	OleUninitialize();
	::CoUninitialize();
	return 0;
}
// New circular buffer system for faster constant uploads.  Avoids CopyResource and speeds things up considerably
FD3D12ConstantBuffer::FD3D12ConstantBuffer(FD3D12Device* InParent, uint32 InSize, uint32 SubBuffers) :
	MaxSize(InSize),
	ShadowData(NULL),
	CurrentUpdateSize(0),
	TotalUpdateSize(0),
	FD3D12DeviceChild(InParent)
{
	InitResource();
}
// New circular buffer system for faster constant uploads.  Avoids CopyResource and speeds things up considerably
FD3D11ConstantBuffer::FD3D11ConstantBuffer(FD3D11DynamicRHI* InD3DRHI, uint32 InSize, uint32 SubBuffers) :
    D3DRHI(InD3DRHI),
    MaxSize(InSize),
    ShadowData(NULL),
    CurrentUpdateSize(0),
    TotalUpdateSize(0)
{
    InitResource();
}
Пример #7
0
//主进程
void main(void)
{
	//创建Opengl渲染环境及窗口
	char *device = "opengl";
	HCoreResizeFunc( ResizeWindow );
	HCoreCreateWindow(100, 100, 800, 600, device);

	if ( !HCoreInitGraphicsDevice(device) )
	{
		printf("初始化失败 \n", device);
		exit(0);
	}
	
	//注册输入函数
	HCoreInputInit();

	HCoreRegisterKeyDown(HCoreKEY_0, KeyDown_0);
	HCoreRegisterKeyDown(HCoreKEY_1, KeyDown_1);
	HCoreRegisterKeyDown(HCoreKEY_2, KeyDown_2);
	HCoreRegisterKeyDown(HCoreKEY_3, KeyDown_3);
	HCoreRegisterKeyDown(HCoreKEY_4, KeyDown_4);
	HCoreRegisterKeyDown(HCoreKEY_5, KeyDown_5);
	HCoreRegisterKeyDown(HCoreKEY_6, KeyDown_6);
	HCoreRegisterKeyDown(HCoreKEY_7, KeyDown_7);
	HCoreRegisterKeyDown(HCoreKEY_8, KeyDown_8);
	HCoreRegisterKeyDown(HCoreKEY_9, KeyDown_9);
	
	//设置相机
	g_Control.SetCamera(Vector4(0.0f, 0.0f, 1.0f), Vector4(0.0f, 1.0f, 1.0f), Vector4(0.0f, 0.0f, 1.0f) );

	//读取模型
	//地形
	g_Model.Load_ASCII("..\\models\\terrain.gma");
	//棋盘
	g_SSAOModel.Load_ASCII("..\\models\\chess.gma");

	// 载入shader
	if ( !InitResource() )
	{
		ReleaseResource();
		exit(0);
	}

	// 主循环
	while( HCoreProcessMessage() )
	{
		GetUserInput();
		RenderFrame();
	}

	// 释放shader
	ReleaseResource();

	// 关闭OpenGL绘图设备
	HCoreReleaseGraphicsDevice();
}
Пример #8
0
bool CSnowboard::InitModule( HWND hWnd )
{
	LOGGER.Init(NULL , NULL , NULL , NULL );
	FRAMEMEMORY.Init( 1024 * 1024 );
	LOG_WARNING( "Init FrameMemory = %d Byte" , FRAMEMEMORY.GetSize() );

	InitRenderer( hWnd );
	InitResource( m_pRenderer->GetDevice() );

	TestFunc();

	return true;
}
Пример #9
0
bool D3D11App::Init()
{
	if (!InitMainWindow())
		return false;

	if (!InitDirect3D())
		return false;
	InitResource();
	float AspectHByW = (float)mClientWidth / (float)mClientHeight;
	g_objTrackballCameraController.ProjParams(DirectX::XM_PI*0.25f, AspectHByW, 1.0f, 1000.0f);
	mTimer.Start();
	return true;
}
Пример #10
0
FD3D11DynamicBuffer::FD3D11DynamicBuffer(FD3D11DynamicRHI* InD3DRHI, D3D11_BIND_FLAG InBindFlag, uint32* InBufferSizes)
	:D3DRHI(InD3DRHI),
	BindFlag(InBindFlag)
{
	//InitBufferSize
	while (BufferSize.size() < MAX_BUFFER_SIZES && *InBufferSizes > 0)
	{
		BufferSize.push_back(*InBufferSizes);
		InBufferSizes++;
	}

	InitResource();
}
Пример #11
0
void FReflectionEnvironmentCubemapArray::UpdateMaxCubemaps(uint32 InMaxCubemaps)
{
	MaxCubemaps = InMaxCubemaps;

	// Reallocate the cubemap array
	if (IsInitialized())
	{
		UpdateRHI();
	}
	else
	{
		InitResource();
	}
}
Пример #12
0
HRESULT CD3D9ExUtils::Render (void* pDst[3], SBufferInfo* pInfo) {
  HRESULT hResult = E_FAIL;
  EBufferProperty eBufferProperty = pInfo->eBufferProperty;

  if (eBufferProperty == BUFFER_HOST) {
    hResult = InitResource (NULL, pInfo);
    if (SUCCEEDED (hResult))
      hResult = Dump2Surface (pDst, m_lpD3D9RawSurfaceShare, pInfo->UsrData.sSystemBuffer.iWidth,
                              pInfo->UsrData.sSystemBuffer.iHeight, pInfo->UsrData.sSystemBuffer.iStride);
  } else if (eBufferProperty == BUFFER_DEVICE) {
    VOID* pSharedHandle = pDst[0];
    hResult = InitResource (pSharedHandle, pInfo);
  }

  if (SUCCEEDED (hResult)) {
    IDirect3DSurface9* pBackBuffer = NULL;
    hResult = m_lpD3D9Device->GetBackBuffer (0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer);
    hResult = m_lpD3D9Device->StretchRect (m_lpD3D9RawSurfaceShare, NULL, pBackBuffer, NULL, D3DTEXF_NONE);
    hResult = m_lpD3D9Device->PresentEx (0, 0, NULL, NULL, 0);
  }

  return hResult;
}
void FIndirectLightingCache::UpdateBlocks(FScene* Scene, FViewInfo* DebugDrawingView, TMap<FIntVector, FBlockUpdateInfo>& BlocksToUpdate)
{
	if (BlocksToUpdate.Num() > 0 && !IsInitialized())
	{
		InitResource();
	}

	INC_DWORD_STAT_BY(STAT_IndirectLightingCacheUpdates, BlocksToUpdate.Num());

	for (TMap<FIntVector, FBlockUpdateInfo>::TIterator It(BlocksToUpdate); It; ++It)
	{
		UpdateBlock(Scene, DebugDrawingView, It.Value());
	}
}
int Init ( ESContext *esContext )
{
	glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f );

	//Init matrix tranform coordinate from clip space to texture space (texture transform matrix)
	//...

	InitResource();
	InitObjects();
	InitFBO();
	InitFBO_();
	
	return 0;
}
Пример #15
0
HRESULT CD3D9Utils::Render (void* pDst[3], SBufferInfo* pInfo) {
  HRESULT hResult = E_FAIL;

  hResult = InitResource (NULL, pInfo);
  if (SUCCEEDED (hResult))
    hResult = Dump2Surface (pDst, m_lpD3D9RawSurfaceShare, pInfo->UsrData.sSystemBuffer.iWidth,
                            pInfo->UsrData.sSystemBuffer.iHeight, pInfo->UsrData.sSystemBuffer.iStride);

  if (SUCCEEDED (hResult)) {
    IDirect3DSurface9* pBackBuffer = NULL;
    hResult = m_lpD3D9Device->GetBackBuffer (0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer);
    hResult = m_lpD3D9Device->StretchRect (m_lpD3D9RawSurfaceShare, NULL, pBackBuffer, NULL, D3DTEXF_NONE);
    hResult = m_lpD3D9Device->Present (0, 0, NULL, NULL);
  }

  return hResult;
}
Пример #16
0
void FRenderResource::InitResourceFromPossiblyParallelRendering()
{
	if (IsInRenderingThread())
	{
		InitResource();
	}
	else
	{
		check(IsInParallelRenderingThread());
		class FInitResourceRenderThreadTask
		{
			FRenderResource& Resource;
			FScopedEvent& Event;
		public:

			FInitResourceRenderThreadTask(FRenderResource& InResource, FScopedEvent& InEvent)
				: Resource(InResource)
				, Event(InEvent)
			{
			}

			FORCEINLINE TStatId GetStatId() const
			{
				RETURN_QUICK_DECLARE_CYCLE_STAT(FInitResourceRenderThreadTask, STATGROUP_TaskGraphTasks);
			}

			ENamedThreads::Type GetDesiredThread()
			{
				return ENamedThreads::RenderThread_Local;
			}

			static ESubsequentsMode::Type GetSubsequentsMode() { return ESubsequentsMode::FireAndForget; }

			void DoTask(ENamedThreads::Type CurrentThread, const FGraphEventRef& MyCompletionGraphEvent)
			{
				Resource.InitResource();
				Event.Trigger();
			}
		};
		{
			FScopedEvent Event;
			TGraphTask<FInitResourceRenderThreadTask>::CreateTask().ConstructAndDispatchWhenReady(*this, Event);
		}
	}
}
Пример #17
0
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int nCmdShow)
{
    HRESULT Hr = ::CoInitialize(NULL);
    if( FAILED(Hr) ) return 0;
    HRESULT hRes = ::OleInitialize(NULL);
    // 初始化UI管理器
    CPaintManagerUI::SetInstance(hInstance);
    // 初始化资源
    InitResource();

    CFrameWnd *pFrame = new CFrameWnd(_T("MainWnd.xml"));
    pFrame->Create(NULL, _T("Redrain窗体动画demo"), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE);
    pFrame->ShowModal();

    delete pFrame;
    ::CoUninitialize();
    return 0;
}
Пример #18
0
LRESULT WindowImplBase::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	LONG styleValue = ::GetWindowLong(*this, GWL_STYLE);
	styleValue &= ~WS_CAPTION;
	::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);

	RECT rcClient;
	::GetClientRect(*this, &rcClient);
	::SetWindowPos(*this, NULL, rcClient.left, rcClient.top, rcClient.right - rcClient.left, \
		rcClient.bottom - rcClient.top, SWP_FRAMECHANGED);

	// 关联UI管理器
	m_PaintManager.Init(m_hWnd, GetManagerName());
	m_PaintManager.AddPreMessageFilter(this);

	// 多语言接口
	CResourceManager::GetInstance()->SetTextQueryInterface(this);

	CDialogBuilder builder;
	if (m_PaintManager.GetResourcePath().IsEmpty())
	{	// 允许更灵活的资源路径定义
		CDuiString strResourcePath=m_PaintManager.GetInstancePath();
		strResourcePath += GetSkinFolder().GetData();
		m_PaintManager.SetResourcePath(strResourcePath.GetData());
	}

	switch(GetResourceType())
	{
	case UILIB_ZIP:
		m_PaintManager.SetResourceZip(GetZIPFileName().GetData(), true);
		break;
	case UILIB_ZIPRESOURCE:
		{
			HRSRC hResource = ::FindResource(m_PaintManager.GetResourceDll(), GetResourceID(), _T("ZIPRES"));
			if( hResource == NULL )
				return 0L;
			DWORD dwSize = 0;
			HGLOBAL hGlobal = ::LoadResource(m_PaintManager.GetResourceDll(), hResource);
			if( hGlobal == NULL ) 
			{
#if defined(WIN32) && !defined(UNDER_CE)
				::FreeResource(hResource);
#endif
				return 0L;
			}
			dwSize = ::SizeofResource(m_PaintManager.GetResourceDll(), hResource);
			if( dwSize == 0 )
				return 0L;

			m_PaintManager.SetResourceZip((LPBYTE)::LockResource(hGlobal), dwSize);

#if defined(WIN32) && !defined(UNDER_CE)
			::FreeResource(hResource);
#endif
		}
		break;
	}
	// 资源管理器接口
	InitResource();

	// 创建主窗口
	CControlUI* pRoot=NULL;
	if (GetResourceType() == UILIB_RESOURCE)
	{
		STRINGorID xml(_ttoi(GetSkinFile().GetData()));
		pRoot = builder.Create(xml, _T("xml"), this, &m_PaintManager);
	}
	else {
		pRoot = builder.Create(GetSkinFile().GetData(), (UINT)0, this, &m_PaintManager);
	}
 	ASSERT(pRoot);
	if (pRoot==NULL)
	{
		MessageBox(NULL,_T("加载资源文件失败"),_T("Duilib"),MB_OK|MB_ICONERROR);
		ExitProcess(1);
		return 0;
	}
	m_PaintManager.AttachDialog(pRoot);
	m_PaintManager.AddNotifier(this);

	InitWindow();
	return 0;
}
int InitGUI (int argc, const char* agr[])
{
    int step = 1;

    __mg_quiting_stage = _MG_QUITING_STAGE_RUNNING;

#ifdef _MGRM_PROCESSES
    const char* name;

    if ((name = strrchr (agr [0], '/')) == NULL)
        name = agr [0];
    else
        name ++;

    if (!strcmp (name, "mginit"))
        mgIsServer = TRUE;
#endif

#ifdef HAVE_SETLOCALE
    setlocale (LC_ALL, "C");
#endif

    /* Save original termio */
#ifdef _MGRM_PROCESSES
    if (mgIsServer)
#endif
//#ifndef WIN32
#ifndef __NOUNIX__
        tcgetattr (0, &savedtermio);
#endif

    /*Initialize default window process*/
    __mg_def_proc[0] = PreDefMainWinProc;
    __mg_def_proc[1] = PreDefDialogProc;
    __mg_def_proc[2] = PreDefControlProc;

    if (!mg_InitFixStr ()) {
        err_message (step, "Can not initialize Fixed String heap!\n");
        return step;
    }
    step++;

    if (!mg_InitMisc ()) {
        err_message (step, "Can not initialize miscellous things!");
        return step;
    }
    step++;

#ifdef _MGRM_PROCESSES
    if (mgIsServer && !kernel_IsOnlyMe ()) {
        err_message (step, "There is already an instance of 'mginit'!");
        return step;
    }
    step++;
#endif

#ifdef _MGRM_PROCESSES
    if (!mgIsServer) {
        if (!client_ClientStartup ()) {
            err_message (step, "Can not start client (Please run mginit first)!");
            return step;
        }
        step++;

        if ((mgSharedRes = kernel_AttachSharedResource ()) == NULL) {
            err_message (step, "Can not attach shared resource (Please run mginit first)!");
            return step;
        }
        atexit (kernel_UnattachSharedResource);
    }
#endif

    /* Init GAL engine. */
    switch (mg_InitGAL ()) {
    case ERR_CONFIG_FILE:
        err_message (step, "Reading configuration failure!");
        return step;

    case ERR_NO_ENGINE:
        err_message (step, "No graphics engine defined!");
        return step;

    case ERR_NO_MATCH:
        err_message (step, "Can not get graphics engine information!");
        return step;

    case ERR_GFX_ENGINE:
        err_message (step, "Can not initialize graphics engine!");
        return step;
    }
    step++;
    atexit (mg_TerminateGAL);

    /* install signal handlers */
#ifdef _MGRM_PROCESSES
    if (mgIsServer)
#endif
        InstallSEGVHandler ();

    /** initialize icon bitmap resource.*/
    if (mg_InitSystemRes () == FALSE) {
        fprintf (stderr, "KERNEL>IniGUI: init system res error!\n");
        return step;
    }
    step++;
    /* DK[11/29/10]: For fix bug 4440, avoid double free. */
/*     atexit (mg_TerminateSystemRes);
 */

    if (!mg_InitGDI ()) {
        err_message (step, "Initialization of GDI resource failure!\n");
        return step;
    }
    step++;
    atexit (mg_TerminateGDI);

    /* Init Master Screen DC here */
    if (!mg_InitScreenDC (__gal_screen)) {
        err_message (step, "Can not initialize screen DC!");
        return step;
    }
    step++;
    atexit (mg_TerminateScreenDC);

    g_rcScr.left = 0;
    g_rcScr.top = 0;
    g_rcScr.right = GetGDCapability (HDC_SCREEN_SYS, GDCAP_MAXX) + 1;
    g_rcScr.bottom = GetGDCapability (HDC_SCREEN_SYS, GDCAP_MAXY) + 1;

#ifdef _MGRM_PROCESSES
    if (mgIsServer) {
        /* Load shared resource and create shared memory. */
        if ((mgSharedRes = kernel_LoadSharedResource ()) == NULL) {
            err_message (step, "Can not load shared resource!");
            return step;
        }
        atexit (kernel_UnloadSharedResource);
        SHAREDRES_TERMIOS = savedtermio;
    }

    step++;
#endif

    if (!mg_InitLFManager ()) {
        err_message (step, "Can not initialize LFManager!\n");
        return step;
    }
    step++;
    atexit (mg_TerminateLFManager);


#ifdef _MGRM_PROCESSES
    if (mgIsServer) 
#endif
    {
        license_create();
        splash_draw_framework(); 
        splash_delay();
    }

    /* Initialize resource */
    if (!InitResource ()) {
        err_message (step, "Can not initialize resource!");
        return step;
    }
    step++;

#ifdef _MGRM_STANDALONE

    /* Init IAL engine.. */
    if (!mg_InitLWEvent ()) {
        err_message (step, "Can not initialize low level event!");
        return step;
    }
    step++;

    atexit (mg_TerminateLWEvent);

    SetDskIdleHandler (salone_IdleHandler4StandAlone);

    if (!salone_StandAloneStartup ()) {
        fprintf (stderr, "KERNEL>InitGUI: Can not start MiniGUI-StandAlone version.\n");
        return step;
    }

#else

    if (mgIsServer) {
        /* Init IAL engine.. */
        if (!mg_InitLWEvent ()) {
            err_message (step, "Can not initialize low level event!");
            return step;
        }
        step++;

        atexit (mg_TerminateLWEvent);

        SetDskIdleHandler (server_IdleHandler4Server);
    }
    else {
        SetDskIdleHandler (client_IdleHandler4Client);
    }
#endif

    SetKeyboardLayout ("default");

    mg_TerminateMgEtc ();
    return 0;
}
Пример #20
0
int InitGUI (void)
{
    int step = 1;

    // Save original termio
#ifndef _STAND_ALONE
    if (mgIsServer)
#endif
        tcgetattr (0, &savedtermio);

    if (!InitMisc ()) {
        err_message (step, "Can not initialize miscellous things!");
        return step;
    }
    step++;

#ifndef _STAND_ALONE
    if (mgIsServer && !IsOnlyMe ()) {
        err_message (step, "There is already an instance of 'mginit'!");
        return step;
    }
    step++;
#endif

    // Init GAL engine.
    switch (InitGAL ()) {
    case ERR_CONFIG_FILE:
        err_message (step, "Reading configuration failure!");
        return step;

    case ERR_NO_ENGINE:
        err_message (step, "No graphics engine defined!");
        return step;

    case ERR_NO_MATCH:
        err_message (step, "Can not get graphics engine information!");
        return step;

    case ERR_GFX_ENGINE:
        err_message (step, "Can not initialize graphics engine!");
        return step;
    }
    step++;
    atexit (TerminateGAL);

    /* install signal handlers */
#ifndef _STAND_ALONE
    if (mgIsServer)
#endif
        InstallSEGVHandler ();

    if (!InitGDI ()) {
        err_message (step, "MiniGUI: Initialization of GDI resource failure!\n");
        return step;
    }
    step++;
    atexit (TerminateGDI);

    /* Init Screen DC here */
    if (!InitScreenDC ()) {
        err_message (step, "Can not initialize screen DC!");
        return step;
    }
    step++;
    atexit (TerminateScreenDC);

    g_rcScr.left = 0;
    g_rcScr.top = 0;
    g_rcScr.right = GetGDCapability (HDC_SCREEN, GDCAP_MAXX) + 1;
    g_rcScr.bottom = GetGDCapability (HDC_SCREEN, GDCAP_MAXY) + 1;

    if (!InitWindowElementColors ()) {
        err_message (step, "Can not initialize colors of window element!");
        return step;
    }
    step++;

#ifndef _STAND_ALONE
    if (mgIsServer) {
        // Load shared resource and create shared memory.
        if ((mgSharedRes = LoadSharedResource ()) == NULL) {
            err_message (step, "Can not load shared resource!");
            return step;
        }
        atexit (UnloadSharedResource);
        SHAREDRES_TERMIOS = savedtermio;
    }
    else {
        if ((mgSharedRes = AttachSharedResource ()) == NULL) {
            err_message (step, "Can not attach shared resource!");
            return step;
        }
        atexit (UnattachSharedResource);
    }
    step++;

#endif

    // Initialize resource
    if (!InitResource ()) {
        err_message (step, "Can not initialize resource!");
        return step;
    }
    step++;

#ifdef _STAND_ALONE

    // Init IAL engine..
    if (!InitLWEvent ()) {
        err_message (step, "Can not initialize low level event!");
        return step;
    }
    step++;

    atexit (TerminateLWEvent);

    __mg_dsk_msgs.OnIdle = IdleHandler4StandAlone;

    if (!StandAloneStartup ()) {
        fprintf (stderr, "Can not start MiniGUI-Lite StandAlone version.\n");
        return step;
    }

#else

    if (mgIsServer) {
        // Init IAL engine..
        if (!InitLWEvent ()) {
            err_message (step, "Can not initialize low level event!");
            return step;
        }
        step++;

        atexit (TerminateLWEvent);

        __mg_dsk_msgs.OnIdle = IdleHandler4Server;

        if (!ServerStartup ()) {
            fprintf (stderr, "Can not start the server of MiniGUI-Lite: mginit.\n");
            return step;
        }
    }
    else {
        if (!ClientStartup ()) {
            err_message (step, "Can not start client!");
            return step;
        }
        step++;

        __mg_dsk_msgs.OnIdle = IdleHandler4Client;
    }
#endif

    SetKeyboardLayout ("default");

    TerminateMgEtc ();
    return 0;
}
Пример #21
0
void DCRenderer::OnResetDevice(IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc)
{
    InitResource(pd3dDevice);    
}
Пример #22
0
void MainServer()
{
	InitInterfaceLocks(); 
	
	InitInterface(); /* starts a thread with the window */

   WrapInit();
	
	InitMemory(); /* memory needs channels in general, but need to start before config,
	so just be careful. */
	
	InitConfig();
	LoadConfig();		/* must be nearly first since channels use it */
	
	InitDebug();
	
	InitChannelBuffer();
	
	OpenDefaultChannels();
	
	lprintf("Starting %s\n",BlakServLongVersionString());
	
	InitClass();
	InitMessage();
	InitObject();
	InitList();
	InitTimer();
	InitSession();
	InitResource();
	InitRoomData();
	InitString();
	InitUser();
	InitAccount();
	InitNameID();
	InitDLlist();   
	InitSysTimer();
	InitMotd();
	InitLoadBof();
	InitTime();
	InitGameLock();
	InitBkodInterpret();
	InitBufferPool();
	InitTable();
	AddBuiltInDLlist();
	
	LoadMotd();
	LoadBof();
	LoadRsc();
	LoadKodbase();
	
	LoadAdminConstants();
	
	PauseTimers();
	
	if (LoadAll() == True)
	{
	/* this loaded_game_msg tells it to disconnect all blakod info about sessions,
		* that were logged on when we saved */
		
		SendTopLevelBlakodMessage(GetSystemObjectID(),LOADED_GAME_MSG,0,NULL);
		DoneLoadAccounts();
	}
	
	/* these must be after LoadAll and ClearList */
	InitCommCli(); 
	InitParseClient(); 
	InitProfiling();
	InitAsyncConnections();
	
	UpdateSecurityRedbook();
	
	UnpauseTimers();

	

	ServiceTimers();
	/* returns if server termiated */
	
	MainExitServer();
   WrapShutdown();
}
Пример #23
0
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
{
  int               i;
  int               iArgC;
  char              szBuf[MAX_BUF];
  char              szArgVBuf[MAX_BUF];
  char              szFileFullPath[MAX_BUF];
  char              szSeaExe[MAX_BUF];
  char              szNsZipName[MAX_BUF];
  char              szAppName[MAX_BUF];
  char              szAppPath[MAX_BUF];

#ifdef SSU_DEBUG
  char              szOutputStr[MAX_BUF];
#endif

  WIN32_FIND_DATA   findFileData;
  HANDLE            hExe;
  HANDLE            hFindFile;
  BOOL              bSelfUpdate;

  if(GetModuleFileName(NULL, szAppName, sizeof(szAppName)) == 0L)
  {
    PrintError("GetModuleFileName() failed", ERROR_CODE_SHOW);
    exit(1);
  }
  ParsePath(szAppName, szBuf, sizeof(szBuf), PP_FILENAME_ONLY);
  ParsePath(szAppPath, szBuf, sizeof(szBuf), PP_PATH_ONLY);

  if(*lpszCmdLine == '\0')
  {
    ShowUsage(szBuf);
    exit(1);
  }

  iArgC = GetArgC(lpszCmdLine);
  bSelfUpdate = FALSE;

#ifdef SSU_DEBUG
  wsprintf(szOutputStr, "ArgC: %d\n", iArgC);
  for(i = 0; i < iArgC; i++)
  {
    GetArgV(lpszCmdLine, i, szArgVBuf, sizeof(szArgVBuf));
    itoa(i, szBuf, 10);
    lstrcat(szOutputStr, "    ");
    lstrcat(szOutputStr, szBuf);
    lstrcat(szOutputStr, ": ");
    lstrcat(szOutputStr, szArgVBuf);
    lstrcat(szOutputStr, "\n");
  }
  MessageBox(NULL, szOutputStr, "Output", MB_OK);
#endif

  /* Get the first parameter */
  GetArgV(lpszCmdLine, 0, szSeaExe, sizeof(szSeaExe));
  if(lstrcmpi(szSeaExe, "-g") == 0)
  {
    /* The first parameter is "-g".
     * Create a new nszip that contains nsinstall.exe in itself */

    GetArgV(lpszCmdLine, 1, szNsZipName, sizeof(szNsZipName));
    GetArgV(lpszCmdLine, 2, szSeaExe, sizeof(szSeaExe));
    if(!FileExists(szSeaExe))
    {
      wsprintf(szBuf, "file not found: %s", szSeaExe);
      PrintError(szBuf, ERROR_CODE_HIDE);
      exit(1);
    }

    if(GetModuleFileName(NULL, szAppName, sizeof(szAppName)) == 0L)
    {
      PrintError("GetModuleFileName() failed", ERROR_CODE_SHOW);
      exit(1);
    }
    if(!FileExists(szAppName))
    {
      wsprintf(szBuf, "File not found: %s", szAppName);
      PrintError(szBuf, ERROR_CODE_HIDE);
      exit(1);
    }

    if(CopyFile(szAppName, szNsZipName, FALSE) == FALSE)
    {
      wsprintf(szBuf, "Error creating %s", szNsZipName);
      PrintError(szBuf, ERROR_CODE_SHOW);
      exit(1);
    }

    hExe = InitResource(szNsZipName);
    AddFile(hExe, szSeaExe);
    DeInitResource(hExe);
    return(0);
  }
  else
  {
    /* The first parameter is not "-g".  Assume that it's the name of the
     * self-extracting .exe to be saved as.  So lets create it only if it does not exist. */

    if(!FileExists(szSeaExe))
    {
      EnumResourceNames(NULL, "FILE", (ENUMRESNAMEPROC)ExtractFilesProc, (LONG)szSeaExe);

      // if still does not exist, copy nsinstall.exe to szSeaExe
      if(!FileExists(szSeaExe))
      {
        if(FileExists(DEFAULT_SEA_FILE))
          CopyFile(DEFAULT_SEA_FILE, szSeaExe, FALSE);
        else
        {
          wsprintf(szBuf, "file not found: %s", DEFAULT_SEA_FILE);
          PrintError(szBuf, ERROR_CODE_HIDE);
          exit(1);
        }
      }
    }

    if(!FileExists(szSeaExe))
    {
      wsprintf(szBuf, "file not found: %s", szSeaExe);
      PrintError(szBuf, ERROR_CODE_HIDE);
      exit(1);
    }
  }

  hExe = InitResource(szSeaExe);
  for(i = 1; i < iArgC; i++)
  {
    GetArgV(lpszCmdLine, i, szArgVBuf, sizeof(szArgVBuf));
    GetFullPathName(szArgVBuf, sizeof(szFileFullPath), szFileFullPath, NULL);
    hFindFile = FindFirstFile(szFileFullPath, &findFileData);

    if(hFindFile == INVALID_HANDLE_VALUE)
    {
      wsprintf(szBuf, "file not found: %s", szArgVBuf);
      PrintError(szBuf, ERROR_CODE_HIDE);
      exit(1);
    }

    do
    {
      char szFile[MAX_BUF];

      if(!(findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
      {
        // We need to pass to AddFile() whatever kind of path we were passed,
        // e.g. simple, relative, full
        strcpy(szFile, szFileFullPath);
        strcpy(strrchr(szFile, '\\') + 1, findFileData.cFileName);
        AddFile(hExe, szFile);
      }
    } while(FindNextFile(hFindFile, &findFileData));

    FindClose(hFindFile);
  }

  DeInitResource(hExe);
  return(0);
}
Пример #24
0
void UAtmosphericFogComponent::PostLoad()
{
    Super::PostLoad();

    if ( !IsTemplate() )
    {
#if WITH_EDITOR
        if (TransmittanceTexture_DEPRECATED)
        {
            // Copy data from Previous data
            if (TransmittanceTexture_DEPRECATED->Source.IsValid())
            {
                TArray<uint8> RawData;
                TArray<FColor> OutData;
                TransmittanceTexture_DEPRECATED->Source.GetMipData(RawData, 0);
                // Convert from FFloat16Color to FColor
                for (int32 i = 0; i < RawData.Num(); i+=sizeof(FFloat16Color))
                {
                    FFloat16Color* OriginalColor = (FFloat16Color*)&RawData[i];
                    FColor TempColor;
                    TempColor.R = FMath::Clamp<uint8>(OriginalColor->R.GetFloat() * 255, 0, 255);
                    TempColor.G = FMath::Clamp<uint8>(OriginalColor->G.GetFloat() * 255, 0, 255);
                    TempColor.B = FMath::Clamp<uint8>(OriginalColor->B.GetFloat() * 255, 0, 255);
                    OutData.Add(TempColor);
                }

                int32 TotalByte = OutData.Num() * sizeof(FColor);
                TransmittanceData.Lock(LOCK_READ_WRITE);
                FColor* TextureData = (FColor*)TransmittanceData.Realloc(TotalByte);
                FMemory::Memcpy(TextureData, OutData.GetData(), TotalByte);
                TransmittanceData.Unlock();

                TransmittanceTexture_DEPRECATED = NULL;
            }
        }

        if (IrradianceTexture_DEPRECATED)
        {
            if (IrradianceTexture_DEPRECATED->Source.IsValid())
            {
                TArray<uint8> RawData;
                TArray<FColor> OutData;
                IrradianceTexture_DEPRECATED->Source.GetMipData(RawData, 0);
                // Convert from FFloat16Color to FColor
                for (int32 i = 0; i < RawData.Num(); i+=sizeof(FFloat16Color))
                {
                    FFloat16Color* OriginalColor = (FFloat16Color*)&RawData[i];
                    FColor TempColor;
                    TempColor.R = FMath::Clamp<uint8>(OriginalColor->R.GetFloat() * 255, 0, 255);
                    TempColor.G = FMath::Clamp<uint8>(OriginalColor->G.GetFloat() * 255, 0, 255);
                    TempColor.B = FMath::Clamp<uint8>(OriginalColor->B.GetFloat() * 255, 0, 255);
                    OutData.Add(TempColor);
                }

                int32 TotalByte = OutData.Num() * sizeof(FColor);
                IrradianceData.Lock(LOCK_READ_WRITE);
                FColor* TextureData = (FColor*)IrradianceData.Realloc(TotalByte);
                FMemory::Memcpy(TextureData, OutData.GetData(), TotalByte);
                IrradianceData.Unlock();

                IrradianceTexture_DEPRECATED = NULL;
            }
        }
#endif
        InitResource();
    }
}
Пример #25
0
int CEngine::Create(HINSTANCE hInst, bool IsWindow, DWORD w, DWORD h)
{
#ifndef _DEBUG
	CheckLFH();
#endif

	m_hInst = hInst;
	m_bWindowMode = IsWindow;

	if(m_bWindowMode == TRUE)
	{
		// 창모드
		m_dwStyle = WS_CAPTION | WS_SYSMENU;
		m_d3dfmt  = D3DFMT_UNKNOWN;
		m_dwScreenWidth = w;
		m_dwScreenHeight= h;
	}else{
		// 풀스크린 모드
		m_dwStyle =	WS_EX_TOPMOST | WS_POPUP;
		m_d3dfmt  = D3DFMT_X8R8G8B8;
		m_dwScreenWidth = ::GetSystemMetrics(SM_CXSCREEN);
		m_dwScreenHeight = ::GetSystemMetrics(SM_CYSCREEN);
	}

	WNDCLASSEX wc =
	{
		sizeof( WNDCLASSEX ), 
		CS_CLASSDC, 
		WndProc,
		0L, 
		0L,
		GetModuleHandle( NULL ), 
		LoadIcon(m_hInst,MAKEINTRESOURCE(ICON)), // 아이콘
		LoadCursor(m_hInst,MAKEINTRESOURCE(CURSOR)), // 커서
		NULL, 
		NULL,
		m_sAppTitle.c_str(), 
		NULL
	};

	RegisterClassEx( &wc );

	RECT rt = { 0, 0, m_dwScreenWidth, m_dwScreenHeight };
	AdjustWindowRect(&rt,m_dwStyle,false);

	DWORD width = rt.right - rt.left;
	DWORD height = rt.bottom - rt.top;

	m_uiClientPosX = GetSystemMetrics(SM_CXSCREEN)/2-width/2;
	m_uiClientPosY = GetSystemMetrics(SM_CYSCREEN)/2-height/2;

	m_hWnd = CreateWindow( m_sAppTitle.c_str(), m_sAppTitle.c_str(), m_dwStyle, 
		m_uiClientPosX, m_uiClientPosY, width, height, NULL, NULL, m_hInst, NULL );
	printf("Resizing window <%d %d>\n", width, height);

	if( NULL == m_hWnd)
	{
		printf("윈도우를 생성할 수 없습니다.");
		return -1;
	}

	if( NULL == ( m_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
	{
		printf("다이렉트X 장치를 생성할 수 없습니다.");
		return -1;
	}

	// 그래픽 카드 이름 얻기
	//D3DADAPTER_IDENTIFIER9 id;
	//ZeroMemory(&id,sizeof(id));
	//if( FAILED(m_pD3D->GetAdapterIdentifier( D3DADAPTER_DEFAULT, NULL, &id)) )
	//{
	//	printf("어댑터 정보를 얻어올 수 없습니다.");
	//	return -1;
	//}
	//printf("Graphic card name : %s\n", id.Description);

	ZeroMemory( &m_d3dpp, sizeof( m_d3dpp ) );
	m_d3dpp.Windowed = m_bWindowMode;
	m_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
	m_d3dpp.BackBufferFormat = m_d3dfmt;
	m_d3dpp.BackBufferHeight = m_dwScreenHeight;
	m_d3dpp.BackBufferWidth = m_dwScreenWidth;

	// 버텍스 프로세스 처리
	D3DCAPS9 caps;
	if( FAILED(m_pD3D->GetDeviceCaps(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,&caps)) )
	{
		printf("디바이스 지원가능 여부를 조사 할 수 없습니다.");
		return -1;
	}

	DWORD vp =0;
	if(caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT)
		vp = D3DCREATE_HARDWARE_VERTEXPROCESSING;
	else
		vp = D3DCREATE_SOFTWARE_VERTEXPROCESSING;

	if( FAILED( m_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_hWnd, vp, &m_d3dpp, &m_pd3dDevice ) ) )
	{
		printf("다이렉트X 랜더링 디바이스를 생성할 수 없습니다.");
		return -1;
	}

	// 어댑터가 지원하는 해상도 조사
	UINT iNumberOfModes = m_pD3D->GetAdapterModeCount(D3DADAPTER_DEFAULT, m_d3dpp.BackBufferFormat);

	D3DDISPLAYMODE iDisMode;
	ZeroMemory(&iDisMode,sizeof(iDisMode));
	for(UINT i=0;i<iNumberOfModes;i++)
	{
		if( FAILED( m_pD3D->EnumAdapterModes( D3DADAPTER_DEFAULT, m_d3dpp.BackBufferFormat, i, &iDisMode)) )
		{
			printf("어댑터의 해상도 지원 정보를 조사할 수 없습니다.");
			return -1;
		}
		m_vDisplayMode.push_back(iDisMode);
	}

	// 스프라이트 객체 생성
	if(FAILED(D3DXCreateSprite(m_pd3dDevice, &m_pd3dSprite)))
	{
		return -1;
	}

	// 컬링 모드 끄기
	m_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);

	::ShowWindow( m_hWnd, SW_SHOWDEFAULT );
	::UpdateWindow( m_hWnd );
	::ShowCursor(m_bShowCursor);

	// 다이렉트X 디바이스 생성및 초기화
	if(FAILED(InitResource(m_hInst)))
	{
		printf("InitD3D 오류");
		return -1;
	}

	return 0;
}
	// FDynamicPrimitiveResource interface.
	void InitPrimitiveResource() override
	{
		InitResource();
	}
	// FDynamicPrimitiveResource interface.
	virtual void InitPrimitiveResource()
	{
		InitResource();
	}