123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- #pragma once
- #ifndef __SpoutSDK__
- #define __SpoutSDK__
- #include <windows.h>
- #include <set>
- #include <string>
- #include <iostream>
- #include <fstream>
- #include <Mmsystem.h>
- #include <direct.h>
- #include <shlwapi.h>
- #include "Shellapi.h"
- #pragma comment(lib, "shlwapi.lib")
- #pragma comment(lib, "Shell32.lib")
- #pragma comment(lib, "Advapi32.lib")
- #pragma comment(lib, "Version.lib")
- #include "SpoutCommon.h"
- #include "spoutMemoryShare.h"
- #include "SpoutSenderNames.h"
- #include "spoutGLDXinterop.h"
- #if defined(__x86_64__) || defined(_M_X64)
- #define is64bit
- #endif
- class SPOUT_DLLEXP Spout {
- public:
- Spout();
- ~Spout();
-
-
-
-
- bool CreateSender (const char *Sendername, unsigned int width, unsigned int height, DWORD dwFormat = 0);
- bool UpdateSender (const char* Sendername, unsigned int width, unsigned int height);
- void ReleaseSender (DWORD dwMsec = 0);
- bool SendTexture (GLuint TextureID, GLuint TextureTarget, unsigned int width, unsigned int height, bool bInvert=true, GLuint HostFBO=0);
- bool SendImage (unsigned char* pixels, unsigned int width, unsigned int height, GLenum glFormat = GL_RGBA, bool bAlignment = true, bool bInvert=false);
-
- bool CreateReceiver (char* Sendername, unsigned int &width, unsigned int &height, bool bUseActive = false);
- void ReleaseReceiver();
- bool ReceiveTexture (char* Sendername, unsigned int &width, unsigned int &height, GLuint TextureID = 0, GLuint TextureTarget = 0, bool bInvert = false, GLuint HostFBO=0);
- bool ReceiveImage (char* Sendername, unsigned int &width, unsigned int &height, unsigned char* pixels, GLenum glFormat = GL_RGBA, GLuint HostFBO=0);
- bool CheckReceiver (char* Sendername, unsigned int &width, unsigned int &height, bool &bConnected);
- bool GetImageSize (char* sendername, unsigned int &width, unsigned int &height, bool &bMemoryMode);
- bool BindSharedTexture();
- bool UnBindSharedTexture();
-
- bool DrawSharedTexture(float max_x = 1.0, float max_y = 1.0, float aspect = 1.0, bool bInvert = true);
- bool DrawToSharedTexture(GLuint TextureID, GLuint TextureTarget, unsigned int width, unsigned int height, float max_x = 1.0, float max_y = 1.0, float aspect = 1.0, bool bInvert = false, GLuint HostFBO = 0);
- int GetSenderCount ();
- bool GetSenderName (int index, char* sendername, int MaxSize = 256);
- bool GetSenderInfo (const char* sendername, unsigned int &width, unsigned int &height, HANDLE &dxShareHandle, DWORD &dwFormat);
- bool GetActiveSender(char* Sendername);
- bool SetActiveSender(const char* Sendername);
-
-
- bool SetDX9(bool bDX9 = true);
- bool GetDX9();
- bool SetMemoryShareMode(bool bMem = true);
- bool GetMemoryShareMode();
- int GetMaxSenders();
- void SetMaxSenders(int maxSenders);
- int GetNumAdapters();
- bool GetAdapterName(int index, char *adaptername, int maxchars);
- bool SetAdapter(int index = 0);
- int GetAdapter();
- bool GetHostPath(const char *sendername, char *hostpath, int maxchars);
- int GetVerticalSync();
- bool SetVerticalSync(bool bSync = true);
- bool SelectSenderPanel(const char* message = NULL);
- bool CheckSpoutPanel();
- bool OpenSpout();
-
-
- bool WritePathToRegistry (const char *filepath, const char *subkey, const char *valuename);
- bool ReadPathFromRegistry(char *filepath, const char *subkey, const char *valuename);
- bool RemovePathFromRegistry(const char *subkey, const char *valuename);
-
- spoutGLDXinterop interop;
-
- void UseAccessLocks(bool bUseLocks);
- void SpoutCleanUp(bool bExit = false);
- void CleanSenders();
- protected :
-
-
-
- char g_SharedMemoryName[256];
- char UserSenderName[256];
- unsigned int g_Width;
- unsigned int g_Height;
- HANDLE g_ShareHandle;
- DWORD g_Format;
- GLuint g_TexID;
- HWND g_hWnd;
- bool bMemory;
- bool bGLDXcompatible;
- bool bMemoryShareInitOK;
- bool bDxInitOK;
- bool bInitialized;
- bool bIsSending;
- bool bIsReceiving;
- bool bChangeRequested;
- bool bSpoutPanelOpened;
- bool bSpoutPanelActive;
- bool bUseActive;
- SHELLEXECUTEINFOA ShExecInfo;
- bool GLDXcompatible();
- bool OpenReceiver (char *name, unsigned int& width, unsigned int& height);
- bool InitReceiver (HWND hwnd, char* sendername, unsigned int width, unsigned int height, bool bMemoryMode);
- bool InitSender (HWND hwnd, const char* sendername, unsigned int width, unsigned int height, DWORD dwFormat, bool bMemoryMode);
-
- bool InitMemoryShare(bool bReceiver);
- bool ReleaseMemoryShare();
- bool FlipVertical(unsigned char *src, unsigned int width, unsigned int height, GLenum glFormat = GL_RGB);
-
- double timeNow, timeThen, elapsedTime, frameTime, lastFrameTime, frameRate, fps, PCFreq, waitMillis, millisForFrame;
- __int64 CounterStart;
-
- bool FindFileVersion(const char *filepath, DWORD &versMS, DWORD &versLS);
-
- void StartCounter();
- double GetCounter();
- };
- #endif
|