Seemed promising but no, it still flickers. Here's my win main section:
WorldManager world;HDC hdc;HDC buffer;HBITMAP bitmap;const int AI_UPDATE_ID = 1;const int AI_TICK = 32;int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, int nShowCmd){ HWND hwnd; WNDCLASS winclass; hinstGLOBAL = hInstance; MSG msg; winclass.style = CS_VREDRAW | CS_HREDRAW; winclass.lpfnWndProc = WndProc; winclass.cbClsExtra = 0; winclass.cbWndExtra = 0; winclass.hInstance = hInstance; winclass.hCursor = LoadCursor(NULL, IDC_ARROW); winclass.hIcon = NULL; winclass.hbrBackground = NULL; winclass.lpszMenuName = NULL; winclass.lpszClassName = PROGNAME; if(!RegisterClass(&winclass)) { MessageBox(NULL, L"Unable to register class on startup", PROGNAME, MB_ICONERROR); return 0; }hwnd = CreateWindow(PROGNAME, L"AI Framework", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CLIENT_X_SZ, CLIENT_Y_SZ, NULL, NULL, hInstance, NULL);ShowWindow(hwnd, nShowCmd);UpdateWindow(hwnd);ZeroMemory(&msg, sizeof(msg));hdc = GetDC(hwnd);buffer = CreateCompatibleDC(hdc); bitmap = CreateCompatibleBitmap(hdc,CLIENT_X_SZ,CLIENT_Y_SZ);while(msg.message != WM_QUIT){ if(PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else { SelectObject(buffer, bitmap); world.render(buffer); BitBlt(hdc, 0, 0, CLIENT_X_SZ,CLIENT_Y_SZ, buffer, 0, 0, SRCCOPY); }}}LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){ PAINTSTRUCT ps; HDC hdc; switch(message) { case WM_CREATE: for(int i = 0; i < 100 ; ++i) world.CreateMovingEntity(rand() % CLIENT_X_SZ, rand() % CLIENT_Y_SZ, 1000, 0.2, 10, VICSEK); SetTimer(hwnd, AI_UPDATE_ID, AI_TICK, NULL); return 0; case WM_TIMER: // TO DO move this to use a better timer call world.update(16); return 0; case WM_PAINT: hdc = BeginPaint(hwnd,&ps); EndPaint(hwnd, &ps); return 0; case WM_KEYDOWN: switch(wParam) { case VK_LEFT: world.resize(100); return 0; case VK_RIGHT: for(int i = 0; i < 100 ; ++i) world.CreateMovingEntity(rand() % CLIENT_X_SZ, rand() % CLIENT_Y_SZ, 1000, 0.2, 10, VICSEK); return 0; return 0; } case WM_SIZE: CLIENT_X_SZ = LOWORD(lParam); CLIENT_Y_SZ =HIWORD(lParam); hdc = GetDC(hwnd); if(bitmap) DeleteObject(bitmap); buffer = CreateCompatibleDC(hdc); bitmap = CreateCompatibleBitmap(hdc,CLIENT_X_SZ,CLIENT_Y_SZ); SelectObject(buffer, bitmap); return 0; case WM_DESTROY: DeleteDC(buffer); DeleteObject(bitmap); PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, message, wParam, lParam);}