• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

GameMaker/Game Dev Memes

zbox

Member
GMC Elder
When you are so good at making bad code that you are bad at making good code but it still werks.
C++:
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();
}
However, those != NULL checks at the end are probably redundant as I saw no obvious sign of over-releasing going on before I added them.

This is me while using callbacks in JS before I learnt about Promises haha.

If it works it works though - bury it and hope you never have to maintain it!
 

Samuel Venable

Time Killer
stackoverflow answers be like...

trololo.cpp:
C++:
#include <string>

int main () {
  std::string str = "trolololo";
  while (true) { str += "lololo"; }
  return 0;
}
compile with:
Code:
g++ trololo.cpp
run with:
Code:
./a.out
Bonus points to whoever gets the punchline.
 
Last edited:

Yal

🐧 *penguin noises*
GMC Elder
View 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
Incidental evidence of a big programmer blogger guy spending an entire post complaining about how bad Unity's model importer is 🦈

(Also according to the forum rules we're legally obliged to only let posts that compare engines in favor of GM remain, so it's not going to be a war as much as it'd be a firing squad)
 
Top