Comments (3)
As it happens, the same thing has happened for other people recently. In one case there was no OpenGL context at all and in the other there was a context but not the "primary" context.
Some time back I found that the context needs to be created in the thread where the Spout functions are used or else create a shared context in one thread and switch to it in the thread where it will be used. An example of how I got around it is here :
https://github.com/leadedge/Spout2/blob/master/VIRTUALDJ/Source/SpoutSender/VDJSpoutSender.cpp
I hope this resolves the problem.
from spout2.
Thanks for your reply. This sorted everything out.
Just for the sake of clarity in case it will help someone else in the future,
I'm working with Spout along with OpenCV 4.0.1, as well as ZED SDK. Pulling the stereographic image and depth image off the camera using the ZED SDK, processing it for feature extraction using OpenCV, and then sending messages out over OSC pertaining to features, as well as a prepared mask image, which is being sent via Spout to Resolume for video content generation.
This code was added to the constructor of my camera manager class. Totally cleared up the Spout errors and got everything working nicely.
Thanks!
HWND m_hwnd;
HDC m_hdc;
HGLRC m_hRC;
HGLRC m_hSharedRC;
bool bOpenGL = false;
m_hwnd = CreateWindow("BUTTON", "VDJ Sender", WS_OVERLAPPEDWINDOW | CS_OWNDC, 0, 0, 32, 32, NULL, NULL, NULL, NULL);
if (!m_hwnd)
{
printf("InitOpenGL error 1\n");
MessageBoxA(NULL, "Error 1\n", "InitOpenGL", MB_OK);
}
m_hdc = GetDC(m_hwnd);
if (!m_hdc)
{
printf("InitOpenGL error 2\n");
MessageBoxA(NULL, "Error 2\n", "InitOpenGL", MB_OK);
}
PIXELFORMATDESCRIPTOR pfd;
ZeroMemory(&pfd, sizeof(pfd));
pfd.nSize = sizeof(pfd);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 32;
pfd.cDepthBits = 24;
pfd.cStencilBits = 8;
pfd.iLayerType = PFD_MAIN_PLANE;
int iFormat = ChoosePixelFormat(m_hdc, &pfd);
if (!iFormat)
{
printf("InitOpenGL error 3\n");
MessageBoxA(NULL, "Error 3\n", "InitOpenGL", MB_OK);
}
if (!SetPixelFormat(m_hdc, iFormat, &pfd))
{
printf("InitOpenGL error 4\n");
MessageBoxA(NULL, "Error 4\n", "InitOpenGL", MB_OK);
}
m_hRC = wglCreateContext(m_hdc);
if (!m_hRC)
{
printf("InitOpenGL error 5\n");
MessageBoxA(NULL, "Error 5\n", "InitOpenGL", MB_OK);
}
wglMakeCurrent(m_hdc, m_hRC);
if (wglGetCurrentContext() == NULL)
{
printf("InitOpenGL error 6\n");
MessageBoxA(NULL, "Error 6\n", "InitOpenGL", MB_OK);
}
m_hSharedRC = wglCreateContext(m_hdc);
if (!m_hSharedRC) printf("InitOpenGL shared context not created\n");
if (!wglShareLists(m_hSharedRC, m_hRC)) printf("wglShare Lists failed\n");
spoutSender = std::make_shared<SpoutSender>();
std::cout << std::endl << std::endl << "Num Adapters:\t" << spoutSender->GetNumAdapters() << std::endl;
std::cout << "Using Adapter:\t" << spoutSender->GetAdapter() << std::endl;
std::cout << "using DX9?\t" << spoutSender->GetDX9() << std::endl << "using CPU?\t" << spoutSender->GetCPUmode() << std::endl << "GetShareMode():\t" << spoutSender->GetShareMode() << std::endl;
spoutSender->CreateSender("spoutVideoOut", 1280, 720);
from spout2.
OK that's good. Thanks for the detail. In the next Spout version I will be introducing checks and warnings along with logs to reveal such problems.
from spout2.
Related Issues (20)
- Spout DX12 HOT 2
- FFGL 2.0 HOT 10
- Creating Spout sender without OpenGL context HOT 10
- Port spout to VK_External_memory HOT 6
- Discrete Spout to NDI HOT 3
- Spout 2.007 : SpoutSender / SpoutSenderNames crashing HOT 5
- RFE: get spout version as String HOT 8
- Spout Settings - max senders can't set to a value with more than 2 digits HOT 3
- Support for Vulkan HOT 2
- Laptops with multiple GPUs HOT 4
- D3D11 Format HOT 28
- SpoutSender/Receiver sourcecode HOT 5
- SpoutLibrary : unable to setup multiple named Spout Receivers HOT 11
- Unused #include <d3d9.h> in SpoutLibrary.h makes compilation with JUCE fail. HOT 2
- GL-Spout-NDI-DX ? HOT 3
- Global registry settings HOT 3
- Multiple Senders in SpoutDX HOT 4
- CPU sharing flag is always false in OpenSpout HOT 7
- Small code issue in SpoutGL.cpp HOT 3
- Use SendImage without using OF, Cinder, etc. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spout2.