bool RageDisplay_D3D::BeginFrame() { GraphicsWindow::Update(); switch( g_pd3dDevice->TestCooperativeLevel() ) { case D3DERR_DEVICELOST: return false; case D3DERR_DEVICENOTRESET: { bool bIgnore = false; RString sError = SetD3DParams( bIgnore ); if( sError != "" ) RageException::Throw( sError ); break; } } g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,0), 1.0f, 0x00000000 ); g_pd3dDevice->BeginScene(); return RageDisplay::BeginFrame(); }
void RenderingManagerC::update() { // Clear the backbuffer to a blue color g_pd3dDevice->Clear( 0L, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL, D3DCOLOR_XRGB(0,0,255), 1.0f, 0L ); // Begin the scene g_pd3dDevice->BeginScene(); DrawBackground(); DrawPlayer(); DrawRaycast(); DrawPortal(true); DrawPortal(false); DrawCrossHair(); //DrawBox(71.0f, 673.0f, 1218.0f, 673.0f, 0x00000000, 0xFFFFFFFF); DrawStaticObjects(); DrawTurrents(); // End the scene g_pd3dDevice->EndScene(); // Present the backbuffer contents to the display g_pd3dDevice->Present( NULL, NULL, NULL, NULL ); }
void render() { static RECT rc = {0, 0, 320, 100}; // rectangular region.. used for text drawing static DWORD frameCount = 0; static DWORD startTime = clock(); char str[16]; doMath(); // do the math.. :-P frameCount++; // increment frame count // Clear the back buffer to a black... values r g b are 0-256 lpD3DDevice8->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER ,D3DCOLOR_XRGB(256, 256, 256), 1.0f, 0); // render the cubes myRect1->render(clock()); myRect2->render(clock()); // this function writes a formatted string to a character string // in this case.. it will write "Avg fps" followed by the // frames per second.. with 2 decimal places sprintf(str, "Avg fps %.2f", (float) frameCount / ((clock() - startTime) / 1000.0f)); // draw the text string.. lpD3DXFont->Begin(); lpD3DXFont->DrawText(str, -1, &rc, DT_LEFT, 0xFFFFFFFF); lpD3DXFont->End(); // present the back buffer.. or "flip" the page lpD3DDevice8->Present( NULL, NULL, NULL, NULL ); // these options are for using rectangular // regions for rendering/drawing... // 3rd is which target window.. NULL makes it use the currently set one (default) // last one is NEVER used.. that happens with DirectX often }
//----------------------------------------------------------------------------- // Name: Render() // Desc: Draws the scene //----------------------------------------------------------------------------- VOID Render() { // Clear the backbuffer and the zbuffer g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 ); // Begin the scene g_pd3dDevice->BeginScene(); // Setup the world, view, and projection matrices SetupMatrices(); // Meshes are divided into subsets, one for each material. Render them in // a loop for( DWORD i=0; i<g_dwNumMaterials; i++ ) { // Set the material and texture for this subset g_pd3dDevice->SetMaterial( &g_pMeshMaterials[i] ); g_pd3dDevice->SetTexture( 0, g_pMeshTextures[i] ); // Draw the mesh subset g_pMesh->DrawSubset( i ); } // End the scene g_pd3dDevice->EndScene(); // Present the backbuffer contents to the display g_pd3dDevice->Present( NULL, NULL, NULL, NULL ); }
//----------------------------------------------------------------------------- // Name: Render() // Desc: Draws the scene //----------------------------------------------------------------------------- VOID Render() { // Clear the backbuffer and the zbuffer g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 ); // Begin the scene g_pd3dDevice->BeginScene(); // Setup the lights and materials SetupLights(); // Setup the world, view, and projection matrices SetupMatrices(); // Render the vertex buffer contents g_pd3dDevice->SetStreamSource( 0, g_pVB, sizeof(CUSTOMVERTEX) ); g_pd3dDevice->SetVertexShader( D3DFVF_CUSTOMVERTEX ); g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2*50-2 ); // End the scene g_pd3dDevice->EndScene(); // Present the backbuffer contents to the display g_pd3dDevice->Present( NULL, NULL, NULL, NULL ); }
void StartFrame() { d3ddevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 ); d3ddevice->BeginScene(); }
//----------------------------------------------------------------------------- // Name: Render() // Desc: Draws the scene //----------------------------------------------------------------------------- VOID Render() { // Clear the backbuffer and the zbuffer g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 ); // Begin the scene g_pd3dDevice->BeginScene(); // Setup the world, view, and projection matrices SetupMatrices(); // Setup our texture. Using textures introduces the texture stage states, // which govern how textures get blended together (in the case of multiple // textures) and lighting information. In this case, we are modulating // (blending) our texture with the diffuse color of the vertices. g_pd3dDevice->SetTexture( 0, g_pTexture ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); #ifdef SHOW_HOW_TO_USE_TCI // Note: to use D3D texture coordinate generation, use the stage state // D3DTSS_TEXCOORDINDEX, as shown below. In this example, we are using // the position of the vertex in camera space to generate texture // coordinates. The tex coord index (TCI) parameters are passed into a // texture transform, which is a 4x4 matrix which transforms the x,y,z // TCI coordinates into tu, tv texture coordinates. // In this example, the texture matrix is setup to // transform the texture from (-1,+1) position coordinates to (0,1) // texture coordinate space: // tu = 0.5*x + 0.5 // tv = -0.5*y + 0.5 D3DXMATRIX mat; mat._11 = 0.25f; mat._12 = 0.00f; mat._13 = 0.00f; mat._14 = 0.00f; mat._21 = 0.00f; mat._22 =-0.25f; mat._23 = 0.00f; mat._24 = 0.00f; mat._31 = 0.00f; mat._32 = 0.00f; mat._33 = 1.00f; mat._34 = 0.00f; mat._41 = 0.50f; mat._42 = 0.50f; mat._43 = 0.00f; mat._44 = 1.00f; g_pd3dDevice->SetTransform( D3DTS_TEXTURE0, &mat ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION ); #endif // Render the vertex buffer contents g_pd3dDevice->SetStreamSource( 0, g_pVB, sizeof(CUSTOMVERTEX) ); g_pd3dDevice->SetVertexShader( D3DFVF_CUSTOMVERTEX ); g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2*50-2 ); // End the scene g_pd3dDevice->EndScene(); // Present the backbuffer contents to the display g_pd3dDevice->Present( NULL, NULL, NULL, NULL ); }
void RageDisplay_D3D::ResolutionChanged() { #if defined(XBOX) D3DVIEWPORT8 viewData = { 0,0,640,480, 0.f, 1.f }; g_pd3dDevice->SetViewport( &viewData ); g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,0), 1.0f, 0x00000000 ); #endif }
void Renderer::Begin(){ #if IS_XBOX // Clear the backbuffer and the zbuffer g_pd3dDevice->Clear( 0, nullptr, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 ); m_sprite->Begin(); #else startOpenGLDrawing(); #endif }
//----------------------------------------------------------------------------- // Name: Render() // Desc: Draws the scene //----------------------------------------------------------------------------- VOID Render() { if( NULL == g_pd3dDevice ) return; // Clear the backbuffer to a blue color g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 ); // Begin the scene g_pd3dDevice->BeginScene(); // Rendering of scene objects can happen here // End the scene g_pd3dDevice->EndScene(); // Present the backbuffer contents to the display g_pd3dDevice->Present( NULL, NULL, NULL, NULL ); }
bool RageDisplay_D3D::BeginFrame() { #if !defined(XBOX) switch( g_pd3dDevice->TestCooperativeLevel() ) { case D3DERR_DEVICELOST: return false; case D3DERR_DEVICENOTRESET: { bool bIgnore = false; CString sError = SetVideoMode( GraphicsWindow::GetParams(), bIgnore ); if( sError != "" ) RageException::Throw( sError ); break; } } #endif g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,0), 1.0f, 0x00000000 ); g_pd3dDevice->BeginScene(); return true; }
void RageDisplay_D3D::ClearZBuffer() { g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,0), 1.0f, 0x00000000 ); }
void render() { static RECT rc = {0, 0, 320, 100}; // rectangular region.. used for text drawing static DWORD frameCount = 0; static DWORD startTime = clock(); char str[16]; DWORD val; doMath(); // do the math.. :-P frameCount++; // increment frame count // Clear the back buffer to a black... values r g b are 0-256 lpD3DDevice8->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(256, 256, 256), 1.0f, 0); lpD3DDevice8->GetRenderState(D3DRS_LIGHTING, &val); if (val) { D3DLIGHT8 light; // structure for light data ZeroMemory( &light, sizeof(D3DLIGHT8) ); // zero the mem light.Type = D3DLIGHT_POINT; // set type, either SPOT, DIRECTIONAL, or POINT // light being put onto objects.. light.Diffuse.r = 1.0f; light.Diffuse.g = 1.0f; light.Diffuse.b = 1.0f; // ambient light of the light source.. only on when light is on light.Ambient.r = 0.25f; light.Ambient.g = 0.25f; light.Ambient.b = 0.25f; // attenuation = Atten0 + Atten1 * d + Atten2 * d * d; // where d is distance // attenuation is decreasing brightness as // a vertex is further away from the light source light.Attenuation0 = .5f; light.Attenuation1 = 0.10f; light.Attenuation2 = 0.01f; // spot lights and directional lights also have a direction // but a POINT light shines in all directions.. kinda like a light bulb light.Position = D3DXVECTOR3(0, 0, -2); light.Range = 15; // after this range the light doesn't affect vertices lpD3DDevice8->SetLight( 0, &light ); // set the light as index 0 lpD3DDevice8->LightEnable( 0, true ); // enable light at index 0 // ambient light.. for everything.. not attached to // this light, just lighting in general lpD3DDevice8->SetRenderState( D3DRS_AMBIENT, 0x00202020 ); } // render the cubes myRect1->render(clock()); myRect2->render(clock()); myRect3->render(clock()); myRect4->render(clock()); myRect5->render(clock()); // this function writes a formatted string to a character string // in this case.. it will write "Avg fps" followed by the // frames per second.. with 2 decimal places sprintf(str, "Avg fps %.2f", (float) frameCount / ((clock() - startTime) / 1000.0f)); // draw the text string.. lpD3DXFont->Begin(); lpD3DXFont->DrawText(str, -1, &rc, DT_LEFT, 0xFFFFFFFF); lpD3DXFont->End(); // present the back buffer.. or "flip" the page lpD3DDevice8->Present( NULL, NULL, NULL, NULL ); // these options are for using rectangular // regions for rendering/drawing... // 3rd is which target window.. NULL makes it use the currently set one (default) // last one is NEVER used.. that happens with DirectX often }
int D3DM_InitDevices( HWND hwnd, int w, int h, int full, HMENU menu ) { char buf[256]; int i,j; LPDIRECTDRAW7 pDD = NULL; HRESULT hr; if( FAILED( hr = DirectDrawCreateEx( NULL, (VOID**)&pDD, IID_IDirectDraw7, NULL ) ) ) return DDENUMRET_CANCEL; D3DCapsStruct.m_ddCaps.dwSize = sizeof(DDCAPS); pDD->GetCaps( &D3DCapsStruct.m_ddCaps, NULL ); if(pDD) { pDD->Release(); pDD = NULL; } ZeroMemory( d3dTexture, sizeof(D3DD_TEXTURE)*D3DD_MAX_TEXTURE_AMOUNT ); ZeroMemory( d3dText, sizeof(D3DD_TEXT)*D3DD_MAX_TEXT_AMOUNT ); ZeroMemory( d3dDisp, sizeof(D3DD_DISP)*D3DD_MAX_DISP_AMOUNT ); pD3D = Direct3DCreate8(D3D_SDK_VERSION); if(pD3D == NULL){ MessageBox(NULL,"Direct3Dオブジェクトの生成に失敗しました。[DirectX8.1が入っていない?]","致命的なエラー", MB_OK | MB_ICONSTOP); return FALSE; } if( FAILED(pD3D->GetDeviceCaps( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &D3DCapsStruct.m_d3dCaps)) ){ MessageBox(NULL,"デバイス能力の取得に失敗しました","致命的なエラー", MB_OK | MB_ICONSTOP); return FALSE; } EnumAdapters(D3DADAPTER_DEFAULT); if( (int)D3DCapsStruct.m_d3dCaps.MaxTextureWidth < D3DD_TEXTURE_CONTROL_SIZE ){ DebugBox( NULL, "このビデオカードは、幅 %d pixel 以上のサイズのテクスチャを生成できません。[%s]", D3DD_TEXTURE_CONTROL_SIZE); return FALSE; }else if( (int)D3DCapsStruct.m_d3dCaps.MaxTextureHeight < D3DD_TEXTURE_CONTROL_SIZE ){ DebugBox( NULL, "このビデオカードは、高さ %d pixel 以上のサイズのテクスチャを生成できません。[%s]", D3DD_TEXTURE_CONTROL_SIZE ); return FALSE; } if( !(D3DCapsStruct.m_d3dCaps.ShadeCaps&D3DPSHADECAPS_ALPHAGOURAUDBLEND) ){ MessageBox(NULL,"このビデオデバイスはグーロブレンディングに対応していません。\nゲームの画像が乱れることがあります","警告", MB_OK | MB_ICONSTOP); } if( !(D3DCapsStruct.m_d3dCaps.ShadeCaps&D3DPSHADECAPS_COLORGOURAUDRGB) ){ MessageBox(NULL,"このビデオデバイスはグーロシェーディングに対応していません。\nゲームの画像が乱れることがあります","警告", MB_OK | MB_ICONSTOP); } if( D3DCapsStruct.m_d3dCaps.TextureCaps&D3DPTEXTURECAPS_SQUAREONLY ){ DebugBox( NULL, "このビデオカードは長方形テクスチャを生成できません。[デバッグ用ダイアログ]" ); } if( FAILED(pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&D3DCapsStruct.m_NowDisplayMode)) ){ MessageBox(NULL,"ディスプレイモードの取得に失敗しました。[なにゆえ?]","致命的なエラー", MB_OK | MB_ICONSTOP); return FALSE; } D3DCapsStruct.m_WindowDisplayMode = D3DCapsStruct.m_NowDisplayMode; D3DMain.m_DrawHwnd = hwnd; D3DMain.m_MenuHwnd = menu; if( GetSystemMetrics(SM_CXFULLSCREEN)<=800 || GetSystemMetrics(SM_CYFULLSCREEN)<=600){ D3DMain.m_FullScreenOnly = TRUE; D3DMain.m_WindowMode = FALSE; }else{ D3DMain.m_FullScreenOnly = FALSE; D3DMain.m_WindowMode = !full; } ZeroMemory(&d3dppApp,sizeof(d3dppApp)); WinWidth = w; WinHeight = h; d3dppApp.SwapEffect = D3DSWAPEFFECT_COPY; d3dppApp.BackBufferFormat = D3DCapsStruct.m_NowDisplayMode.Format; d3dppApp.BackBufferCount = 1; d3dppApp.BackBufferWidth = WinWidth; d3dppApp.BackBufferHeight = WinHeight; d3dppApp.Windowed = TRUE; d3dppApp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; HRESULT ret; ret = pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_HARDWARE_VERTEXPROCESSING,&d3dppApp,&pD3DDevice); if( FAILED(ret) ){ ret = pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dppApp,&pD3DDevice); if( FAILED(ret) ){ D3DMain.m_FullScreenOnly = TRUE; } } if(D3DMain.m_FullScreenOnly==TRUE){ RELEASE_3D(pD3DDevice); D3DMain.m_WindowMode = FALSE; ZeroMemory(&d3dppApp,sizeof(d3dppApp)); for(i=0;i<D3DCapsStruct.m_DisplayModeNum;i++){ if( D3DCapsStruct.m_DisplayMode[i].Width == 800 && D3DCapsStruct.m_DisplayMode[i].Height == 600 ){ switch( D3DCapsStruct.m_DisplayMode[i].Format ){ case D3DFMT_R5G6B5: case D3DFMT_X1R5G5B5: case D3DFMT_A1R5G5B5: case D3DFMT_A4R4G4B4: case D3DFMT_X4R4G4B4: D3DCapsStruct.m_FullModeNum=i; d3dppApp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; d3dppApp.Windowed = D3DMain.m_WindowMode; d3dppApp.SwapEffect = FULL_FLIP; d3dppApp.BackBufferFormat = D3DCapsStruct.m_DisplayMode[i].Format; d3dppApp.BackBufferCount = 1; d3dppApp.BackBufferWidth = WinWidth; d3dppApp.BackBufferHeight = WinHeight; break; } } if(d3dppApp.SwapEffect) break; } if(!full){ wsprintf( buf, "このビデオカードの現在のモードではゲームを実行できません。フルスクリーン化しますか?\n[%d]", D3DCapsStruct.m_DisplayMode[i].RefreshRate ); if( MessageBox( NULL, buf, "問い合わせ", MB_YESNO )==IDNO ){ RELEASE_3D(pD3D); return FALSE; } } ret = pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_HARDWARE_VERTEXPROCESSING,&d3dppApp,&pD3DDevice); if( FAILED(ret) ){ ret = pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dppApp,&pD3DDevice); if( FAILED(ret) ){ switch(ret){ default: case D3DERR_OUTOFVIDEOMEMORY: DebugBox( NULL, "Direct3D が処理を行うのに十分なディスプレイ メモリがありません。" ); RELEASE_3D(pD3D); return FALSE; case D3DERR_INVALIDCALL: DebugBox( NULL, "Direct3Dの初期化に失敗しました[D3DERR_INVALIDCALL]\nこのグラフィックカードは必要な機能をサポートしていないか、\nあるいはDirectX8に対応したドライバが入っていません。" ); RELEASE_3D(pD3D); return FALSE; case D3DERR_NOTAVAILABLE: DebugBox( NULL, "Direct3Dの初期化に失敗しました[D3DERR_NOTAVAILABLE]\nこのグラフィックカードは必要な機能をサポートしていないか、\nあるいはDirectX8に対応したドライバが入っていません。" ); RELEASE_3D(pD3D); return FALSE; } } } }else{ if(D3DMain.m_WindowMode){ }else{ RELEASE_3D(pD3DDevice); ZeroMemory(&d3dppApp,sizeof(d3dppApp)); d3dppApp.SwapEffect = FULL_FLIP; d3dppApp.BackBufferCount = 1; d3dppApp.BackBufferWidth = WinWidth; d3dppApp.BackBufferHeight = WinHeight; d3dppApp.Windowed = FALSE; d3dppApp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; if(DrawSetting.full_16bit){ d3dppApp.BackBufferFormat=D3DFMT_UNKNOWN; for(i=0;i<D3DCapsStruct.m_DisplayModeNum;i++){ if( D3DCapsStruct.m_DisplayMode[i].Width == 800 && D3DCapsStruct.m_DisplayMode[i].Height == 600 ){ switch( D3DCapsStruct.m_DisplayMode[i].Format ){ case D3DFMT_R5G6B5: case D3DFMT_X1R5G5B5: case D3DFMT_A1R5G5B5: case D3DFMT_A4R4G4B4: case D3DFMT_X4R4G4B4: D3DCapsStruct.m_FullModeNum=i; d3dppApp.BackBufferFormat = D3DCapsStruct.m_DisplayMode[i].Format; break; } } if(d3dppApp.BackBufferFormat!=D3DFMT_UNKNOWN) break; } }else{ d3dppApp.BackBufferFormat = D3DCapsStruct.m_NowDisplayMode.Format; } ret = pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_HARDWARE_VERTEXPROCESSING,&d3dppApp,&pD3DDevice); if( FAILED(ret) ){ ret = pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dppApp,&pD3DDevice); if( FAILED(ret) ){ switch(ret){ default: case D3DERR_OUTOFVIDEOMEMORY: DebugBox( NULL, "Direct3D が処理を行うのに十分なディスプレイ メモリがありません。" ); RELEASE_3D(pD3D); return FALSE; case D3DERR_INVALIDCALL: DebugBox( NULL, "Direct3Dの初期化に失敗しました[D3DERR_INVALIDCALL]\nこのグラフィックカードは必要な機能をサポートしていないか、\nあるいはDirectX8に対応したドライバが入っていません。" ); RELEASE_3D(pD3D); return FALSE; case D3DERR_NOTAVAILABLE: DebugBox( NULL, "Direct3Dの初期化に失敗しました[D3DERR_NOTAVAILABLE]\nこのグラフィックカードは必要な機能をサポートしていないか、\nあるいはDirectX8に対応したドライバが入っていません。" ); RELEASE_3D(pD3D); return FALSE; } } } } } if( FAILED(pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&D3DCapsStruct.m_NowDisplayMode)) ){ MessageBox(NULL,"ディスプレイモードの取得に失敗しました。[なにゆえ?]","致命的なエラー", MB_OK | MB_ICONSTOP); RELEASE_3D(pD3D); return FALSE; } D3DCapsStruct.m_ttCaps.m_R8G8B8 = IsTextureFormatOk( D3DFMT_R8G8B8, D3DCapsStruct.m_NowDisplayMode.Format); D3DCapsStruct.m_ttCaps.m_X8R8G8B8 = IsTextureFormatOk( D3DFMT_X8R8G8B8, D3DCapsStruct.m_NowDisplayMode.Format); D3DCapsStruct.m_ttCaps.m_A8R8G8B8 = IsTextureFormatOk( D3DFMT_A8R8G8B8, D3DCapsStruct.m_NowDisplayMode.Format); D3DCapsStruct.m_ttCaps.m_R5G6B5 = IsTextureFormatOk( D3DFMT_R5G6B5, D3DCapsStruct.m_NowDisplayMode.Format); D3DCapsStruct.m_ttCaps.m_X1R5G5B5 = IsTextureFormatOk( D3DFMT_X1R5G5B5, D3DCapsStruct.m_NowDisplayMode.Format); D3DCapsStruct.m_ttCaps.m_A1R5G5B5 = IsTextureFormatOk( D3DFMT_A1R5G5B5, D3DCapsStruct.m_NowDisplayMode.Format); D3DCapsStruct.m_ttCaps.m_X4R4G4B4 = IsTextureFormatOk( D3DFMT_X4R4G4B4, D3DCapsStruct.m_NowDisplayMode.Format); D3DCapsStruct.m_ttCaps.m_A4R4G4B4 = IsTextureFormatOk( D3DFMT_A4R4G4B4, D3DCapsStruct.m_NowDisplayMode.Format); D3DCapsStruct.m_ttCaps.m_A8P8 = IsTextureFormatOk( D3DFMT_A8P8, D3DCapsStruct.m_NowDisplayMode.Format); D3DCapsStruct.m_ttCaps.m_P8 = IsTextureFormatOk( D3DFMT_P8, D3DCapsStruct.m_NowDisplayMode.Format); D3DCapsStruct.m_ttCaps.m_A8 = IsTextureFormatOk( D3DFMT_A8, D3DCapsStruct.m_NowDisplayMode.Format); D3DD_SetBackBuffer( WinWidth, WinHeight ); pD3DDevice->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_ARGB(0,0,0,0),1.0,0); if(0){ char buf2[512]; wsprintf( buf, "実行ディスプレイモード[%s]\n", TxFmtMode[ LIM(d3dppApp.BackBufferFormat,0,D3DFMT_D3DD_MAX-1) ] ); MBS_CPY(buf2,buf); MBS_CAT(buf2,"使用可能テクスチャ列挙\n"); for(i=1;i<D3DFMT_D3DD_MAX-1;i++){ if( TxFmtMode[i] ){ j = IsTextureFormatOk( (D3DFORMAT)i, D3DCapsStruct.m_NowDisplayMode.Format); if(j){ wsprintf(buf,"%-15s[%s]\n", TxFmtMode[i], (j==2)?"OK":"OK(NotRenderTarget)" ); MBS_CAT(buf2,buf); }else{ wsprintf(buf,"%-15s[%s]\n", TxFmtMode[i], "--Not--" ); MBS_CAT(buf2,buf); } } } DebugBox(NULL,buf2); } D3DD_CreateTable(); return TRUE; }
void __cdecl main() { int screenshot = 0; InitialiseD3D(); g_pGamePads = new c_GamePads(); g_pWorld = new c_World(g_pD3DDevice, g_pGamePads); D3DVIEWPORT8 viewport; viewport.Height = 5000; viewport.Width = 5000; viewport.X = 0; viewport.Y = 0; viewport.MinZ = 0.0f; viewport.MaxZ = 1.0f; DWORD WinnerColor = D3DCOLOR_XRGB(0, 0, 100); g_pWorld->pPlayer[0]->Dead = 1; g_pWorld->pPlayer[1]->Dead = 1; //DWORD musicresult = 0; //CWMAFileStream music; //music.Initialize("D:\\song1.wma"); //XVideo video; //video.LoadVideo("D:\\test.xmv"); //video.PlayVideo(); if(g_pWorld->pPlayer[0]->Dead != 0 && g_pWorld->pPlayer[1]->Dead != 0) { WinnerColor = D3DCOLOR_XRGB(150, 0, 0); g_pWorld->pPlayer[0]->Dead = 0; g_pWorld->pPlayer[0]->TransX = 2.5f; g_pWorld->pPlayer[0]->TransY = 5.0f; g_pWorld->pPlayer[0]->Theta = 3.1415f/2.0f; g_pWorld->pPlayer[0]->Phi = 3.1415f/2.0f; g_pWorld->pPlayer[0]->Firing = 0; g_pWorld->pPlayer[1]->Dead = 0; g_pWorld->pPlayer[1]->TransX = 2.5f; g_pWorld->pPlayer[1]->TransY = 80.0f - 5.0f; g_pWorld->pPlayer[1]->Theta = -3.1415f/2.0f; g_pWorld->pPlayer[1]->Phi = 3.1415f/2.0f; g_pWorld->pPlayer[1]->Firing = 0; g_pWorld->pPlayer[2]->Dead = 0; g_pWorld->pPlayer[2]->TransX = 180.0f - 2.5f; g_pWorld->pPlayer[2]->TransY = 5.0f; g_pWorld->pPlayer[2]->Theta = 3.1415f/2.0f; g_pWorld->pPlayer[2]->Phi = 3.1415f/2.0f; g_pWorld->pPlayer[2]->Firing = 0; g_pWorld->pPlayer[3]->Dead = 0; g_pWorld->pPlayer[3]->TransX = 180.0f - 2.5f; g_pWorld->pPlayer[3]->TransY = 80.0f - 5.0f; g_pWorld->pPlayer[3]->Theta = -3.1415f/2.0f; g_pWorld->pPlayer[3]->Phi = 3.1415f/2.0f; g_pWorld->pPlayer[3]->Firing = 0; g_pWorld->bfirstblood = 0; g_pWorld->rumble->Play(0); for(int i=0; i<150; i++) { g_pWorld->Balls[i].State = 0; } g_pWorld->wait = 1200; } while(true) { //music.Process(&musicresult); //DirectSoundDoWork(); g_pGamePads->GetInput(); if( (g_pGamePads->pGP1->wButtons & XINPUT_GAMEPAD_START) && (g_pGamePads->pGP1->wButtons & XINPUT_GAMEPAD_BACK) ) ReBoot(); if(g_pGamePads->pGP1->wButtons & XINPUT_GAMEPAD_DPAD_DOWN) { if(screenshot == 0) { screenshot = 1; CaptureScreen(g_pD3DDevice, "D:\\screen.bmp"); } } if(g_pWorld->pPlayer[0]->Dead != 0 && g_pWorld->pPlayer[1]->Dead != 0) { WinnerColor = D3DCOLOR_XRGB(150, 0, 0); g_pWorld->pPlayer[0]->Dead = 0; g_pWorld->pPlayer[0]->TransX = 2.5f; g_pWorld->pPlayer[0]->TransY = 5.0f; g_pWorld->pPlayer[0]->Theta = 3.1415f/2.0f; g_pWorld->pPlayer[0]->Phi = 3.1415f/2.0f; g_pWorld->pPlayer[0]->Firing = 0; g_pWorld->pPlayer[1]->Dead = 0; g_pWorld->pPlayer[1]->TransX = 2.5f; g_pWorld->pPlayer[1]->TransY = 80.0f - 5.0f; g_pWorld->pPlayer[1]->Theta = -3.1415f/2.0f; g_pWorld->pPlayer[1]->Phi = 3.1415f/2.0f; g_pWorld->pPlayer[1]->Firing = 0; g_pWorld->pPlayer[2]->Dead = 0; g_pWorld->pPlayer[2]->TransX = 180.0f - 2.5f; g_pWorld->pPlayer[2]->TransY = 5.0f; g_pWorld->pPlayer[2]->Theta = 3.1415f/2.0f; g_pWorld->pPlayer[2]->Phi = 3.1415f/2.0f; g_pWorld->pPlayer[2]->Firing = 0; g_pWorld->pPlayer[3]->Dead = 0; g_pWorld->pPlayer[3]->TransX = 180.0f - 2.5f; g_pWorld->pPlayer[3]->TransY = 80.0f - 5.0f; g_pWorld->pPlayer[3]->Theta = -3.1415f/2.0f; g_pWorld->pPlayer[3]->Phi = 3.1415f/2.0f; g_pWorld->pPlayer[3]->Firing = 0; g_pWorld->bfirstblood = 0; g_pWorld->redwins->Play(0); (g_pWorld->CurrLevel)++; if(g_pWorld->CurrLevel == 5) g_pWorld->CurrLevel = 0; (g_pWorld->Boards) = &((g_pWorld->BoardsAll)[g_pWorld->CurrLevel][0]); for(int i=0; i<150; i++) { g_pWorld->Balls[i].State = 0; } g_pWorld->wait = 800; } if(g_pWorld->pPlayer[2]->Dead != 0 && g_pWorld->pPlayer[3]->Dead != 0) { WinnerColor = D3DCOLOR_XRGB(0, 0, 150); g_pWorld->pPlayer[0]->Dead = 0; g_pWorld->pPlayer[0]->TransX = 2.5f; g_pWorld->pPlayer[0]->TransY = 5.0f; g_pWorld->pPlayer[0]->Theta = 3.1415f/2.0f; g_pWorld->pPlayer[0]->Phi = 3.1415f/2.0f; g_pWorld->pPlayer[0]->Firing = 0; g_pWorld->pPlayer[1]->Dead = 0; g_pWorld->pPlayer[1]->TransX = 2.5f; g_pWorld->pPlayer[1]->TransY = 80.0f - 5.0f; g_pWorld->pPlayer[1]->Theta = -3.1415f/2.0f; g_pWorld->pPlayer[1]->Phi = 3.1415f/2.0f; g_pWorld->pPlayer[1]->Firing = 0; g_pWorld->pPlayer[2]->Dead = 0; g_pWorld->pPlayer[2]->TransX = 180.0f - 2.5f; g_pWorld->pPlayer[2]->TransY = 5.0f; g_pWorld->pPlayer[2]->Theta = 3.1415f/2.0f; g_pWorld->pPlayer[2]->Phi = 3.1415f/2.0f; g_pWorld->pPlayer[2]->Firing = 0; g_pWorld->pPlayer[3]->Dead = 0; g_pWorld->pPlayer[3]->TransX = 180.0f - 2.5f; g_pWorld->pPlayer[3]->TransY = 80.0f - 5.0f; g_pWorld->pPlayer[3]->Theta = -3.1415f/2.0f; g_pWorld->pPlayer[3]->Phi = 3.1415f/2.0f; g_pWorld->pPlayer[3]->Firing = 0; g_pWorld->bfirstblood = 0; g_pWorld->bluewins->Play(0); (g_pWorld->CurrLevel)++; if(g_pWorld->CurrLevel == 5) g_pWorld->CurrLevel = 0; (g_pWorld->Boards) = &((g_pWorld->BoardsAll)[g_pWorld->CurrLevel][0]); for(int i=0; i<150; i++) { g_pWorld->Balls[i].State = 0; } g_pWorld->wait = 800; } g_pD3DDevice->SetViewport(&viewport); g_pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, WinnerColor, 0.0f, 0); g_pD3DDevice->BeginScene(); g_pWorld->UpdateWorld(); g_pD3DDevice->EndScene(); g_pD3DDevice->Present(NULL, NULL, NULL, NULL); } }