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

GL_INVALID_OPERATION when binding VAO when creating own framebuffer #3361

Open
mtytel opened this issue Oct 4, 2024 · 4 comments
Open

GL_INVALID_OPERATION when binding VAO when creating own framebuffer #3361

mtytel opened this issue Oct 4, 2024 · 4 comments

Comments

@mtytel
Copy link
Contributor

mtytel commented Oct 4, 2024

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"

#include <X11/Xlib.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;
        Display* display = (Display*)entry::getNativeDisplayHandle();
        int32_t screen = DefaultScreen(display);
        Window root = RootWindow(display, screen);
        init.platformData.nwh  = (void*)XCreateSimpleWindow(display, root, -100, -100, 1, 1, 0, 0, 0);

        init.platformData.ndt  = entry::getNativeDisplayHandle();
        init.platformData.type = entry::getNativeWindowHandleType();
        init.resolution.width  = 1;
        init.resolution.height = 1;
        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::touch(0);
        bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
        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

@bkaradzic
Copy link
Owner

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

@mtytel
Copy link
Contributor Author

mtytel commented Oct 5, 2024

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

@mtytel
Copy link
Contributor Author

mtytel commented Oct 5, 2024

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.

@mtytel mtytel closed this as completed Oct 5, 2024
@mtytel
Copy link
Contributor Author

mtytel commented Nov 16, 2024

OK I've been playing around with this some more. I created on offscreen window to set as the initial nwh. Then later create a frame buffer for the window I actually want to render to. This still crashes when binding to the VAO.

I edited the example above, this should work right?

@mtytel mtytel reopened this Nov 16, 2024
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