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

Pages: 1 ... 3 4 [5]
61
Graphics / TransformToLocal() in SFML 2
« on: September 18, 2012, 01:46:21 am »
Is there an equivalent to sf::Drawable::TransformToLocal(const sf::Vector2f&) in SFML 2? If not, what exactly does it do? It seem simple enough by the name. Is it correct to assume that it takes the global coordinates supplied and returns the coordinates relative to the origin of the given sprite? I'm porting something over from SFML 1.6 (which I've never used). Thanks!


Edit: I figured it out, it's fairly simple: Sprite.getInverseTransform().transformPoint(sf::Vector2f(x, y))

62
Graphics / Re: sf::Texture destructor segfault?
« on: August 08, 2012, 02:28:48 am »
None of that will really help, maybe get a step closer to the problem, but what you actually have to do is a minimal (i.e. as less lines of code as possible that still produces the error) but complete (i.e. one can take your code and compile it) example. Often in the task of trimming down things, one finds the mistake on yourself. ;)

Okay, I'm wondering if it has something to do with the inheritance now... I just can't figure it out. GameInstance and it's two base classes have nothing allocated to the heap so I can't figure out what could be going wrong. I'll dig more and see if I can come up with something. I am not 100% sure that I'm using virtual functions and destructors properly either, do you think this could potentially be the problem?

Unfortunatly cplusplus.com isn't uptodate with the whole C++11 standard. They got a few but not very much of these functions. Cppreference is a wiki and thus gives the people more power to change things. ;)
Yeah, I've noticed that. They do seem to be lacking a lot with the new standard. I'll definitely be digging around that wiki! :)




Edit:
One of my base classes had a virtual destructor while the other didn't. However giving them both a virtual destructor yields the same results; some undefined access violation it seems.

63
Graphics / Re: sf::Texture destructor segfault?
« on: August 08, 2012, 02:16:30 am »
I use nothrow because I haven't learned to use exceptions and nothrow is a lazy/cheap way of checking for an error without checking for an exception. The destructor of GameInstance is created by the compiler, would it help to see the header for GameInstance? By the way, GameInstance does inherit from two other classes... could this be the problem?

Also, thanks for showing me that link from C++ reference. I normally try to find my answers from www.cplusplus.com.

64
Graphics / Re: sf::Texture destructor segfault?
« on: August 08, 2012, 01:08:24 am »
Alright, well I started learning how to use GDB and it wasn't the sf::Textures at all... It seems to actually be sf::Vertex. I think I'm using sf::RectangleShape improperly. This is a screenshot of my call stack when I get the segfault:

http://postimage.org/image/8pt4szacf/

It seems that GameInstance (within InstanceManager) is setting this whole thing off. GameInstance holds an sf::RectangleShape like this:

class GameInstance
{
     private:
          sf::RectangleShape DebugRect;
}
 

I don't understand what's going on, are shapes supposed to be allocated on the heap? Again, this is my first time using GDB so don't be too harsh :)


Also, a completely separate question: When using std::nothrow in C++11, does it still return 0 or does it return nullptr?

65
Graphics / sf::Texture destructor segfault?
« on: August 06, 2012, 07:57:45 pm »
Hello all,

I made a little SpriteManager class which will handle sprites (and textures) loading and passing around. This is my add function:

signed int Phox::cSpriteManager::Add(const std::string& Path, bool Smooth)
{
    for (unsigned int i = 0; i < Paths.size(); i++)
        if (Paths[i] == Path) return -1;

    sf::Texture* Texture = new (std::nothrow) sf::Texture;
        if (!Texture) return -2;

    sf::Sprite* Sprite = new (std::nothrow) sf::Sprite;
        if (!Sprite) return -3;

    if (!Texture->loadFromFile(Path))
    {
        delete Texture;
        delete Sprite;
        return -4;
    }

    Texture->setSmooth(Smooth);
    Sprite->setTexture(*Texture);

    Paths.push_back(Path);
    Textures.push_back(Texture);
    Sprites.push_back(Sprite);

    return Sprites.size() - 1;
}
 


And here is the destructor:
Phox::cSpriteManager::~cSpriteManager()
{
    std::cout << "SpriteManager: Calling Dtor.\n";
    for (unsigned int i = 1; i < Sprites.size(); i++)
        if (Sprites[i] != 0) delete Sprites[i];

    //for (unsigned int i = 1; i < Textures.size(); i++)
        //if (Textures[i] != 0) delete Textures[i];

    Textures.clear();
    Sprites.clear();
    Paths.clear();
    std::cout << "SpriteManager: Finished Dtor.\n";
}
 

Occasionally when main() ends and the above lines are not commented I get a 0xC0000005 segfault.. However commenting the lines never yields the error. The weird part about the error is that when it crashes I see both "Calling Dtor." and "Finished Dtor." which makes me believe that deleting the textures doesn't actually cause the segfault. Like I said though, commenting those two lines never ever crashes.

I'm using the latest SFML github source (2 days ago) and GCC 4.7.0. Any help in understanding the problem would be really appreciated. 

66
SFML projects / Re: SFML Light System - Let There Be Light
« on: August 03, 2012, 07:17:10 pm »
Hello everybody, I'm having some issues getting this to work. I thought maybe I wasn't setting up the world or the shapes properly so I compiled the example code. I made absolutely no modifications to it at all, and it compiles and runs, but this is what I see:

http://postimage.org/image/hh9kokr75/


This is the case with 1.5 and 1.5.1. I'm using GCC 4.7 and the latest SFML source. Any help would really be appreciated. :)

67
SFML projects / Re: TGUI: a c++ GUI for SFML (with Form Builder)
« on: July 25, 2012, 09:49:29 pm »
Hey Texus,

I don't know how easily it could be implemented, but is it possible to have animated interfaces? For example, the button could have multiple "mouse over" and "mouse leave" subimages. Mousing over a button could have 5 subimages that fade dark, etc.

68
General / Getting the Real Current Time (AM/PM)
« on: July 11, 2012, 07:12:32 pm »
Does SFML provide a way to get the current time of the system? Even if it's in seconds and can be parsed, that's fine. I figure sf::Clock probably has access to this somehow.

69
Feature requests / Re: File Downloading
« on: July 11, 2012, 04:00:21 pm »
Awesome, thanks for the quick reply Laurent. :)

70
Feature requests / File Downloading
« on: July 11, 2012, 03:47:22 am »
I searched around and couldn't find much for a way to download a file from the net. I have a very primitive HTTP download function which works, but it would be nice to be able to get the progress of the download, pause a download, et cetera. I have very little understanding about the HTTP protocol, so I apologize if this is already available through HTTP. (If so I'd really appreciate a push in the right direction in how to implement the functionality.)

Pages: 1 ... 3 4 [5]
anything