コード例 #1
0
ファイル: main.cpp プロジェクト: dianxiang/graphics
void InitD3D( HWND hWnd, SFLOAT width, SFLOAT height ){

	//initializing swap chain
	DXGI_SWAP_CHAIN_DESC swapChainDesc;

	ZeroMemory( &swapChainDesc, sizeof( DXGI_SWAP_CHAIN_DESC ) );

	swapChainDesc.BufferCount = 1; // number of back buffers
	swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; //unsigned normalized values
	swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; // draw graphics into back buffer
	swapChainDesc.OutputWindow = hWnd; // window to output to
	swapChainDesc.SampleDesc.Count = 4; // anti-aliasing that is done on the images
	swapChainDesc.Windowed = TRUE;

	D3D_FEATURE_LEVEL featureLevels[] = 
	{
		//D3D_FEATURE_LEVEL_11_0
        D3D_FEATURE_LEVEL_10_1,
        //D3D_FEATURE_LEVEL_10_0,
	};

	HRESULT hr = D3D11CreateDeviceAndSwapChain(
		NULL,
		D3D_DRIVER_TYPE_HARDWARE,
		NULL,
		0, //flags for singlethreading/multithreading etc. stuff
		featureLevels,
		1,
		D3D11_SDK_VERSION,
		&swapChainDesc,
		&gSwapChain,
		&gDevice,
		NULL,
		&gDeviceContext
	);

	//setting the render target to the back buffer
	//get address of back buffer into renderTargetLocation
	ID3D11Texture2D *renderTargetAddress;
	gSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), (LPVOID*)&renderTargetAddress );

	//using the back buffer address to create the render target
	gDevice->CreateRenderTargetView( renderTargetAddress, NULL, &gRenderTargetView );
	renderTargetAddress->Release();

	//set render target as the back buffer
	gDeviceContext->OMSetRenderTargets( 1, &gRenderTargetView, NULL );

	InitViewport( width, height );
	//InitRasterizer();
	InitGraphics( width, height );
	InitPipeline();

}
コード例 #2
0
void GLUTCALLBACK Draw(void)
{
  glClear(GL_COLOR_BUFFER_BIT);
  glBlendFunc(blendSrc, blendDst);
  glAlphaFunc(alphaFunc, 0.5f);

  InitViewport(0,0, windW/2, windH);
  DrawBorder(0);

  glColor3f(0.0, 0.0, 1.0);
  DrawScene(0);

  InitViewport(windW/2, 0, windW/2, windH);
  DrawBorder(1);

  glColor3f(1.0, 0.0, 0.0);
  DrawScene(1);

  glFinish();
  glutSwapBuffers();
}
コード例 #3
0
static void GLUTCALLBACK  Draw(void)
{
  glClear(GL_COLOR_BUFFER_BIT);
    
  InitViewport(0,0, windW/2, windH);
  DrawBorder(0);

  glColor3f(0.0, 0.0, 1.0);
  DrawScene(0);

  InitViewport(windW/2, 0, windW/2, windH);
  DrawBorder(1);
  
  glColor3f(1.0, 0.0, 0.0);
  DrawScene(1);

  glFinish();

    glFlush();

//    if (doubleBuffer) {
	glutSwapBuffers();
//    }
}
コード例 #4
0
void OgreApplication::Init(void){

	/* Set default values for the variables */
	animating_ = false;
	space_down_ = false;
	animation_state_ = NULL;
	input_manager_ = NULL;
	keyboard_ = NULL;
	mouse_ = NULL;

	/* Run all initialization steps */
    InitRootNode();
    InitPlugins();
    InitRenderSystem();
    InitWindow();
    InitViewport();
	InitEvents();
	InitOIS();
	LoadMaterials();
}
コード例 #5
0
ファイル: AsteroidGame.cpp プロジェクト: Untamedhawk/Comp3501
//////////////////
//Init Functions//
/////////////////
void AsteroidGame::Init(void){
	input_manager_ = NULL;
	keyboard_ = NULL;
	mouse_ = NULL;

	/* Run all initialization steps */
    InitRootNode();
    InitPlugins();
    InitRenderSystem();
    InitWindow();
    InitViewport();
	InitEvents();
	InitOIS();
	LoadMaterials();

	InitManagers();
	


	iAsteroidManager->createAsteroidField();

	iGameState = GameState::Running;
}