コード例 #1
0
void initScreens(JNIEnv *env) {
    awt_numScreens = ::CountMonitors();
    monHds = (MHND *)safe_Malloc(awt_numScreens * sizeof(MHND));
    AwtWin32GraphicsDevice **tempDevArray;
    if (awt_numScreens != ::CollectMonitors(monHds, awt_numScreens)) {
        JNU_ThrowInternalError(env, "Failed to get all monitor handles.");
    }

    if (devices) {
	devices->RemoveReference();
	// Lock access to devices array until we've created the new
	// array.  Prevents things like accessing out-of-date color
	// models and partially-created devices array.
    }
    MTSafeArray *tmpDevices = new MTSafeArray(awt_numScreens);
    // Add reference for the overall array - don't want to delete it just
    // because there are no surfaceData objects referencing it
    tmpDevices->AddReference();

    // Create all devices first, then initialize them.  This allows
    // correct configuration of devices after contruction of the
    // primary device (which may not be device 0).
    tempDevArray = (AwtWin32GraphicsDevice**)
	safe_Malloc(awt_numScreens * sizeof(AwtWin32GraphicsDevice));
    for (int i = 0; i < awt_numScreens; ++i) {
	tempDevArray[i] = new AwtWin32GraphicsDevice(i, tmpDevices);
    }
    for (i = 0; i < awt_numScreens; ++i) {
	tempDevArray[i]->Initialize();
	tmpDevices->AddElement(tempDevArray[i], i);
    }
    free(tempDevArray);
    devices = tmpDevices;
    InitDirectX();
}
コード例 #2
0
	bool CEngine::Init(const SInitParam& initParam)
	{
		//ウィンドウ初期化。
		if (!InitWindow(initParam)) {
			return false;
		}
		//DirectX初期化。
		if (!InitDirectX(initParam)) {
			return false;
		}
		//メインレンダリングターゲットを作成。
		for (int i = 0; i < 2; i++) {
			m_mainRenderTarget[i].Create(
				m_frameBufferWidth,
				m_frameBufferHeight,
				1,
				FMT_A16B16G16R16F,
				FMT_D24S8,
				MULTISAMPLE_NONE,
				0
			);
		}

		CGameObjectManager::Instance().Init( initParam.gameObjectPrioMax );
		InitCopyBackBufferPrimitive();
		//レンダリングコンテキストの初期化。
		{
			m_renderContextArray.reset(new CRenderContext[initParam.numRenderContext]);
			for (int i = 0; i < initParam.numRenderContext; i++) {
				m_renderContextArray[i].Init(m_pD3DDevice, initParam.commandBufferSizeTbl[i]);
			}
			m_numRenderContext = initParam.numRenderContext;
			if (m_numRenderContext > 1) {
				TK_ASSERT(initParam.renderContextMap != nullptr, "renderContextMap is nullptr!!!");
				m_renderContextMap.reset( new SRenderContextMap[m_numRenderContext]);
				memcpy(m_renderContextMap.get(), initParam.renderContextMap, sizeof(SRenderContextMap) * m_numRenderContext);
			}
		}
		//トランスフォーム済みプリミティブを描画するシェーダーをロード。
		m_pTransformedPrimEffect = m_effectManager.LoadEffect("Assets/presetShader/TransformedPrim.fx");
		//プリレンダリングを作成。
		m_preRender.Create( initParam.graphicsConfig );
		//ポストエフェクトをレンダリング。
		m_postEffect.Create( initParam.graphicsConfig );
		m_soundEngine.Init();
		m_physicsWorld.Init();
		ShowWindow(m_hWnd, SW_SHOWDEFAULT);
		UpdateWindow(m_hWnd);
		return true;
	}
