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

Author Topic: Access violation when declaring Texture object  (Read 1550 times)

0 Members and 1 Guest are viewing this topic.

EldarFara

  • Newbie
  • *
  • Posts: 6
    • View Profile
Access violation when declaring Texture object
« on: May 06, 2018, 06:19:40 pm »
Hello, I have strange problem while trying to declare Texture object inside class.
What I have:
(click to show/hide)
That supposed to be a menu class that declaring images, textures and sprites for menu and draws it, and i have "Unhandled exception at 0x779522E2 (ntdll.dll) in Project137.exe: 0xC0000005: Access violation writing location 0x00000004." on the line where system_main_menu object is being declared.
Problem solves only if I will remove that 3 lines with declaring textures: Texture t_main_logo, Texture t_main_menu_background and Texture t_welcome_to_loading and usage of them.
For example this code won't work:
(click to show/hide)
It works if I declare texture outside class (in main() for example) but still doesnt work if I declare them in any other class.
Strange thing is that code worked fine until I started to use cout to get some variables values, then that error appeared, and when I used ctrl+z to undo code I wrote that problem didn't disappear. I'm not sure if this problem connected to SFML itself (probably my software problem) but I googled that problem I have and found out they all have very different reasons. Sorry if provided not enough info about problem, feel free to ask for more.
I use SFML 2.4.2 x32 in VS 2017, precompiled build by Nightlybuilds (here).
« Last Edit: May 06, 2018, 06:37:00 pm by EldarFara »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10846
    • View Profile
    • development blog
    • Email
Re: Access violation when declaring Texture object
« Reply #1 on: May 06, 2018, 06:23:54 pm »
Did you also download the 32bit binaries and are you certain you're using the 32bit compiler?

If you use the debugger, where does it crash exactly?
« Last Edit: May 06, 2018, 06:25:55 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

EldarFara

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Access violation when declaring Texture object
« Reply #2 on: May 06, 2018, 06:47:18 pm »
Many thanks for fast answer,
I use 32bit binaries and x86 compiler (in case if you meant it).
Not sure about what debugger you meant, I compile in debug mode, it builds the program and opens debug console but not the SFML window, and pointing to exception in line with declaring object of class with textures, as I described.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10846
    • View Profile
    • development blog
    • Email
Re: Access violation when declaring Texture object
« Reply #3 on: May 06, 2018, 10:07:48 pm »
What's the callstack? (If you don't know what that is, you may want to look it up :) )
« Last Edit: May 06, 2018, 10:17:02 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

EldarFara

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Access violation when declaring Texture object
« Reply #4 on: May 07, 2018, 01:10:52 pm »
Good day,
Here is my callstack:
(click to show/hide)

EldarFara

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Access violation when declaring Texture object
« Reply #5 on: May 10, 2018, 10:19:23 am »
After discussing the the topic in SFML discord group it turned out that using another precompiled SFML binaries helps. So problem is solved for now