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

Author Topic: Passing renderWindow as an argument causes acces violation exception?  (Read 1540 times)

0 Members and 1 Guest are viewing this topic.

SamTheT

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Hey guys! I just started using SFML and I am working on a "paint" app just for fun and I encountered a problem: I have a button class, which has sf::Text, bounds and stuff (buttons will be used to switch between brushes, for example) and I need to draw it. I found a simple solution for myself, but it doesn't work :( I'll write some code for a simplr understanding:
WindowButton::draw(sf::RenderWindow* renderWindow)
{
renderWindow->draw(buttonText);
}

But this gives me access violation exception every frame and that freaks me out! Is there any way to fix this?

P.S: there might a problem with button text though, but I'm not sure, I'll try to investigate it, but still, please help me, I need to know if passing renderWindow as an argument is actually a thing.
Thanks in advance!

SamTheT

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: Passing renderWindow as an argument causes acces violation exception?
« Reply #1 on: December 25, 2015, 10:44:45 am »
Okay, it's okay to pass the render window as an argument as I found out, BUT I still can't draw text with it, it seems like I can't access the button's sf::Text class even though it is public. Any solution to that? I have no idea what's happening.

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Passing renderWindow as an argument causes acces violation exception?
« Reply #2 on: December 25, 2015, 03:55:45 pm »
Post a complete and minimal example that shows the problem. But if I had to guess, I would say that your font and text instance are part of your WindowButton class and you copy your button which causes the font to be copied, but the text instance still has a pointer to the old font.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor