{"id":21070821,"url":"https://github.com/fafalone/directcomposition","last_synced_at":"2026-01-02T03:46:27.662Z","repository":{"id":189425505,"uuid":"680627626","full_name":"fafalone/DirectComposition","owner":"fafalone","description":"twinBASIC DirectComposition Demos","archived":false,"fork":false,"pushed_at":"2024-03-03T22:01:46.000Z","size":5402,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-20T21:56:50.141Z","etag":null,"topics":["direct2d","directcomposition","directx","twinbasic","vb6"],"latest_commit_sha":null,"homepage":"","language":"Visual Basic 6.0","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fafalone.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-08-19T21:25:54.000Z","updated_at":"2023-12-31T18:40:46.000Z","dependencies_parsed_at":"2024-03-03T23:20:51.584Z","dependency_job_id":"8313dd7c-defc-4355-84ae-88bd42df9833","html_url":"https://github.com/fafalone/DirectComposition","commit_stats":null,"previous_names":["fafalone/directcomposition"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fafalone%2FDirectComposition","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fafalone%2FDirectComposition/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fafalone%2FDirectComposition/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fafalone%2FDirectComposition/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fafalone","download_url":"https://codeload.github.com/fafalone/DirectComposition/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243513858,"owners_count":20303022,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["direct2d","directcomposition","directx","twinbasic","vb6"],"created_at":"2024-11-19T18:48:29.272Z","updated_at":"2026-01-02T03:46:27.657Z","avatar_url":"https://github.com/fafalone.png","language":"Visual Basic 6.0","readme":"# twinBASIC DirectComposition Demos\n\nThis repository is to show off some basic demos of using DirectComposition/Direct2D in twinBASIC. \n\n**Update (14 Nov 2025):** Project has been updated to use a more recent version of WinDevLib since newer ones changed how overloaded interface methods work. Also fixed bug that `Sub Main` startup option didn't work (since it missed initialiing the CS),\n\n**Update (03 Mar 2024):** .twinproj has been updated to use a more recent version of WinDevLib (formerly tbShellLib) due to errors in the package tB did not raise at the time this project was released.\n\n**Update (19 Dec 2023):** .twinproj updated to reference WinDevLib (formerly tbShellLib) 7.0-- this eliminates package errors that tB did not raise at the time this project was initially released.\n\n### Requirements\n-DirectX 11, which is a pre-installed standard on Windows 7 and newer.\n\n-A relatively recent build of [twinBASIC](https://github.com/twinbasic/twinbasic) to build from source.\n\n-If you create a new project based on this code, you'll need to add the tbShellLib package, version 5.0.203 or higher, which contains all the APIs and interfaces. It's available on the package server in the 'twinpack Packages'  list in your project settings -\u003e COM Type Library / ActiveX References; [illustration here](https://github.com/fafalone/tbShellLib/issues/9). It's has already been added to the demo, so no action is neccessary for that, only for new projects.\n\n## DirectComposition Effects Demo\nThe first demo is a just a basic proof of concept, a close-as-possible port of the [Microsoft DirectComposition Effects SDK example](https://github.com/microsoft/Windows-classic-samples/tree/main/Samples/DirectCompositionEffects). The app is provisioned for having more than one demo by running the Effects Sample in it's own thread, which a log sync'd back to the Launch Form inside a critical section.\n\n![Screenshot](https://i.imgur.com/xr6jyOL.gif)\n\nSince the demo is ported as close as possible, you'll find something additional of interest in this project: Instead of using a Form, it creates it's own window from scratch using API and handles the entire message pump (error handlers omitted):\n\n```vb6\n    Private Function CreateApplicationWindow() As Long\n\n        Dim hr As Long = S_OK\n    \n        Dim wcex As WNDCLASSEX\n    \n        wcex.cbSize = LenB(wcex)\n        wcex.style = CS_HREDRAW Or CS_VREDRAW\n        wcex.lpfnWndProc = AddressOf WindowProc\n        wcex.cbClsExtra = 0\n        wcex.cbWndExtra = 0\n        wcex.hInstance = App.hInstance\n        wcex.hIcon = 0\n        wcex.hCursor = LoadCursor(0, IDC_ARROW)\n        wcex.hbrBackground = GetStockObject(WHITE_BRUSH)\n        wcex.lpszMenuName = 0\n        wcex.lpszClassName = StrPtr(wndClass)\n        wcex.hIconSm = 0\n    \n        hr = IIf(RegisterClassEx(wcex), S_OK, E_FAIL)\n\n        If SUCCEEDED(hr) Then\n            PostLog \"RegisterClassEx succeeded\"\n            Dim RECT As RECT\n            RECT.Right = windowWidth: RECT.Bottom = windowHeight\n            AdjustWindowRect RECT, WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_MINIMIZEBOX, 0\n        \n            m_hWnd = CreateWindowExW(0, StrPtr(wndClass), StrPtr(wndName), _\n                                WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_MINIMIZEBOX, _\n                                CW_USEDEFAULT, CW_USEDEFAULT, RECT.Right - RECT.Left, RECT.Bottom - RECT.Top, _\n                                0, 0, App.hInstance, ByVal 0)\n        End If\n```\n\n```vb6\n    Private Function EnterMessageLoop() As Long\n        Dim result As Long\n    \n        If ShowApplicationWindow() Then\n            Dim tMSG As MSG\n            Dim hr As Long\n            PostLog \"Entering message loop\"\n            hr = GetMessage(tMSG, 0, 0, 0)\n            Do While hr \u003c\u003e 0\n                If hr = -1 Then\n                    PostLog \"Error: 0x\" \u0026 Hex$(Err.LastDllError)\n                Else\n                    TranslateMessage tMSG\n                    DispatchMessage tMSG\n                End If\n                hr = GetMessage(tMSG, 0, 0, 0)\n            Loop\n            PostLog \"Exited message loop\"\n            result = CLng(tMSG.wParam)\n        End If\n        \n        EnterMessageLoop = result\n    End Function\n```\n\nAfter that, we get into all the DirectComposition/Direct2D code, which is too complex to go into much detail here; but the basic steps are to start with the `D3D11CreateDevice` and `D2D1CreateFactory` APIs to create the root DirectX objects, get a DXGI interface from the former, then use the `DCompositionCreateDevice` to create the rendering object. After that, we create surfaces, make those into DirectComposition visuals, and apply various transform effects and animations. \n\nI recommend following the code starting from `BeforeEnteringMessageLoop` to see all the object creation, then following from OnKeyDown and OnLeftButton to see how it responds to the two actions.\n\nStay tuned for more demos!\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffafalone%2Fdirectcomposition","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffafalone%2Fdirectcomposition","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffafalone%2Fdirectcomposition/lists"}