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.


Topics - Ruckamongus

Pages: [1]
1
General / Building Error With Latest Source and -std=c++11 Flag
« on: May 23, 2014, 07:34:20 am »
Hello all, I tried building the latest source with the G++ flag "-std=c++11", but it gives a compile error in src/SFML/Main/MainWin32.cpp. The error comes from:

extern int main(int argc, char* argv[]);

////////////////////////////////////////////////////////////
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, INT)
{
    return main(__argc, __argv);//Undefined reference to both of these variables.
}
 

It got me thinking... how did it compile without the C++11 flag in the first place? I tried searching the source, but couldn't find any definition of "__argc" or "__argv". Is it perhaps a WinAPI shadowing issue?

2
Graphics / Texture getMaximumSize() Return Value
« on: January 30, 2013, 03:49:49 am »
Hello folks, quick question. The value that sf::Texture::getMaximumSize() returns is maximum total pixels, or maximum pixels per dimension?

Thanks!

3
Network / Selector Status and TcpSocket Status Different
« on: November 22, 2012, 02:23:11 am »
I've got a few TcpSockets and a TcpListener in a selector. Why does this happen:

if (selector.isReady(client))
{
        // The client has sent some data, we can receive it
        std::cout << "Is ready\n";//Shows
       
        sf::Packet packet;
        int Status = client.receive(packet);
       
        std::cout << "Status: " << Status << '\n';//Displays 1, aka Socket::NotReady
        if (Status == sf::Socket::Done)
        {
                std::cout << "Message recieved!\n"; //Never happens
        }
}
 

Shouldn't these values be the same? I'm using the SocketSelector example in the SFML 2.0 documentation. I am also using the latest git snapshot of SFML. One final thing: both the listener and all TcpSockets are NOT blocking.

4
General / Can SFML press a mouse/keyboard button?
« on: November 10, 2012, 10:44:55 pm »
Title says it all, can SFML press an I/O button? For example I can control the global location of the mouse with set position, but can I have it click at a given time, etc?

Thanks!

5
General / Deciding which Container to use for a Manager Class.
« on: October 31, 2012, 01:33:56 am »
Hello all,

I'm not sure if this is the proper section; sorry if it isn't. My questions is about C++ more than SFML. Basically, I have a few different managers in my game engine (InstanceManager, SoundManager, and SpriteManager). Currently, their implementations use a vector for storage, as vectors have fast lookup time. However, I'm wondering if a different container is more appropriate. I'm using C++11 so I'm open to the newer containers as well. I'm looking for the "best" container that balances rapid lookup with quick deletion from a non-terminal end. I haven't had any formal classes on data structures or containers so I don't know the inner workings of more advanced containers. (I've written my own singly/doubly linked lists, a primitive vector class, and a queue though.)

I'm sorry if this isn't appropriate for the SFML forums, but I figured since I'm storing sf::stuff I might as well ask some more seasoned programmer their opinions.

My current managers are pretty simple, and look something like:
class SomeManager
{
     public:
          bool Add(sf::something* Address);

     private:
          std::vector<sf::something*> m_Somethings;

};
 

The use of pointers is to avoid copying and such. I know that manual memory management is frowned upon with unique pointers, but it seems unnecessary when the manager deletes everything for you anyway (in its dtor).

Would a unordered_map be a good alternative?

Thanks!

6
Graphics / How to Make a Rotatable Rect
« on: October 10, 2012, 12:44:12 am »
Hello all,

I'm wondering what would be the best way to create a rotatable rectangle? I don't want it to have a texture, or be drawable, however I do want it to have an origin (and location) and be able to retrieve it's four coordinates depending on its rotation.

For example (all psuedocode of course):
RotateRect Rect;
Rect.setSize(x1, y1, x2, y2);//x2/y2 can be width and height, it doesn't matter
Rect.setOrigin(sf::Vector2f(10, 10));
Rect.setRotation(63);
 

Now I want to be able to to get the x1, x2, y1, and y2 coordinates on runtime given it's rotation. Would it be better to create a class that does the trig-math stuff on it's own, or try to inherit from sf::Transformable? If it does inhert from sf::Transformable, how do I get the vertices' coordinates?

Again, I do not want it to be drawn, so inheriting from sf::Shape or sf::RectShape is a bit too heavy.

7
General / Per-Pixel Collision Detection
« on: September 18, 2012, 03:51:09 am »
First of all, I have ported the example over from the wiki. However, it was meant for SFML 1.6 which allowed direct access to pixel data without copying the image from the video card to memory. The ported system works, however to do a single collision it drops the FPS from 60 to 5! Of course this is not acceptable, so what would be the best way to accomplish per-pixel collision detection in SFML 2.0?

8
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))

9
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. 

10
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.

11
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]
anything