int main(int argc, char* argv[]) { struct stat st; char* output_dir; if (argc != 2) { fprintf(stderr, "usage: %s outdir\n", argv[0]); return kErrArgc; } output_dir = argv[1]; if (stat(output_dir, &st) == -1) { fprintf(stderr, "error: could not stat %s\n", output_dir); return kErrCannotStat; } if (!S_ISDIR(st.st_mode)) { fprintf(stderr, "error: not a directory: %s\n", output_dir); return kErrNotADir; } InitStates(); InitTransitions(); OutputInit(&g_output, output_dir); TraverseStates(start_state, false); OutputCloseCurrent(&g_output); return 0; }
CRRC_AirplaneSim_MCopter01::CRRC_AirplaneSim_MCopter01(const char* filename, FDMEnviroment* myEnv, SimpleXMLTransfer* cfg) : EOM01("fdm_mcopter01.dat", myEnv) { // Previously there has been code to load an old-style .air-file. // This has been removed as CRRCSim includes an automatic converter. SimpleXMLTransfer* fileinmemory = new SimpleXMLTransfer(filename); power.clear(); LoadFromXML(fileinmemory, cfg->getInt("airplane.verbosity", 5)); InitStates(); delete fileinmemory; }
// this function initializes and prepares Direct3D for use void InitD3D(HWND hWnd) { // create a struct to hold information about the swap chain DXGI_SWAP_CHAIN_DESC scd; // clear out the struct for use ZeroMemory(&scd, sizeof(DXGI_SWAP_CHAIN_DESC)); // fill the swap chain description struct scd.BufferCount = 1; // one back buffer scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; // use 32-bit color scd.BufferDesc.Width = SCREEN_WIDTH; // set the back buffer width scd.BufferDesc.Height = SCREEN_HEIGHT; // set the back buffer height scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; // how swap chain is to be used scd.OutputWindow = hWnd; // the window to be used scd.SampleDesc.Count = 4; // how many multisamples scd.Windowed = TRUE; // windowed/full-screen mode scd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; // allow full-screen switching // create a device, device context and swap chain using the information in the scd struct D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, NULL, NULL, NULL, D3D11_SDK_VERSION, &scd, &swapchain, &dev, NULL, &devcon); // create the depth buffer texture D3D11_TEXTURE2D_DESC texd; ZeroMemory(&texd, sizeof(texd)); texd.Width = SCREEN_WIDTH; texd.Height = SCREEN_HEIGHT; texd.ArraySize = 1; texd.MipLevels = 1; texd.SampleDesc.Count = 4; texd.Format = DXGI_FORMAT_D32_FLOAT; texd.BindFlags = D3D11_BIND_DEPTH_STENCIL; ID3D11Texture2D *pDepthBuffer; dev->CreateTexture2D(&texd, NULL, &pDepthBuffer); // create the depth buffer D3D11_DEPTH_STENCIL_VIEW_DESC dsvd; ZeroMemory(&dsvd, sizeof(dsvd)); dsvd.Format = DXGI_FORMAT_D32_FLOAT; dsvd.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMS; dev->CreateDepthStencilView(pDepthBuffer, &dsvd, &zbuffer); pDepthBuffer->Release(); // get the address of the back buffer ID3D11Texture2D *pBackBuffer; swapchain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&pBackBuffer); // use the back buffer address to create the render target dev->CreateRenderTargetView(pBackBuffer, NULL, &backbuffer); pBackBuffer->Release(); // set the render target as the back buffer devcon->OMSetRenderTargets(1, &backbuffer, zbuffer); // Set the viewport D3D11_VIEWPORT viewport; ZeroMemory(&viewport, sizeof(D3D11_VIEWPORT)); viewport.TopLeftX = 0; // set the left to 0 viewport.TopLeftY = 0; // set the top to 0 viewport.Width = SCREEN_WIDTH; // set the width to the window's width viewport.Height = SCREEN_HEIGHT; // set the height to the window's height viewport.MinDepth = 0; // the closest an object can be on the depth buffer is 0.0 viewport.MaxDepth = 1; // the farthest an object can be on the depth buffer is 1.0 devcon->RSSetViewports(1, &viewport); InitPipeline(); InitGraphics(); InitStates(); }
CRRC_AirplaneSim_MCopter01::CRRC_AirplaneSim_MCopter01(SimpleXMLTransfer* xml, FDMEnviroment* myEnv, SimpleXMLTransfer* cfg) : EOM01("fdm_mcopter01.dat", myEnv) { power.clear(); LoadFromXML(xml, cfg->getInt("airplane.verbosity", 5)); InitStates(); }
void CGLImpl::Init() { use_aa = 1;// not working // The device-creation presentation params with reasonable defaults D3DPRESENT_PARAMETERS d3dpp = { 1280, // BackBufferWidth; 720, // BackBufferHeight; D3DFMT_A8R8G8B8, // BackBufferFormat; 1, // BackBufferCount; D3DMULTISAMPLE_NONE,// MultiSampleType; 0, // MultiSampleQuality; D3DSWAPEFFECT_DISCARD, // SwapEffect; NULL, // hDeviceWindow; FALSE, // Windowed; TRUE, // EnableAutoDepthStencil; D3DFMT_D24S8, // AutoDepthStencilFormat; 0, // Flags; 0, // FullScreen_RefreshRateInHz; D3DPRESENT_INTERVAL_IMMEDIATE, // FullScreen_PresentationInterval; }; if (use_aa) { //d3dpp.BackBufferFormat = ( D3DFORMAT )MAKESRGBFMT( D3DFMT_A8R8G8B8 ); d3dpp.BackBufferCount = 0; d3dpp.EnableAutoDepthStencil = FALSE; d3dpp.DisableAutoBackBuffer = TRUE; d3dpp.DisableAutoFrontBuffer = TRUE; d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8; } XDKGlGetScreenSize((int*)&d3dpp.BackBufferWidth, (int*)&d3dpp.BackBufferHeight); HRESULT hr; // Create Direct3D LPDIRECT3D9 pD3D = Direct3DCreate9( D3D_SDK_VERSION ); // Create the D3D device if( FAILED( hr = pD3D->CreateDevice( 0, D3DDEVTYPE_HAL, NULL, NULL, &d3dpp, &device ) ) ) { printf( "Could not create D3D device!\n" ); DebugBreak(); } pD3D->Release(); // init aa surface if (use_aa) { D3DSURFACE_PARAMETERS params = {0}; int tile_w = 1280/4; int tile_h = 720; // render target params.Base = 0; device->CreateRenderTarget( tile_w, tile_h, D3DFMT_X8R8G8B8, D3DMULTISAMPLE_4_SAMPLES, 0, 0, &pRenderTarget, ¶ms ); // stencil+depth surface params.Base = pRenderTarget->Size / GPU_EDRAM_TILE_SIZE; params.HierarchicalZBase = D3DHIZFUNC_GREATER_EQUAL; device->CreateDepthStencilSurface( tile_w, tile_h, D3DFMT_D24S8, D3DMULTISAMPLE_4_SAMPLES, 0, 0, &pDepthStencilTarget, ¶ms ); device->CreateTexture( 1280, 720, 1, 0, ( D3DFORMAT )MAKESRGBFMT( D3DFMT_LE_X8R8G8B8 ), D3DPOOL_DEFAULT, &pFrontBuffer, NULL ); device->CreateTexture( 1280, 720, 1, 0, ( D3DFORMAT )MAKESRGBFMT( D3DFMT_X8R8G8B8 ), D3DPOOL_DEFAULT, &pResolveBuffer, NULL ); } // init stuff InitTextures(); InitializeMatrices(); InitStates(); state.render_height = d3dpp.BackBufferHeight; state.render_width = d3dpp.BackBufferWidth; #if USE_VB // create vb and stuff device->CreateVertexBuffer( 1024*1024*8,// 8 Mo 0, NULL, NULL, &pVbGL, NULL ); device->CreateIndexBuffer( 1024*1024*8,// 8 Mo 0, D3DFMT_INDEX32, NULL, &pIbGL, NULL); // refresh ib/vb cache GLImpl.pVbGL->Lock(0, 8*1024*1024, (void**)&GLImpl.prim.vertices.data, 0); //GLImpl.pVbGL->Unlock(); GLImpl.pIbGL->Lock(0, 8*1024*1024, (void**)&GLImpl.prim.indices.data, 0); //GLImpl.pIbGL->Unlock(); #endif if (use_aa) { device->SetRenderTarget( 0, pRenderTarget ); device->SetDepthStencilSurface( pDepthStencilTarget ); } //device->SynchronizeToPresentationInterval(); if (use_aa == 0) { device->GetFrontBuffer(&pFrontBuffer); } }