Skip to content

Add reliable back-buffer movie capture - #188

Open
caseychaos1212 wants to merge 1 commit into
w3dhub:mainfrom
caseychaos1212:pr-w3dview-movie-capture
Open

Add reliable back-buffer movie capture#188
caseychaos1212 wants to merge 1 commit into
w3dhub:mainfrom
caseychaos1212:pr-w3dview-movie-capture

Conversation

@caseychaos1212

Copy link
Copy Markdown
Collaborator

Summary

This PR adds a reliable, explicitly driven back-buffer movie-capture path for tools such as the Qt W3D Viewer.

The new API captures rendered Direct3D back-buffer frames into AVI output while reporting initialization and frame-capture failures to the caller.

Changes

  • Add WW3D::Try_Start_Movie_Capture_From_Back_Buffer().
  • Add WW3D::Try_Update_Movie_Capture_From_Back_Buffer().
  • Track whether capture is using the legacy front buffer or the new back buffer.
  • Prevent back-buffer capture from also being advanced automatically by Begin_Render().
  • Copy back-buffer data through a lockable system-memory staging surface.
  • Convert pitched BGRA32 input into bottom-up, DWORD-aligned BGR24 AVI frames.
  • Validate filenames, dimensions, frame rates, formats, strides, and allocation sizes.
  • Stop capture and release resources cleanly when conversion, locking, or AVI writing fails.
  • Harden the existing front-buffer capture path with the same conversion and failure handling.
  • Preserve numbered AVI filename generation.

Compatibility

The existing movie-capture and FrameGrabClass entry points remain available. The new methods provide an isolated, Boolean-returning API for callers that need explicit back-buffer capture.

Back-buffer capture remains Windows-specific and rejects unsupported or multisampled surface formats.

Testing

New tests cover:

  • AVI row-stride calculation and overflow handling.
  • Pitched BGRA32-to-BGR24 conversion.
  • Vertical row flipping and AVI row padding.
  • Source and destination boundary protection.
  • Invalid pointers, dimensions, pitches, and strides.
  • Invalid or oversized FrameGrabClass construction.
  • Existing and new API signatures.

MSVC x64 builds passed with both frame-grab and screenshot tests passing. Strict MSVC x86 /W4 /WX builds also passed with 2/2 tests passing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant