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

Pages: 1 [2] 3 4
16
Feature requests / Re: Vector2- divide operator
« on: August 20, 2012, 11:25:06 pm »
Evidently I didn't read the documentation  :)

In that case I must be doing something wrong, as this does not work:

sf::Vector2f v(5,5);
sf::Vector2f z = v/5;

"no operator / matches these commands"

17
Feature requests / Vector2- divide operator
« on: August 20, 2012, 03:07:22 pm »
I'm sure this has to have been mentioned before, but I have not been able to find anything mentioning it using the forum's search or google.

Why doesn't sf::Vector2 (I've only been using sf::Vector2f but I assume the problem is with the other types as well) have a divide operator? It seems like an obvious feature to have.

18
SFML projects / Re: TGUI: a c++ GUI for SFML (with Form Builder)
« on: August 12, 2012, 07:01:21 pm »
I'm not using the latest version right now, so I'll post what happens when I am. I'll find a way around it.

19
SFML projects / Re: TGUI: a c++ GUI for SFML (with Form Builder)
« on: August 08, 2012, 08:39:48 pm »
I got bad news. Although the crash in moveToBack was caused by my code (it's fixed now), the shared_ptr did exactly what I was afraid of. At the end of your for loop, when the smart pointer goes out of scope, it deletes the pointer. So the program will crash on the next draw call.

But I don't see what big changes you would need to make in your framework to solve this. It's not like you can't keep using smart pointers at other places, just not with my objects.
As far as I see (I don't have your full source of course, so I could be wrong), all you have to do is change this line
std::shared_ptr<tgui::Picture> objspacer = std::shared_ptr<tgui::Picture>(SfmlFramework::Singleton()->window->add<tgui::Picture>(name1));
into this
tgui::Picture* objspacer = SfmlFramework::Singleton()->window->add<tgui::Picture>(name1);

That should work fine and, unless you are storing the pointers somewhere (which you normally shouldn't do), you don't even have to change anything else.
edit: You will probably have more of these lines and thus more to change than just one line, but the point is that only the declaration of the objects should change.

There's the problem - I'm storing every pointer for every object, and the resource freeing process is based around std::shared_ptr's. However, in my code here:
for(int a=1;a<=cols;a++){
                        std::string name1 = "backpackgui_spacer"+std::to_string((long long)counter);
                        std::shared_ptr<tgui::Picture> objspacer = std::shared_ptr<tgui::Picture>(SfmlFramework::Singleton()->window->add<tgui::Picture>(name1));
                        objspacer->load("noitem.png");
                        objspacer->callbackID = 50+counter;
                        objspacer->setPosition(m_pRoundManager->getMapSize().x/2*tile_size - tile_size - ((cols/2)*tile_size) + tile_size*a,m_pRoundManager->getMapSize().y*tile_size-100 - tile_size - rows*tile_size + i*tile_size);
                        //objspacer->moveToBack(); BREAKS

                        if(i==1 && a == 1){
                                std::string name = "backpackgui_selected";
                                std::shared_ptr<tgui::Picture> selected = std::shared_ptr<tgui::Picture>(SfmlFramework::Singleton()->window->add<tgui::Picture>(name));
                                selected->setPosition(objspacer->getPosition());
                                selected->load("selected.png");
                                selected->moveToBack(); //works fine
                                objects[name] = selected;

The moveToBack() call that is commented out crashes, but selected->moveToBack() later on works fine.

20
SFML projects / Re: TGUI: a c++ GUI for SFML (with Form Builder)
« on: August 07, 2012, 08:54:21 pm »
Ah. Well, my framework is entirely structured around shared_ptrs, so that won't be possible. Also, Avast blocks FormBuilder.exe - "Win32:MalOb-HC [Cryp]"

EDIT: Deleted it (I was using the debug version) and regenerated it as the release mode and it is no longer detected as a virus. I probably have some hitherto unknown virus which infected it the first time.

EDIT X2: The formbuilder immediately exits upon opening.

21
SFML projects / Re: TGUI: a c++ GUI for SFML (with Form Builder)
« on: August 07, 2012, 08:06:11 pm »
Bug:

for(int a=1;a<=cols;a++){
                        std::string name1 = "backpackgui_spacer"+std::to_string((long long)counter);
                        std::shared_ptr<tgui::Picture> objspacer = std::shared_ptr<tgui::Picture>(SfmlFramework::Singleton()->window->add<tgui::Picture>(name1));
                        objspacer->load("noitem.png");
                        objspacer->callbackID = 50+counter;
                        objspacer->setPosition(m_pRoundManager->getMapSize().x/2*tile_size - tile_size - ((cols/2)*tile_size) + tile_size*a,m_pRoundManager->getMapSize().y*tile_size-100 - tile_size - rows*tile_size + i*tile_size);
                        objspacer->moveToBack();
 

The last line, objspacer->moveToBack(), causes the program to exit with:
First-chance exception at 0x775bb9bc in Build to survive.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x003ee408..
First-chance exception at 0x775bb9bc in Build to survive.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x003edd20..
First-chance exception at 0x775bb9bc in Build to survive.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000..

22
SFML projects / Re: TGUI: a c++ GUI for SFML (with Form Builder)
« on: August 07, 2012, 07:41:52 pm »
I built my project again today, and it works! I've absolutely no idea why, but it does.

23
SFML projects / Re: TGUI: a c++ GUI for SFML (with Form Builder)
« on: August 06, 2012, 06:10:20 pm »
So if I understand it correctly, you are just drawing a sprite, nothing more?

If it worked with v0.4, then something must be broken in v0.5, but I don't have any problems here so you will have to find out what is causing it.
- Have you tried with some basic code, nothing more than creating a window and drawing the sprite?
- Try if it makes a difference if you use sf::RenderWindow or tgui::Window. Is the problem with just linking and including, or does it only occur when using tgui in your code?
- Are you using debug libs or release libs for both sfml and tgui? You can't mix them.

If you think that the problem lies in tgui::Window then you can test with tgui::Form (it isn't in the tutorials, you will need to use the documentation or just look in the header file).

I'll test with some basic code later, I am going out for a while. Currently what I have tested is my framework  doing nothing but creating the window and drawing a sprite - nothing to SFML is done other than that - using a tgui::Window, and another with a completely minimal program without tgui (using a sf::RenderWindow) to draw a sprite which works. I highly doubt it is my framework but I'm unsure whether it is using tgui or using the tgui window which is causing the problem.

24
SFML projects / Re: TGUI: a c++ GUI for SFML (with Form Builder)
« on: August 06, 2012, 05:39:22 pm »
You need to make use of the call backtrace, which will tell you what function call is causing the error. ;)

I already know what line is causing the error!

window.draw(sprite)

25
SFML projects / Re: TGUI: a c++ GUI for SFML (with Form Builder)
« on: August 06, 2012, 05:01:51 pm »
Sorry, I meant an SFML sprite. The only thing I can think of, as it works without tgui, is that the tgui window wrapper is somehow breaking this (or if I needed to change something else for the update, but there is nothing in the upgrading tutorial that I have not done).

26
SFML projects / Re: TGUI: a c++ GUI for SFML (with Form Builder)
« on: August 06, 2012, 04:53:34 pm »
I've come across another fatal error - it's either me or tgui. Since upgrading to tgui 0.5 (and to the SFML RC), whenever I try and draw an object an unhandled exception occurs, showing me this code in visual studio 2010:

void RenderTarget::draw(const Vertex* vertices, unsigned int vertexCount,
                        PrimitiveType type, const RenderStates& states)
{
    // Nothing to draw?
    if (!vertices || (vertexCount == 0))
        return;

    if (activate(true))
    {
        // First set the persistent OpenGL states if it's the very first call
        if (!m_cache.glStatesSet)
            resetGLStates();

        // Check if the vertex count is low enough so that we can pre-transform them
        bool useVertexCache = (vertexCount <= StatesCache::VertexCacheSize);
        if (useVertexCache)
        {
            // Pre-transform the vertices and store them into the vertex cache
            for (unsigned int i = 0; i < vertexCount; ++i)
            {
                Vertex& vertex = m_cache.vertexCache[i];
                vertex.position = states.transform * vertices[i].position;
                vertex.color = vertices[i].color;
                vertex.texCoords = vertices[i].texCoords;
            }

I tried drawing something in SFML without tgui and it worked fine. I haven't changed any code at all since upgrading other than a few of the function call names to make it work with the new tgui.

27
SFML projects / Re: TGUI: a c++ GUI for SFML (with Form Builder)
« on: August 02, 2012, 10:14:57 pm »
That's not a problem, upgrading SFML and tgui was on my todo list too. Thanks!

28
SFML projects / Re: TGUI: a c++ GUI for SFML (with Form Builder)
« on: August 02, 2012, 09:27:16 pm »
Nope, that doesn't have any effect. Also, is there any way to make callback activate when the object is underneath another object? I have a "selection box" object, which is a square with an outline and transparent centre positioned exactly on top of the object , but no callback is fired when I click on the object underneath.

29
SFML projects / Re: TGUI: a c++ GUI for SFML (with Form Builder)
« on: August 02, 2012, 08:27:29 pm »
At the moment, the game is created in a window, and the view is immediately set. Then the GUI buttons are created and displayed, but the click positioning is off (exactly like before you fixed it the first time) until I set the view again, after the objects have been created.

30
SFML projects / Re: TGUI: a c++ GUI for SFML (with Form Builder)
« on: August 02, 2012, 03:06:19 pm »
Sorry for taking so long to point this out after the last view bug - I was on holiday :D The objects will only work correctly with Views if you set the view after the object is created. I set the view then create all the objects but change the view when the window is resized, which means in order to use the GUIs I have to resize my window.

Pages: 1 [2] 3 4
anything