Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Rendering in COM object, opengl problem  (Read 180 times)

0 Members and 1 Guest are viewing this topic.

Kuba

  • Newbie
  • *
  • Posts: 4
    • View Profile
Rendering in COM object, opengl problem
« on: May 12, 2025, 08:51:48 pm »
Hi,
Recently I was developing a COM system with SFML. And I encountered problem with displaying anything on screen by passing the pointer to render window. It seems that there is something wrong with opengl, could you help me? I've tried writing to sf::RenderTexture but nothing works for me so far...

In attachments you can see the callstack and the fact that this is still the main thread (so another context shouldn't be needed). And also exactly which exception there is and where.

Thank you so much in advance! In case of any questions I am here to reply.
SFML is updated with github.

« Last Edit: May 12, 2025, 08:55:25 pm by Kuba »

Kuba

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Rendering in COM object, opengl prol
« Reply #1 on: May 12, 2025, 08:54:13 pm »
And here is the code snippet with gdb output.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11203
    • View Profile
    • development blog
    • Email
Re: Rendering in COM object, opengl problem
« Reply #2 on: May 13, 2025, 01:04:05 am »
Not sure what you mean with COM in this case or if it's even relevant to the issue.

Since I see you use new and raw pointers, my guess is, that you're passing somewhere a nullptr without realizing it, which then causes a crash.
I recommend to stick to references whenever possible and use stack allocated objects instead of heap objects and if you really need a pointer, use smart pointers, preferably std::unique_ptr
Official FAQ: https://www.sfml-dev.org/faq/
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Kuba

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Rendering in COM object, opengl problem
« Reply #3 on: May 13, 2025, 09:48:39 am »
Hi, thanks for reply,
COM - Component object model.

And yeah, I also wondered about the pointer correctness but it is correct and as you said I changed to reference and issue remains exactly the same.

In screenshot there is a dupe of sf::RenderTarget during clear, when the crash happens. And I also want to mention that when I copy-paste exact code in place in main program where it is called - it works. I suspect that maybe opengl broke, but it is really hard for me to tell.


eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11203
    • View Profile
    • development blog
    • Email
Re: Rendering in COM object, opengl problem
« Reply #4 on: May 13, 2025, 10:56:51 am »
From my experience the issue usually in nearly all cases with ones own code. ;D

Okay, so you do mean COM, but I guess it's not really relevant for the rest of the issue.

Do you have a minimal, but complete code example that reproduces the issue?
Official FAQ: https://www.sfml-dev.org/faq/
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Kuba

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Rendering in COM object, opengl problem
« Reply #5 on: May 16, 2025, 01:00:06 pm »
Hey okay I got this, sorry for not providing minimum viable code, since it is time-consuming a little bit.

Generally, I found the root of this problem. Both main app and this dll are in the same thread, but opengl functions in dll are nullptr (and in main app they exist somehow). Setting window active and creating sf::Context in dll place doesnt resolve the issue... and any call to opengl from dll causes the error.

I will try to provide code sample today, it is going to be more interesting hahah


 

anything