bkaradzic/bgfx

GL_INVALID_OPERATION when binding VAO when creating own framebuffer

mtytel opened this issue · 4 comments

Instead of passing a window handle to bgfx::init I'm creating my own frame buffer for a window handle. This triggers a GL_INVALID_OPERATION.
Running this on Ubuntu 24.04

To Reproduce
I've edited the Hello World example to trigger the GL_INVALID_OPERATION.

#include <bx/uint32_t.h>
#include "common.h"
#include "bgfx_utils.h"
#include "logo.h"

namespace
{

class ExampleHelloWorld : public entry::AppI
{
public:
  ExampleHelloWorld(const char* _name, const char* _description, const char* _url)
  : entry::AppI(_name, _description, _url)
	{
	}

	void init(int32_t, const char* const*, uint32_t _width, uint32_t _height) override
	{
		m_width  = _width;
		m_height = _height;

		bgfx::Init init;
		init.type = bgfx::RendererType::OpenGL;
		init.platformData.ndt  = entry::getNativeDisplayHandle();
		bgfx::init(init);
	}

	virtual int shutdown() override
	{
		bgfx::shutdown();

		return 0;
	}

	bool update() override
	{
		if (!bgfx::isValid(m_fbh))
			m_fbh = bgfx::createFrameBuffer(entry::getNativeWindowHandle(entry::kDefaultWindowHandle), m_width, m_height);

		bgfx::setViewFrameBuffer(0, m_fbh);
		bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
		bgfx::touch(0);
		bgfx::frame();

		return true;
	}

	uint32_t m_width;
	uint32_t m_height;
	bgfx::FrameBufferHandle m_fbh = BGFX_INVALID_HANDLE;
};

} // namespace

ENTRY_IMPLEMENT_MAIN(
    ExampleHelloWorld
	, "00-helloworld"
	, "Triggers an open gl invalid operation"
	, ""
	);

Additional context
OpenGL core profile version string: 4.6.0 NVIDIA 550.90.07

Think this is related to issue #209

You're using window handle that's already used for primary window...

I removed the nwh assignment in the init so it's headless isn't it?

Alright I thought headless OpenGL was supported because I didn't get an error when I didn't pass in the nwh. I didn't realize it was getting the window handle somehow.

I created an offscreen window that I pass into init.nwh and that seems to work.