Skip to content

Commit

Permalink
SetMirror/SetSwap
Browse files Browse the repository at this point in the history
25.05.24
Use SetMirror/SetSwap/GetMirror/GetSwap
instead of using globals directly'
  • Loading branch information
leadedge committed May 25, 2024
1 parent 78c85d8 commit da5914d
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 28 deletions.
57 changes: 41 additions & 16 deletions SpoutDX/source/SpoutDX.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//
//
// SpoutDX
//
// Sender and receiver for DirectX applications
Expand Down Expand Up @@ -153,6 +152,8 @@
// 22.05.24 CheckSpoutPanel - Register sender only if not already registered
// 23.05.24 - ReadPixelData/ReadTexurePixels - use global m_bSwapRB flag instead of false
// ReadPixelData - RGBA and BGRA texture data to BGR pixels default, RGB for swap
// 25.05.24 - SetSenderName - remove name increment
// Add SetMirror/SetSwap/GetMirror/GetSwap for SpoutCam instead of using globals directly
//
// ====================================================================================
/*
Expand Down Expand Up @@ -381,21 +382,6 @@ bool spoutDX::SetSenderName(const char* sendername)
strcpy_s(m_SenderName, 256, sendername);
}

// If a sender with this name is already registered,
// create an incremented name, because this function
// precedes SpoutSenderNames::RegisterSenderName
char name[256]{};
strcpy_s(name, 256, m_SenderName);
if (sendernames.FindSenderName(name)) {
int i = 1;
do {
sprintf_s(name, 256, "%s_%d", m_SenderName, i);
i++;
} while (sendernames.FindSenderName(name));
// Re-set the global sender name
strcpy_s(m_SenderName, 256, name);
}

// Remove the sender from the names list if it's
// shared memory information does not exist.
// This can happen if the sender has crashed or if a
Expand Down Expand Up @@ -1873,6 +1859,43 @@ int spoutDX::GetMemoryBufferSize(const char *name)

}

//
// Options used for SpoutCam
//

//---------------------------------------------------------
// Function: SetMirror
// Set mirror image option
void spoutDX::SetMirror(bool bMirror)
{
m_bMirror = bMirror;
}

//---------------------------------------------------------
// Function: SetSwap
// Set swap red/blue option : RGB <> BGR
void spoutDX::SetSwap(bool bSwap)
{
m_bSwapRB = bSwap;
}

//---------------------------------------------------------
// Function: GetMirror
// Return mirror option
bool spoutDX::GetMirror()
{
return m_bMirror;
}

//---------------------------------------------------------
// Function: GetSwap
// Return swap option
bool spoutDX::GetSwap()
{
return m_bSwapRB;
}


//
// Sharing modes
//
Expand Down Expand Up @@ -2076,6 +2099,8 @@ bool spoutDX::CheckSender(unsigned int width, unsigned int height, DWORD dwForma

// Create a sender using the DX11 shared texture handle (m_dxShareHandle)
// and specifying the same texture format.
// If the sender already exists, the name is incremented
// name, name_1, name_2 etc
if (sendernames.CreateSender(m_SenderName, m_Width, m_Height, m_dxShareHandle, m_dwFormat)) {

// sendernames::SetSenderInfo writes the sender information to shared memory
Expand Down
27 changes: 17 additions & 10 deletions SpoutDX/source/SpoutDX.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/*
SpoutDX.h
Sender and receiver for DirectX applications
Expand Down Expand Up @@ -292,6 +291,20 @@ class SPOUT_DLLEXP spoutDX {
// Get the number of bytes available for data transfer
int GetMemoryBufferSize(const char *name);

//
// Options used for SpoutCam
//

// Mirror image
void SetMirror(bool bMirror = true);

// RGB <> BGR
void SetSwap(bool bSwap = true);

bool GetMirror();

bool GetSwap();

//
// Public for external access
//
Expand All @@ -301,15 +314,6 @@ class SPOUT_DLLEXP spoutDX {
spoutDirectX spoutdx;
spoutCopy spoutcopy;

//
// Options used for SpoutCam
//

// Mirror image
bool m_bMirror;
// RGB <> BGR
bool m_bSwapRB;

protected :

ID3D11Device* m_pd3dDevice;
Expand All @@ -335,8 +339,11 @@ protected :
bool m_bClassDevice;
bool m_bAdapt;
bool m_bMemoryShare; // Using 2.006 memoryshare methods
bool m_bMirror; // Mirror image
bool m_bSwapRB; // RGB <> BGR
SHELLEXECUTEINFOA m_ShExecInfo; // For ShellExecute


// For WriteMemoryBuffer/ReadMemoryBuffer
SpoutSharedMemory memorybuffer;

Expand Down
Binary file modified binaries/SPOUTCAM/SpoutCam32/SpoutCam32.ax
Binary file not shown.
Binary file modified binaries/SPOUTCAM/SpoutCam64/SpoutCam64.ax
Binary file not shown.
5 changes: 3 additions & 2 deletions source/cam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@
09.01.24 SpoutDX::ReadPixelData wait for command completion using FlushWait
23.05.24 SpoutDX::ReadPixelData - RGBA and BGRA texture data to BGR pixels default, RGB for swap
24.04.24 Rebuild x86/x64 VS2022/MT for release
25.05.24 Use SpoutDX SetMirror and SetSwap instead of globals directly
Version 2.032
*/
Expand Down Expand Up @@ -552,8 +553,8 @@ HRESULT CVCamStream::put_Settings(DWORD dwFps, DWORD dwResolution, DWORD dwMirro
receiver.SetReceiverName(name);

// Mirror and swap
receiver.m_bMirror = (dwMirror > 0);
receiver.m_bSwapRB = (dwSwap > 0);
receiver.SetMirror(dwMirror > 0);
receiver.SetSwap(dwSwap > 0);

// Flip is true by default - so false will appear inverted
bInvert = !(dwFlip > 0);
Expand Down

0 comments on commit da5914d

Please sign in to comment.