Giter Site home page Giter Site logo

loadFBOextension fail about spout2 HOT 3 CLOSED

leadedge avatar leadedge commented on June 25, 2024
loadFBOextension fail

from spout2.

Comments (3)

leadedge avatar leadedge commented on June 25, 2024

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.

BlindElephants avatar BlindElephants commented on June 25, 2024

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.

leadedge avatar leadedge commented on June 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.