Skip to content

Commit a9814ea

Browse files
committed
CC2021 - Force dedicated window
1 parent 0a2addf commit a9814ea

File tree

2 files changed

+91
-16
lines changed

2 files changed

+91
-16
lines changed

Spout-AfterEffects.vcxproj

+6-6
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,32 @@
2222
<ProjectGuid>{6D4130D4-8DE3-4EA9-ACDC-8ED259E620D0}</ProjectGuid>
2323
<Keyword>Win32Proj</Keyword>
2424
<RootNamespace>SpoutAfterEffects</RootNamespace>
25-
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
25+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
2626
</PropertyGroup>
2727
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
2828
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
2929
<ConfigurationType>DynamicLibrary</ConfigurationType>
3030
<UseDebugLibraries>true</UseDebugLibraries>
31-
<PlatformToolset>v141</PlatformToolset>
31+
<PlatformToolset>v142</PlatformToolset>
3232
<CharacterSet>Unicode</CharacterSet>
3333
</PropertyGroup>
3434
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
3535
<ConfigurationType>DynamicLibrary</ConfigurationType>
3636
<UseDebugLibraries>false</UseDebugLibraries>
37-
<PlatformToolset>v141</PlatformToolset>
37+
<PlatformToolset>v142</PlatformToolset>
3838
<WholeProgramOptimization>true</WholeProgramOptimization>
3939
<CharacterSet>Unicode</CharacterSet>
4040
</PropertyGroup>
4141
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
4242
<ConfigurationType>DynamicLibrary</ConfigurationType>
4343
<UseDebugLibraries>true</UseDebugLibraries>
44-
<PlatformToolset>v141</PlatformToolset>
44+
<PlatformToolset>v142</PlatformToolset>
4545
<CharacterSet>Unicode</CharacterSet>
4646
</PropertyGroup>
4747
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
4848
<ConfigurationType>DynamicLibrary</ConfigurationType>
4949
<UseDebugLibraries>false</UseDebugLibraries>
50-
<PlatformToolset>v141</PlatformToolset>
50+
<PlatformToolset>v142</PlatformToolset>
5151
<WholeProgramOptimization>true</WholeProgramOptimization>
5252
<CharacterSet>Unicode</CharacterSet>
5353
</PropertyGroup>
@@ -139,7 +139,7 @@
139139
<FunctionLevelLinking>true</FunctionLevelLinking>
140140
<IntrinsicFunctions>true</IntrinsicFunctions>
141141
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;SPOUTAFTEREFFECTS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
142-
<AdditionalIncludeDirectories>C:\Program Files %28x86%29\Spout2\SPOUTSDK\SpoutSDK;$(AESDK)/Util;$(AESDK)/Headers;$(AESDK)/SP;$(AESDK)/Win;$(AESDK)/Resources;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
142+
<AdditionalIncludeDirectories>C:\Program Files %28x86%29\Spout2\SPOUTSDK\SpoutSDK;$(AESDK)/Util;$(AESDK)\Headers;$(AESDK)/SP;$(AESDK)/Win;$(AESDK)/Resources;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
143143
</ClCompile>
144144
<Link>
145145
<SubSystem>Windows</SubSystem>

SpoutAE.cpp