コード例 #3
0
ファイル: Application.cpp プロジェクト: Ajzahtiri/3DCG
HRESULT Application::Initialise(HINSTANCE hInstance, int nCmdShow)
{
    if (FAILED(InitWindow(hInstance, nCmdShow)))
	{
        return E_FAIL;
	}

    RECT rc;
    GetClientRect(_hWnd, &rc);
    _WindowWidth = rc.right - rc.left;
    _WindowHeight = rc.bottom - rc.top;

	//inits device
    if (FAILED(InitDirectX()))
    {
        Cleanup();

        return E_FAIL;
    }

	//inits input
	if (FAILED(InitInput(hInstance)))
	{
		Cleanup();

		return E_FAIL;
	}

	// Initialize the world matrix
	XMStoreFloat4x4(&_cube1, XMMatrixIdentity());
	XMStoreFloat4x4(&_cube2, XMMatrixIdentity());

	_cubbe1.Initialise(_pd3dDevice);
	_cubbe2.Initialise(_pd3dDevice);

	//inits camera (view matrix)
	if (FAILED(_cam.Initialise()))
	{
		Cleanup();

		return E_FAIL;
	}

    // Initialize the projection matrix
	XMStoreFloat4x4(&_projection, XMMatrixPerspectiveFovLH(XM_PIDIV2, _WindowWidth / (FLOAT) _WindowHeight, 1.0f, 100.0f));

	return S_OK;
}
コード例 #4
0
ファイル: RenderMesh.cpp プロジェクト: kami36/Study
int APIENTRY WinMain(HINSTANCE hInstance, 
					 HINSTANCE hPrevInstance, 
					 LPSTR lpCmdLine, 
					 int nCmdShow)
{
	wchar_t className[32] = L"Sample";
	wchar_t windowName[32] = L"Sample";

	//윈도우 클레스 정보 생성
	//내가 이러한 윈도를 만들겠다 라는 정보
	WNDCLASS WndClass;
	WndClass.cbClsExtra = 0;			//윈도우에서 사용하는 여분의 메모리설정( 그냥 0 이다  신경쓰지말자 )
	WndClass.cbWndExtra = 0;			//윈도우에서 사용하는 여분의 메모리설정( 그냥 0 이다  신경쓰지말자 )
	WndClass.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);		//윈도우 배경색상
	WndClass.hCursor = LoadCursor( NULL, IDC_ARROW );			//윈도우의 커서모양 결정
	WndClass.hIcon = LoadIcon( NULL, IDI_APPLICATION );		//윈도우아이콘모양 결정
	WndClass.hInstance = hInstance;				//프로그램인스턴스핸들 
	WndClass.lpfnWndProc = (WNDPROC)WndProc;			//윈도우 프로시져 함수 포인터
	WndClass.lpszMenuName = NULL;						//메뉴이름 없으면 NULL
	WndClass.lpszClassName = className;				//지금 작성하고 있는 윈도우 클레스의 이름
	WndClass.style	 = CS_HREDRAW | CS_VREDRAW;	//윈도우 그리기 방식 설정 ( 사이즈가 변경될때 화면갱신 CS_HREDRAW | CS_VREDRAW )

	//위에서 작성한 윈도우 클레스정보 등록
	RegisterClass( &WndClass );

	//윈도우 생성
	//생성된 윈도우 핸들을 전역변수 g_hWnd 가 받는다.
	HWND hWnd = CreateWindow(
		className,				//생성되는 윈도우의 클래스이름
		windowName,				//윈도우 타이틀바에 출력되는 이름
		WS_OVERLAPPEDWINDOW,	//윈도우 스타일 WS_OVERLAPPEDWINDOW
		WINPOS_X,				//윈도우 시작 위치 X 
		WINPOS_Y,				//윈도우 시작 위치 Y
		WINSIZE_X,				//윈도우 가로 크기 ( 작업영역의 크기가 아님 )
		WINSIZE_Y,				//윈도우 세로 크기 ( 작업영역의 크기가 아님 )
		GetDesktopWindow(),		//부모 윈도우 핸들 ( 프로그램에서 최상위 윈도우면 NULL 또는 GetDesktopWindow() )
		NULL,					//메뉴 ID ( 자신의 컨트롤 객체의 윈도우인경우 컨트롤 ID 가 된	
		hInstance,				//이 윈도우가 물릴 프로그램 인스턴스 핸들
		NULL					//추가 정보 NULL ( 신경끄자 )
		);

	//윈도우를 정확한 작업영역 크기로 맞춘다
	RECT rcClient = { 0, 0, WINSIZE_X, WINSIZE_Y };
	AdjustWindowRect( &rcClient, WS_OVERLAPPEDWINDOW, FALSE );	//rcClient 크기를 작업 영영으로 할 윈도우 크기를 rcClient 에 대입되어 나온다.

	//윈도우 크기와 윈도우 위치를 바꾸어준다.
	SetWindowPos( hWnd, NULL, 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top, 
		SWP_NOZORDER | SWP_NOMOVE );

	if (!InitDirectX(hWnd))
	{
		return 0;
	}

	InitVertexBuffer();

	ShowWindow( hWnd, nCmdShow );

	//메시지 구조체
	MSG msg;		
	ZeroMemory( &msg, sizeof( MSG ) );

	int oldT = GetTickCount();
	while (msg.message != WM_QUIT)
	{
		//PeekMessage 는 메시지 큐에 메시지가 없어도 프로그램이 멈추기 않고 진행이 된다.
		//이때 메시지큐에 메시지가 없으면 false 가 리턴되고 메시지가 있으면 true 가 리턴이된다.
		if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
		{
			TranslateMessage( &msg ); //눌린 키보드 의 문자를 번역하여 WM_CHAR 메시지를 발생시킨다.
			DispatchMessage( &msg );  //받아온 메시지 정보로 윈도우 프로시져 함수를 실행시킨다.
		}
		else
		{
			const int curT = GetTickCount();
			const int elapseT = curT - oldT;
			if (elapseT > 15)
			{
				oldT = curT;
				Render(elapseT);
			}
		}
	}

	if (g_pDevice)
		g_pDevice->Release();
	if (g_pVB)
		g_pVB->Release();
	if (g_pIB)
		g_pIB->Release();
	if (g_pMesh)
		g_pMesh->Release();
	return 0;
}
コード例 #5
0
ファイル: DXApp.cpp プロジェクト: DanielHop/GameEngine
bool DXApp::Init()
{
	return (InitWindow() && InitDirectX());
}