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 - slohobo

Pages: [1]
1
General / Deletion of sfml objects
« on: August 26, 2017, 05:41:36 pm »
I have some objects that are taking up heap space on the memory by using the new operator and I want to know if I am properly deleting these objects. Whenever I allocate them onto heap the heap I delete them using the delete operator because I didn't see a deconstructor in any of the sfml classes (looking at the header files provided on the sfml site).

2
Window / Window resize messing with hitboxes
« on: August 14, 2017, 09:47:06 pm »
I am sure it is a line of code that will fix my issue, but whenever I maximize my window, sfml will inherently change how my hitboxes work with the user (in this case the mouse). If I start my program at 1280x720p and my hitboxes revolve around that resolution than it will work fine, but if I increase the size of my program to 1400x1080p then my hitboxes "get smaller". The hitboxes in theory do not get smaller, but as the amount of pixels on the screen increase, the hitbox itself doesn't account for the change. Is there something in sfml that will account for resizes or do I have to do the math around it and figure it out?

I am asking this because whenever I resize the window, sfml accounts for the graphical changes the resize did.

I really hope this makes sense...

3
Graphics / Re: sfml text exception
« on: August 13, 2017, 01:07:27 am »
I was hoping that sfml's classes would copy construct the variables I pass to it (cuz I am a newb), and it actually saves memory by requiring the user to make sure the variables that they send to the object have been saved by the user (not just deleted after scope aka a very java way of programming). I have to leave my safe space of OOP.

[You don't need to read the next sentence]
I don't need to const reference but I might as well just leave it there for good luck because either way it isn't going to do anything either way.
        TextInteraction::TextInteraction(RECT box, const std::string &pText, const sf::Font &_font,
                                          const int &_size, float x, float y) : HitBox(box) {
                content = new std::string(pText);
                font = new sf::Font(_font);
                size = new int(_size);
                text = new sf::Text(*content, *font, *size);
                text->setPosition(x, y);
                text->setOrigin(x, y);
                text->setColor(sf::Color::White);
        }

4
Graphics / Re: sfml text exception
« on: August 12, 2017, 11:08:13 pm »
So I made the constructor require a const reference of my sf::Font object, but I am still receiving the same exception as before mentioned.

        TextInteraction::TextInteraction(RECT box, std::string _text, const sf::Font &font,
                                              int size, float x, float y) : HitBox(box) {
                text = new sf::Text(_text, font, size);
                text->setPosition(x, y);
                text->setOrigin(x, y);
                text->setColor(sf::Color::White);
        }

5
Graphics / sfml text exception
« on: August 12, 2017, 06:52:31 pm »
I am trying to display a Text object and I am receiving an error when I try sending it to the draw function in my sf::RenderWindow object. Bear in mind that I was originally a java programmer so I might be doing something that only works in java (but I doubt it).

The exception looks like (though I doubt it will do any good because it seems like it is sending me the location in the runtime memory the exception is occuring):

Exception thrown at 0x548EAB3F (sfml-graphics-d-2.dll) in Survior.exe: 0xC0000005: Access violation reading location 0xCCCCCD24. occurred

//where exception in relayed
        void TextInteraction::textDisplay() {
                //displays regular text white
                MainWindow::window.draw(*text);
        }
//constructor
        TextInteraction::TextInteraction(RECT box, std::string _text, sf::Font font, int size, float x, float y) : HitBox(box) {
                text = new sf::Text(_text, font, size);
                text->setOrigin(x, y);
                text->setColor(sf::Color::White);
        }

Pages: [1]