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

Pages: [1]
1
Graphics / Re: Making my own Render Queue with Drawables
« on: April 08, 2017, 02:16:56 pm »
You don't necessarily need to allocate it on the heap, but you need to make sure the object the pointer points to stays alive. Keep in mind that your render queue should not handle the lifetime of your objects.

What would you say is a better way to keep the objects alive then?

2
Graphics / Re: Making my own Render Queue with Drawables
« on: April 08, 2017, 01:52:35 pm »
Given the error message, you seem to try and access a null pointer. Make sure that all your pointers are valid.

Indeed. Immediately upon realizing this, I went and declared the shape I wanted drawn on the heap instead and it worked. What can I say, pointers still confuse me some times. Oops.

Anyway, thanks for the reply! :D

3
Graphics / Making my own Render Queue with Drawables
« on: April 08, 2017, 12:46:47 pm »
Right, so I'm very new to sfml and computer graphics in general. I tired my hand at OpenGL a while ago and that experience sort of put me off OpenGL for a while, which is why I've been playing around with SFML recently.

What I'm trying to do is to create my own render queue, which can then render all of it's drawables to any RenderTarget:

#include "RenderQ.h"

namespace game {
        namespace renderer {

                RenderQ::RenderQ()
                {
                        _queue = std::vector<sf::Drawable *>();
                }

                void RenderQ::submit(sf::Drawable * drawable)
                {
                        _queue.push_back(drawable);
                }

                void RenderQ::clear()
                {
                        _queue.clear();
                }

                void RenderQ::drawAll(sf::RenderTarget& target)
                {
                        for (int i = 0; i < _queue.size(); i++) {
                                target.draw( *_queue[i] );
                        }
                }

        }
}
 

I can submit to the queue just fine. The problem comes when I call drawAll.

I'm not entirely certain what happens or why it breaks, but it throws this error at me and I've unsuccessfully spent a couple of hour trying to figure out where it comes from:

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

I'm not entirely certain what sort of information I can get from the error. It's not very descriptive, and I'm not entirely certain on how to do proper error handling ( or in fact, catching ) with SFML. Any sort of help would be greatly appreciated.

Thanks in advance!

Pages: [1]
anything