Stellarium  0.90.0
SpoutLibrary.h
1 /*
2 SpoutSDK is released under the Simplified BSD licence.
3 
4 Copyright (C) 2014-2016. Lynn Jarvis. All rights reserved.
5 
6 Redistribution and use in source and binary forms, with or without modification,
7 are permitted provided that the following conditions are met:
8 
9 1. Redistributions of source code must retain the above copyright notice,
10  this list of conditions and the following disclaimer.
11 
12 2. Redistributions in binary form must reproduce the above copyright notice,
13  this list of conditions and the following disclaimer in the documentation
14  and/or other materials provided with the distribution.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
17 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 
27 //
28 // SpoutLibrary.dll
29 //
30 // Spout SDK dll compatible with any C++ compiler
31 //
32 
33 
34 // Note from FS: We need this because the Spout source is compilable only with MSVC, so we use a C/COM-style interface
35 // to access a precompiled .dll, this *should* work with all Windows compilers.
36 
37 #include <windows.h>
38 //FS: we probably should not include GL directly here, use Qt's wrapper headers instead
39 //#include <GL/GL.h>
40 #include <QOpenGLContext>
41 
42 // FS: We actually want to IMPORT the dll functions, so we have to comment this
43 // Note that it worked before because it seems dllimport is not strictly required (but strongly recommended):
44 // http://stackoverflow.com/a/58031, also, we don't really want to EXPORT the functions again either, and MinGW
45 // seems to sometimes have problems without it
46 //#define SPOUTLIBRARY_EXPORTS // defined for this DLL. The application imports rather than exports
47 
48 #ifdef SPOUTLIBRARY_EXPORTS
49 #define SPOUTAPI __declspec(dllexport)
50 #else
51 #define SPOUTAPI __declspec(dllimport)
52 #endif
53 
55 //
56 // COM-Like abstract interface.
57 // This interface doesn't require __declspec(dllexport/dllimport) specifier.
58 // Method calls are dispatched via virtual table.
59 // Any C++ compiler can use it.
60 // Instances are obtained via factory function.
61 //
63 {
64  // Sender
65  virtual bool CreateSender(const char *Sendername, unsigned int width, unsigned int height, DWORD dwFormat = 0) = 0;
66  virtual void ReleaseSender(DWORD dwMsec = 0) = 0;
67  virtual bool UpdateSender(const char* Sendername, unsigned int width, unsigned int height) = 0;
68  virtual bool SendTexture(GLuint TextureID, GLuint TextureTarget, unsigned int width, unsigned int height, bool bInvert = true, GLuint HostFBO = 0) = 0;
69  virtual bool SendImage(const unsigned char* pixels, unsigned int width, unsigned int height, GLenum glFormat = GL_RGBA, bool bInvert=false) = 0;
70 
71  // Receiver
72  virtual bool CreateReceiver(char* Sendername, unsigned int &width, unsigned int &height, bool bUseActive = false) = 0;
73  virtual void ReleaseReceiver() = 0;
74  virtual bool ReceiveTexture(char* Sendername, unsigned int &width, unsigned int &height, GLuint TextureID = 0, GLuint TextureTarget = 0, bool bInvert = false, GLuint HostFBO = 0) = 0;
75  virtual bool ReceiveImage(char* Sendername, unsigned int &width, unsigned int &height, unsigned char* pixels, GLenum glFormat = GL_RGBA, bool bInvert = false, GLuint HostFBO=0) = 0;
76  virtual bool CheckReceiver(char* Sendername, unsigned int &width, unsigned int &height, bool &bConnected) = 0;
77  virtual bool GetImageSize(char* sendername, unsigned int &width, unsigned int &height, bool &bMemoryMode) = 0;
78 
79  virtual bool BindSharedTexture() = 0;
80  virtual bool UnBindSharedTexture() = 0;
81 
82  virtual bool DrawSharedTexture(float max_x = 1.0, float max_y = 1.0, float aspect = 1.0, bool bInvert = true) = 0;
83  virtual 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) = 0;
84 
85  virtual int GetSenderCount() = 0;
86  virtual bool GetSenderName(int index, char* sendername, int MaxSize = 256) = 0;
87  virtual bool GetSenderInfo(const char* sendername, unsigned int &width, unsigned int &height, HANDLE &dxShareHandle, DWORD &dwFormat) = 0;
88  virtual bool GetActiveSender(char* Sendername) = 0;
89  virtual bool SetActiveSender(const char* Sendername) = 0;
90 
91  // Utilities
92  virtual bool SetDX9(bool bDX9 = true) = 0; // User request to use DirectX 9 (default is DirectX 11)
93  virtual bool GetDX9() = 0; // Return the flag that has been set
94  virtual bool SetMemoryShareMode(bool bMem = true) = 0;
95  virtual bool GetMemoryShareMode() = 0;
96  virtual int GetMaxSenders() = 0; // Get maximum senders allowed
97  virtual void SetMaxSenders(int maxSenders) = 0; // Set maximum senders allowed
98  virtual bool GetHostPath(const char *sendername, char *hostpath, int maxchars) = 0; // The path of the host that produced the sender
99  virtual int GetVerticalSync() = 0;
100  virtual bool SetVerticalSync(bool bSync = true) = 0;
101  virtual bool SelectSenderPanel(const char* message = NULL) = 0;
102 
103  // Access to globals
104  virtual bool GetSpoutSenderName(char * sendername, int maxchars) = 0; // get the global sender name
105  virtual bool IsSpoutInitialized() = 0; // has the class been initialized
106 
107  // Adapter functions
108  virtual int GetNumAdapters() = 0; // Get the number of graphics adapters in the system
109  virtual bool GetAdapterName(int index, char *adaptername, int maxchars) = 0; // Get an adapter name
110  virtual bool SetAdapter(int index = 0) = 0; // Set required graphics adapter for output
111  virtual int GetAdapter() = 0; // Get the SpoutDirectX global adapter index
112 
113  // Library release function
114  virtual void Release() = 0;
115 
116 };
117 
118 
119 // Handle type. In C++ language the interface type is used.
120 typedef SPOUTLIBRARY* SPOUTHANDLE;
121 
122 // Factory function that creates instances of the SPOUT object.
123 extern "C" SPOUTAPI SPOUTHANDLE WINAPI GetSpout(VOID);
124 
125