Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loadFBOextension fail #39

Closed
BlindElephants opened this issue Jan 24, 2019 · 3 comments
Closed

loadFBOextension fail #39

BlindElephants opened this issue Jan 24, 2019 · 3 comments

Comments

@BlindElephants
Copy link

I'm using SpoutSDK in Visual Studio. Creating a new instance of SpoutSender works and everything compiles and links properly. When I call CreateSender("senderName", 1280, 720); i get the error:

loadFBOextension fail
Spout::CreateSender - OpenSpout failed

Running on Windows 10 with a Nvidia 1070ti GPU which fully supports all openGL extensions through openGL 4.6.

Any advice on how to get this working?

@leadedge
Copy link
Owner

leadedge commented Jan 24, 2019

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.

@BlindElephants
Copy link
Author

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);

@leadedge
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants