When you are so good at making bad code that you are bad at making good code but it still werks.
However, thoseC++:static inline void video_thread(video_t ind, wid_t wid) { // MPEG-2 vidoe codec + MP2 audio codec + *.MPG = werk! HRESULT hr = S_OK; CoInitialize(NULL); HWND vidwin = NULL; RECT rect; long evCode; widmap.insert(std::make_pair(ind, wid)); HWND window = (HWND)stoull(wid, nullptr, 10); wstring wstr_fname = widen(vidmap.find(ind)->second); hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph); if (SUCCEEDED(hr)) { hr = pGraph->RenderFile(wstr_fname.c_str(), NULL); if (SUCCEEDED(hr)) { hr = CoCreateInstance(CLSID_VideoMixingRenderer, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&pVideoRenderer); if (SUCCEEDED(hr)) { hr = pGraph->FindFilterByName(L"Video Renderer", &pVideoRenderer); if (SUCCEEDED(hr)) { hr = pVideoRenderer->QueryInterface(IID_IVMRAspectRatioControl, (void **)&pAspectRatio); if (SUCCEEDED(hr)) { hr = pAspectRatio->SetAspectRatioMode(VMR_ARMODE_LETTER_BOX); if (SUCCEEDED(hr)) { hr = pGraph->QueryInterface(IID_IVideoWindow, (void **)&pVidWin); if (SUCCEEDED(hr)) { SetWindowLongPtr(window, GWL_STYLE, GetWindowLongPtr(window, GWL_STYLE) | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); hr = pVidWin->put_Owner((OAHWND)window); if (SUCCEEDED(hr)) { GetClientRect(window, &rect); hr = pVidWin->SetWindowPosition(0, 0, rect.right - rect.left, rect.bottom - rect.top); if (SUCCEEDED(hr)) { hr = pVidWin->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS); if (SUCCEEDED(hr)) { hr = pVidWin->SetWindowForeground(OATRUE); if (SUCCEEDED(hr)) { hr = pVidWin->HideCursor(OATRUE); if (SUCCEEDED(hr)) { hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl); if (SUCCEEDED(hr)) { hr = pVideoRenderer->FindPin(L"VMR Input0", &pin); if (SUCCEEDED(hr)) { hr = pin->QueryInterface(IID_IOverlay, (void **)&pOverlay); if (SUCCEEDED(hr)) { hr = pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent); if (SUCCEEDED(hr)) { hr = pOverlay->GetWindowHandle(&vidwin); if (SUCCEEDED(hr)) { std::lock_guard<std::mutex> guard1(window_mutex); cwidmap.insert(std::make_pair(ind, std::to_string((unsigned long long)vidwin))); std::thread finthread(update_thread, ind); hr = pControl->Run(); if (SUCCEEDED(hr)) { while (ShowCursor(false) >= 0); hr = pEvent->WaitForCompletion(INFINITE, &evCode); if (SUCCEEDED(hr)) { hr = pControl->Stop(); if (SUCCEEDED(hr)) { hr = pVidWin->put_Visible(OAFALSE); if (SUCCEEDED(hr)) { pVidWin->put_Owner((OAHWND)NULL); } } } while (ShowCursor(true) < 0); } std::lock_guard<std::mutex> guard2(update_mutex); updmap[ind] = false; finthread.join(); } } } } } } } } } } } } } } } } } if (pEvent != NULL) { pEvent->Release(); } if (pControl != NULL) { pControl->Release(); } if (pVidWin != NULL) { pVidWin->Release(); } if (pAspectRatio != NULL) { pAspectRatio->Release(); } if (pVideoRenderer != NULL) { pVideoRenderer->Release(); } if (pGraph != NULL) { pGraph->Release(); } if (pin != NULL) { pin->Release(); } CoUninitialize(); }
!= NULL
checks at the end are probably redundant as I saw no obvious sign of over-releasing going on before I added them.
Hey now, that's very great, and very exciting. And epic.
#include <string>
int main () {
std::string str = "trolololo";
while (true) { str += "lololo"; }
return 0;
}
g++ trololo.cpp
./a.out
If this was pre-GMS2, it wouldn't even qualify as a meme. This was the only way to do GML
Is it weird that, looking at this picture, I initially saw it as zombies and humans about to high-five, rather than zombies trying to reach for humans while humans backing away in terror?
Incidental evidence of a big programmer blogger guy spending an entire post complaining about how bad Unity's model importer isView attachment 35629
juju has proclaimed
for legal reasons this is an edited meme and a joke I'm not actually comparing the engines pls don't start war
Ignore the italics, it won't let me turn it off.
std::wstring wstr = ...
// string to wstring
wstring widen(string str) {
size_t wchar_count = str.size() + 1;
vector<wchar_t> buf(wchar_count);
return wstring { buf.data(),
(size_t)MultiByteToWideChar(
CP_UTF8, 0, str.c_str(), -1,
buf.data(), (int)wchar_count) };
}
// wstring to string
string narrow(wstring wstr) {
int nbytes = WideCharToMultiByte(CP_UTF8,
0, wstr.c_str(), (int)wstr.length(),
NULL, 0, NULL, NULL);
vector<char> buf(nbytes);
return string { buf.data(),
(size_t)WideCharToMultiByte(
CP_UTF8, 0, wstr.c_str(),
(int)wstr.length(), buf.data(),
nbytes, NULL, NULL) };
}
std::wstring wstr = ...
wstr.c_str()
C++:// string to wstring wstring widen(string str) { size_t wchar_count = str.size() + 1; vector<wchar_t> buf(wchar_count); return wstring { buf.data(), (size_t)MultiByteToWideChar( CP_UTF8, 0, str.c_str(), -1, buf.data(), (int)wchar_count) }; } // wstring to string string narrow(wstring wstr) { int nbytes = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), (int)wstr.length(), NULL, 0, NULL, NULL); vector<char> buf(nbytes); return string { buf.data(), (size_t)WideCharToMultiByte( CP_UTF8, 0, wstr.c_str(), (int)wstr.length(), buf.data(), nbytes, NULL, NULL) }; }
//std::back_inserter
#include <iterator>
std::wstring w;
std::copy(start_string, start_string + strlen(start_string), back_inserter(w));
const WCHAR* wide_string = w.c_str();
Then you lose UTF-8 supportC++://std::back_inserter #include <iterator> std::wstring w; std::copy(start_string, start_string + strlen(start_string), back_inserter(w)); const WCHAR* wide_string = w.c_str();
oh, hmmm. I dont think I need it as I really only need gamemaker to pass a string to the dll that is the file location of the sound to play, which it does then hard crashesThen you lose UTF-8 support
If the user passes a sound file that has non-english characters in the full path, good luck loading the sound file at all.oh, hmmm. I dont think I need it as I really only need gamemaker to pass a string to the dll that is the file location of the sound to play, which it does then hard crashes
nah these are hard coded im not geting any user input for itIf the user passes a sound file that has non-english characters in the full path, good luck loading the sound file at all.