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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Nitetesi

Pages: [1]
1
General / Re: RenderTarget Pointer&Reference issue
« on: November 29, 2021, 09:10:05 am »
Yep, the Entity pointer there (the "this" value) is null.
Maybe the code that set it up wasn't called, or something failed.

Values of pointers close to 0 (like 0x0000000000000108) are still from a null pointer. It's using the null as the base address of an object that doesn't exist, then offsetting from that to find member variables (resulting in the error at a near 0 value).

Yeah i fixed that by making a function that initializes Entity

void MainWindow::initializeEntity(Entity& entity)
{
        this->entity = &entity;
}

2
General / Re: RenderTarget Pointer&Reference issue
« on: November 28, 2021, 06:15:16 pm »
"Access violation reading location 0x0000000000000000" means the program is trying to read from location 0 in memory, which isn't allowed. This is typically caused by using a pointer which is null.
If you run the program in a debugger, it should stop on the actual location of the null dereference. The code you provided might not actually be where things are failing (if it is, then probably either window or entity are null).

The address is now static
Access violation reading location 0x0000000000000108.
And i am sure that the problem is Entity



3
General / Re: RenderTarget Pointer&Reference issue
« on: November 28, 2021, 03:06:01 pm »
You're probably reading or writing to a nullptr.

Too lazy to explain in detail ;)
void Entity::render(sf::RenderTarget& target)
{
        this->setEntity();
        target.draw(this->entity);
}
Nothing looks undefined and now i am seeing that error on setEntity() function

void MainWindow::render()
{
        this->setVariables();
        this->window->clear(this->gray);
        this->window->draw(this->posText);
        this->entity->render(*this->window);
        this->window->display();
}

4
General / Re: RenderTarget Pointer&Reference issue
« on: November 27, 2021, 07:49:27 pm »
You're probably reading or writing to a nullptr.

Too lazy to explain in detail ;)

Could you explain?

5
General / RenderTarget Pointer&Reference issue
« on: November 20, 2021, 04:51:16 pm »
Too lazy to explain in detail

void Entity::render(sf::RenderTarget& target)
{
        target.draw(this->entity);
}
 

0xC0000005: Access violation reading location 0x0000000000000000.


Render function in Window.cpp
this->entity->render(*this->window);
 

Window.h
-------------------------
sf::RenderWindow* window;
Entity* entity;

6
General / Re: Text and Audio aren't working
« on: November 20, 2021, 06:35:55 am »
For the text, the problem is your font is a local variable in Window::setText(). Once that function ends, the font is deconstructed. As the header for Text::setFont says:
Quote
The font argument refers to a font that must exist as long as the text uses it. Indeed, the text doesn't store its own copy of the font, but rather keeps a pointer to the one that you passed to this function. If the font is destroyed and the text tries to use it, the behavior is undefined.
So the Font should be stored somewhere more permanent.
Oh that was the problem for the font, thanks

7
General / Text and Audio aren't working
« on: November 19, 2021, 09:19:54 pm »
I am using Debug x64 and i am not mixing libraries (linked libs with -d suffixes)
No sound at all and Text is broken because of the font

void Window::setText()
{
        sf::Font font;
        if (!font.loadFromFile("edge.otf"))
        {
          std::cout << "ERROR" << std::endl;
        }
        this->text.setFont(font);
        this->text.setCharacterSize(24);
        this->text.setString("Hello World");
}
 

Exception thrown at 0x00007FFD771569DB (sfml-graphics-d-2.dll) in WindWar.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

Sound::Sound()
{
        buffer.loadFromFile("assets/harp.wav");
}

Sound::~Sound()
{
}

void Sound::play()
{
        sound.setBuffer(buffer);
        sound.play();
}
 

No error but no sound

8
General / Re: Image file for sprite is failed to load?
« on: November 19, 2021, 03:23:36 pm »
You've probably misread my post but i did the reverse (added -d to end of the library names and it seems worked) Thank you

9
General / Image file for sprite is failed to load? [SOLVED]
« on: November 19, 2021, 10:32:32 am »
I am just trying to create a sprite file, i put the image file both on working and output directories.
sf::Texture texture;
texture.loadFromFile("brick.jpg");
       
sf::Sprite sprite;
sprite.setTexture(texture);
this->window->draw(sprite);
 
I am sure that the conf is alright, it works on Debug x64

Failed to load image "á±ô‼x☺brick.jpg   ☼øq$~:→7É☼m÷⌂↑³¤▼F@·¤▼FŞ'♫m÷⌂P·¤▼FÉ☺". Reason: Unable to open file

Pages: [1]