void NzMusic::Play() { #if NAZARA_AUDIO_SAFE if (!m_impl) { NazaraError("Music not created"); return; } #endif if (m_impl->streaming) { if (GetStatus() != nzSoundStatus_Playing) alSourcePlay(m_source); return; } m_impl->stream->Seek(0); m_impl->streaming = true; m_impl->thread = NzThread(&NzMusic::MusicThread, this); return; }
bool NzWindowImpl::Create(const NzVideoMode& mode, const NzString& title, nzUInt32 style) { bool fullscreen = (style & nzWindowStyle_Fullscreen) != 0; DWORD win32Style, win32StyleEx; unsigned int x, y; unsigned int width = mode.width; unsigned int height = mode.height; if (fullscreen) { DEVMODE win32Mode; std::memset(&win32Mode, 0, sizeof(DEVMODE)); win32Mode.dmBitsPerPel = mode.bitsPerPixel; win32Mode.dmPelsHeight = mode.height; win32Mode.dmPelsWidth = mode.width; win32Mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; win32Mode.dmSize = sizeof(DEVMODE); if (ChangeDisplaySettings(&win32Mode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) { // Situation extrêmement rare grâce à NzVideoMode::IsValid appelé par NzWindow NazaraError("Failed to change display settings for fullscreen, this video mode is not supported by your computer"); fullscreen = false; } } // Testé une seconde fois car sa valeur peut changer if (fullscreen) { x = 0; y = 0; win32Style = WS_CLIPCHILDREN | WS_POPUP; // Pour cacher la barre des tâches // http://msdn.microsoft.com/en-us/library/windows/desktop/ff700543(v=vs.85).aspx win32StyleEx = WS_EX_APPWINDOW; fullscreenWindow = this; } else { win32Style = WS_VISIBLE; if (style & nzWindowStyle_Titlebar) { win32Style |= WS_CAPTION | WS_MINIMIZEBOX; if (style & nzWindowStyle_Closable) win32Style |= WS_SYSMENU; if (style & nzWindowStyle_Resizable) win32Style |= WS_MAXIMIZEBOX | WS_SIZEBOX; } else win32Style |= WS_POPUP; win32StyleEx = 0; RECT rect = {0, 0, static_cast<LONG>(width), static_cast<LONG>(height)}; AdjustWindowRect(&rect, win32Style, false); width = rect.right-rect.left; height = rect.bottom-rect.top; x = (GetSystemMetrics(SM_CXSCREEN) - width)/2; y = (GetSystemMetrics(SM_CYSCREEN) - height)/2; } m_callback = 0; #if NAZARA_UTILITY_THREADED_WINDOW NzMutex mutex; NzConditionVariable condition; m_threadActive = true; // On attend que la fenêtre soit créée mutex.Lock(); m_thread = NzThread(WindowThread, &m_handle, win32StyleEx, title.GetWideString().data(), win32Style, x, y, width, height, this, &mutex, &condition); condition.Wait(&mutex); mutex.Unlock(); #else m_handle = CreateWindowExW(win32StyleEx, className, title.GetWideString().data(), win32Style, x, y, width, height, nullptr, nullptr, GetModuleHandle(nullptr), this); #endif if (!m_handle) { NazaraError("Failed to create window: " + NzError::GetLastSystemError()); return false; } if (fullscreen) { SetForegroundWindow(m_handle); ShowWindow(m_handle, SW_SHOW); } m_eventListener = true; m_ownsWindow = true; #if !NAZARA_UTILITY_THREADED_WINDOW m_sizemove = false; #endif m_style = style; // Récupération de la position/taille de la fenêtre (Après sa création) RECT clientRect, windowRect; GetClientRect(m_handle, &clientRect); GetWindowRect(m_handle, &windowRect); m_position.Set(windowRect.left, windowRect.top); m_size.Set(clientRect.right - clientRect.left, clientRect.bottom - clientRect.top); return true; }