+85-10
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,87 @@ MyBlit(
5151
if (!bSenderInitialized)
5252
{
5353
printf("Create sender\n");
54+
HWND m_hwnd;
55+
HDC m_hdc;
56+
HGLRC m_hRC;
57+
HGLRC m_hSharedRC;
58+
bool bOpenGL = false;
59+
60+
m_hwnd = CreateWindow(L"BUTTON", L"VDJ Sender", WS_OVERLAPPEDWINDOW | CS_OWNDC, 0, 0, 32, 32, NULL, NULL, NULL, NULL);
61+
62+
if (!m_hwnd)
63+
{
64+
printf("InitOpenGL error 1\n");
65+
MessageBoxA(NULL, "Error 1\n", "InitOpenGL", MB_OK);
66+
}
67+
68+
m_hdc = GetDC(m_hwnd);
69+
if (!m_hdc)
70+
{
71+
printf("InitOpenGL error 2\n");
72+
MessageBoxA(NULL, "Error 2\n", "InitOpenGL", MB_OK);
73+
}
74+
75+
PIXELFORMATDESCRIPTOR pfd;
76+
ZeroMemory(&pfd, sizeof(pfd));
77+
pfd.nSize = sizeof(pfd);
78+
pfd.nVersion = 1;
79+
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
80+
pfd.iPixelType = PFD_TYPE_RGBA;
81+
pfd.cColorBits = 32;
82+
pfd.cDepthBits = 24;
83+
pfd.cStencilBits = 8;
84+
pfd.iLayerType = PFD_MAIN_PLANE;
85+
int iFormat = ChoosePixelFormat(m_hdc, &pfd);
86+
if (!iFormat)
87+
{
88+
printf("InitOpenGL error 3\n");
89+
MessageBoxA(NULL, "Error 3\n", "InitOpenGL", MB_OK);
90+
}
91+
92+
if (!SetPixelFormat(m_hdc, iFormat, &pfd))
93+
{
94+
printf("InitOpenGL error 4\n");
95+
MessageBoxA(NULL, "Error 4\n", "InitOpenGL", MB_OK);
96+
}
97+
98+
m_hRC = wglCreateContext(m_hdc);
99+
if (!m_hRC)
100+
{
101+
printf("InitOpenGL error 5\n");
102+
MessageBoxA(NULL, "Error 5\n", "InitOpenGL", MB_OK);
103+
}
104+
105+
wglMakeCurrent(m_hdc, m_hRC);
106+
if (wglGetCurrentContext() == NULL)
107+
{
108+
printf("InitOpenGL error 6\n");
109+
MessageBoxA(NULL, "Error 6\n", "InitOpenGL", MB_OK);
110+
}
111+
112+
m_hSharedRC = wglCreateContext(m_hdc);
113+
if (!m_hSharedRC) printf("InitOpenGL shared context not created\n");
114+
if (!wglShareLists(m_hSharedRC, m_hRC)) printf("wglShare Lists failed\n");
115+
116+
//spoutSender = std::make_shared<SpoutSender>();
117+
std::cout << std::endl << std::endl << "Num Adapters:\t" << spoutsender.GetNumAdapters() << std::endl;
118+
std::cout << "Using Adapter:\t" << spoutsender.GetAdapter() << std::endl;
119+
std::cout << "using DX9?\t" << spoutsender.GetDX9() << std::endl << "using CPU?\t" << spoutsender.GetCPUmode() << std::endl << "GetShareMode():\t" << spoutsender.GetShareMode() << std::endl;
54120
bSenderInitialized = spoutsender.CreateSender(senderName, tWidth, tHeight);
121+
55122
if (pixels2 != nullptr)
56123
{
57124
delete pixels2;
58-
pixels2 = (PF_Pixel8 *)malloc(tWidth*tHeight * sizeof(PF_Pixel8));
125+
pixels2 = (PF_Pixel8*)malloc(tWidth * tHeight * sizeof(PF_Pixel8));
59126
}
127+
128+
/*
129+
bSenderInitialized = spoutsender.CreateSender(senderName, tWidth, tHeight);
130+
if (pixels2 != nullptr)
131+
{
132+
delete pixels2;
133+
pixels2 = (PF_Pixel8 *)malloc(tWidth*tHeight * sizeof(PF_Pixel8));
134+
}*/
60135
}
61136
else if (shouldUpdate)
62137
{
@@ -147,15 +222,15 @@ MyDeath(
147222
void *hook_refconPV)
148223
{
149224
// free anything you allocated.
225+
spoutsender.SpoutCleanUp(true);
150226
}
151227

152228
static void
153229
MyVersion(
154230
void *hook_refconPV,
155231
A_u_long *versionPV)
156232
{
157-
spoutsender.SpoutCleanUp(true);
158-
233+
159234
*versionPV = 1;
160235
}
161236

@@ -173,14 +248,14 @@ EntryPointFunc(
173248
hooksP->version_hook_func = MyVersion;
174249

175250

176-
/*
177-
AllocConsole();
178-
freopen("CONIN$", "r", stdin);
179-
freopen("CONOUT$", "w", stdout);
180-
freopen("CONOUT$", "w", stderr);
181251

182-
printf("SpoutAE EntryPoint\n");
183-
*/
252+
//AllocConsole();
253+
//freopen("CONIN$", "r", stdin);
254+
//freopen("CONOUT$", "w", stdout);
255+
//freopen("CONOUT$", "w", stderr);
256+
//
257+
//printf("SpoutAE EntryPoint\n");
258+
184259

185260

186261
//spoutsender = GetSpout(); // Create an instance of the Spout library

0 commit comments

Comments
 (0)