static void DD_Shutdown(VideoOutput *dr) { DDCONTEXT DestroyObjects(dd); DD_ShutdownWindow(dr); }
DynamicObject::~DynamicObject(void) { lmbox_free(data); lmbox_free(timer_script); if (timer_id > 0) { SDL_RemoveTimer(timer_id); } DestroyObjects(); DestroyEventHandlers(); while (properties.size() > 0) { delete properties.back(); properties.pop_back(); } while (methodhandlers.size() > 0) { MethodHandler *handler = methodhandlers.back(); methodhandlers.pop_back(); delete handler; } while (msgqueue.size() > 0) { free(msgqueue.front()); msgqueue.pop(); } pthread_cond_destroy(&msgcond); pthread_mutex_destroy(&msglock); }
Application::~Application(void) { if (m_WireframeRS) { m_WireframeRS->Release(); m_WireframeRS = nullptr; } if (m_SolidRS) { m_SolidRS->Release(); m_SolidRS = nullptr; } DestroyObjects(); if (m_EffectsManager) delete m_EffectsManager; m_EffectsManager = nullptr; if (m_InputLayoutsManager) delete m_InputLayoutsManager; m_InputLayoutsManager = nullptr; }
void EffectScene::AllocateObjects( int _ObjectsCount ) { DestroyObjects(); m_ObjectsCount = _ObjectsCount; m_ppObjects = new Object*[m_ObjectsCount]; for ( int ObjectIndex=0; ObjectIndex < m_ObjectsCount; ObjectIndex++ ) m_ppObjects[ObjectIndex] = NULL; }
//----------------------------------------------------------------------------- // Name: CreateFullScreenDisplay() // Desc: //----------------------------------------------------------------------------- HRESULT CDisplay::CreateFullScreenDisplay( HWND hWnd, DWORD dwWidth, DWORD dwHeight, DWORD dwBPP ) { HRESULT hr; // Cleanup anything from a previous call DestroyObjects(); // DDraw stuff begins here if( FAILED( hr = DirectDrawCreateEx( NULL, (VOID**)&m_pDD, IID_IDirectDraw7, NULL ) ) ) return E_FAIL; // Set cooperative level hr = m_pDD->SetCooperativeLevel( hWnd, DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN ); if( FAILED(hr) ) return E_FAIL; // Set the display mode if( FAILED( m_pDD->SetDisplayMode( dwWidth, dwHeight, dwBPP, 0, 0 ) ) ) return E_FAIL; // Create primary surface (with backbuffer attached) DDSURFACEDESC2 ddsd; ZeroMemory( &ddsd, sizeof( ddsd ) ); ddsd.dwSize = sizeof( ddsd ); ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX | DDSCAPS_3DDEVICE; ddsd.dwBackBufferCount = 1; if( FAILED( hr = m_pDD->CreateSurface( &ddsd, &m_pddsFrontBuffer, NULL ) ) ) return E_FAIL; // Get a pointer to the back buffer DDSCAPS2 ddscaps; ZeroMemory( &ddscaps, sizeof( ddscaps ) ); ddscaps.dwCaps = DDSCAPS_BACKBUFFER; if( FAILED( hr = m_pddsFrontBuffer->GetAttachedSurface( &ddscaps, &m_pddsBackBuffer ) ) ) return E_FAIL; m_pddsBackBuffer->AddRef(); m_hWnd = hWnd; m_bWindowed = FALSE; UpdateBounds(); return S_OK; }
void Application::CreateObject(UINT id) { DestroyObjects(); if ( id == 1) m_ModelObjects.push_back(new Triangle()); else if ( id == 2) m_ModelObjects.push_back(new Pyramid()); else if ( id == 3) m_ModelObjects.push_back(new SierpinskiTriangle(2)); else if ( id == 4) m_ModelObjects.push_back(new SierpinskiPyramid(1)); else if ( id == 5) m_ModelObjects.push_back(new Cylinder(1, 0.5, 1, 4, 2)); else if ( id == 6) m_ModelObjects.push_back(new Geosphere(1,4)); else if ( id == 7) m_ModelObjects.push_back(new Grid(1,1, 50,50)); else if ( id == 8) m_ModelObjects.push_back(new Wave(1,1, 50,50)); else if ( id == 9) m_ModelObjects.push_back(new TestObject("Models/skull.txt")); else if (id == 0) { ModelObject* ground = new Grid(100, 100, 10, 10); ground->SetPosition(0, -1, 0); ground->GetMaterial()->Ambient = DirectX::XMFLOAT4(0.3f, 0.3f, 0.3f, 1.0f); ground->GetMaterial()->Diffuse = DirectX::XMFLOAT4(1.0f, 0.0f, 0.0f, 1.0f); ground->GetMaterial()->Specular = DirectX::XMFLOAT4(0.2f, 0.2f, 0.2f, 100.0f); m_ModelObjects.push_back(ground); ModelObject* skull = new TestObject("Models/skull.txt"); skull->GetMaterial()->Ambient = DirectX::XMFLOAT4(0.f, 0.f, 0.f, 1.0f); skull->GetMaterial()->Diffuse = DirectX::XMFLOAT4(.3f, 0.3f, 0.3f, 1.0f); skull->GetMaterial()->Specular = DirectX::XMFLOAT4(0.2f, 0.2f, 0.2f, 100.0f); m_ModelObjects.push_back(skull); } std::shared_ptr<MeshData> data = std::make_shared<MeshData>(); for each (auto model in m_ModelObjects) { model->Initialize(data); }
IWMProfile* CProfile::GetWMProfile(void) { // Get windows media profile. This function is called // when the stream is to be encoded. If we do not have // the object yet, we create it using the settings we currently // have on the thingy DestroyObjects(); if (m_pIWMProfile == NULL) CreateNew(); else _ASSERT(FALSE); return m_pIWMProfile; }
BOOL CBufferedDC::Create( CDC *pTargetDC_i, const CRect& crTargetDCRect_i ) { DestroyObjects(); // If already created // Assign buffer rect m_crTargetDCRect = crTargetDCRect_i; // Assign target dc m_pTargetDC = pTargetDC_i; if( !IsTargetDCValid() || !CreateCompatibleDC( pTargetDC_i ) || !m_bmpBuffer.CreateCompatibleBitmap( pTargetDC_i, m_crTargetDCRect.Width(), m_crTargetDCRect.Height() ) || !SelectObject( m_bmpBuffer )) { ASSERT( FALSE ); return FALSE; }// End if // Save current mem dc settings m_nRestorePoint = SaveDC(); return TRUE; }// End Create
static M4Err DD_SetFullScreen(VideoOutput *dr, Bool bOn, u32 *outWidth, u32 *outHeight) { M4Err e; char *sOpt; u32 MaxWidth, MaxHeight; DDCONTEXT; if (!dd->width ||!dd->height) return M4BadParam; if (bOn == dd->fullscreen) return M4OK; dd->fullscreen = bOn; /*whenever changing card display mode relocate fastest YUV format for blit (since it depends on the dest pixel format)*/ dd->yuv_init = 0; if (dd->fullscreen) { char *sOpt = PMI_GetOpt(dr, "Video", "SwitchResolution"); if (sOpt && !stricmp(sOpt, "yes")) dd->switch_res = 1; /*get current or best fitting mode*/ if (GetDisplayMode(dd) != M4OK) return M4IOErr; } MaxWidth = MaxHeight = 0; sOpt = PMI_GetOpt(dr, "Video", "MaxResolution"); if (sOpt) sscanf(sOpt, "%dx%d", &MaxWidth, &MaxHeight); dd->is_resizing = 1; if (dd->is_3D_out) { DEVMODE settings; e = M4OK; /*recreate the GL context whenever changing display settings, it's safer...*/ DestroyObjects(dd); /*Setup FS*/ if (dd->fullscreen) { /*change display mode*/ if (dd->switch_res) { /*when switching res weird messages are sent to parent -> store current rect and post a size/pos message on restore */ if (!dd->owns_hwnd) { HWND hWnd = GetParent(dd->hWnd); if (!hWnd) hWnd = dd->hWnd; GetWindowRect(hWnd, &dd->rcWnd); } } if ((MaxWidth && (dd->fs_width >= MaxWidth)) || (MaxHeight && (dd->fs_height >= MaxHeight)) ) { dd->fs_width = MaxWidth; dd->fs_height = MaxHeight; } /*force size change (we do it whether we own or not the window)*/ dd->prev_styles = GetWindowLong(dd->hWnd, GWL_STYLE); GetWindowRect(dd->hWnd, &dd->rcChildWnd); SetWindowLong(dd->hWnd, GWL_STYLE, WS_POPUP); SetWindowPos(dd->hWnd, NULL, 0, 0, dd->fs_width, dd->fs_height, SWP_NOZORDER | SWP_SHOWWINDOW); SetForegroundWindow(dd->hWnd); memset(&settings, 0, sizeof(DEVMODE)); settings.dmSize = sizeof(DEVMODE); settings.dmPelsWidth = dd->fs_width; settings.dmPelsHeight = dd->fs_height; settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT; if ( ChangeDisplaySettings(&settings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL ) { fprintf(stdout, "cannot change display settings...\n"); e = M4IOErr; } dd->NeedRestore = 1; dd->fs_store_width = dd->fs_width; dd->fs_store_height = dd->fs_height; } if (!e) e = DD_SetupOpenGL(dr); } else { e = InitDirectDraw(dr, dd->width, dd->height); } dd->is_resizing = 0; if (bOn) { dd->store_width = *outWidth; dd->store_height = *outHeight; *outWidth = dd->fs_width; *outHeight = dd->fs_height; } else { *outWidth = dd->store_width; *outHeight = dd->store_height; } return e; }
//----------------------------------------------------------------------------- // Name: ~CDisplay() // Desc: //----------------------------------------------------------------------------- CDisplay::~CDisplay() { DestroyObjects(); }
//----------------------------------------------------------------------------- // Name: CreateWindowedDisplay() // Desc: //----------------------------------------------------------------------------- HRESULT CDisplay::CreateWindowedDisplay( HWND hWnd, DWORD dwWidth, DWORD dwHeight ) { HRESULT hr; // Cleanup anything from a previous call DestroyObjects(); // DDraw stuff begins here if( FAILED( hr = DirectDrawCreateEx( NULL, (VOID**)&m_pDD, IID_IDirectDraw7, NULL ) ) ) return E_FAIL; // Set cooperative level hr = m_pDD->SetCooperativeLevel( hWnd, DDSCL_NORMAL ); if( FAILED(hr) ) return E_FAIL; RECT rcWork; RECT rc; DWORD dwStyle; // If we are still a WS_POPUP window we should convert to a normal app // window so we look like a windows app. dwStyle = GetWindowStyle( hWnd ); dwStyle &= ~WS_POPUP; dwStyle |= WS_OVERLAPPED | WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX; SetWindowLong( hWnd, GWL_STYLE, dwStyle ); // Aet window size SetRect( &rc, 0, 0, dwWidth, dwHeight ); AdjustWindowRectEx( &rc, GetWindowStyle(hWnd), GetMenu(hWnd) != NULL, GetWindowExStyle(hWnd) ); SetWindowPos( hWnd, NULL, 0, 0, rc.right-rc.left, rc.bottom-rc.top, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE ); SetWindowPos( hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE ); // Make sure our window does not hang outside of the work area SystemParametersInfo( SPI_GETWORKAREA, 0, &rcWork, 0 ); GetWindowRect( hWnd, &rc ); if( rc.left < rcWork.left ) rc.left = rcWork.left; if( rc.top < rcWork.top ) rc.top = rcWork.top; SetWindowPos( hWnd, NULL, rc.left, rc.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE ); LPDIRECTDRAWCLIPPER pcClipper; // Create the primary surface DDSURFACEDESC2 ddsd; ZeroMemory( &ddsd, sizeof( ddsd ) ); ddsd.dwSize = sizeof( ddsd ); ddsd.dwFlags = DDSD_CAPS; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; if( FAILED( m_pDD->CreateSurface( &ddsd, &m_pddsFrontBuffer, NULL ) ) ) return E_FAIL; // Create the backbuffer surface ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE; ddsd.dwWidth = dwWidth; ddsd.dwHeight = dwHeight; if( FAILED( hr = m_pDD->CreateSurface( &ddsd, &m_pddsBackBuffer, NULL ) ) ) return E_FAIL; if( FAILED( hr = m_pDD->CreateClipper( 0, &pcClipper, NULL ) ) ) return E_FAIL; if( FAILED( hr = pcClipper->SetHWnd( 0, hWnd ) ) ) { pcClipper->Release(); return E_FAIL; } if( FAILED( hr = m_pddsFrontBuffer->SetClipper( pcClipper ) ) ) { pcClipper->Release(); return E_FAIL; } // Done with clipper pcClipper->Release(); m_hWnd = hWnd; m_bWindowed = TRUE; UpdateBounds(); return S_OK; }
plDXTextFont::~plDXTextFont() { DestroyObjects(); }
EffectScene::~EffectScene() { DestroyLights(); DestroyObjects(); delete m_pMaterials; }