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

Pages: [1]
1
Graphics / Conversion from SFML angles to radians [SOLVED]
« on: June 21, 2014, 06:20:29 pm »
Greetings.

When designing things making use of angles - movement, for example - I generally use radians now, as the underlying mechanism, though I may specify initial angles in degrees, as I still find them easier to picture (for example, 1 degree is much more clear to me than the radian equivalent). This works well as the trig functions generally takes radians.

SFML, however, does not.

Due to this, I was trying to convert to and from these different units.

In detail. Radians starting on the positive x axis, counted counterclockwise. SFML degrees, it seems, start on the positive y axis, and are counted clockwise.

I imagine this may be of use to future searches for the same thing.

I seem to have inconsistent success with the functions.

What math would be required for each?

2
Feature requests / float, float for ctors or setSize
« on: January 06, 2014, 08:40:46 pm »
Greetings. This isn't so much a feature request as an idea for slight convenience.

Let's take RectangleShape as an example, though it isn't the only thing. The ctor takes sf::Vector2f, as does setSize. However, others - position, origin, scale, etc - also take two floats. For lazy people like myself, such methods are nice. Is there a reason the setSize* don't have it?

On another note, I recently added a fullscreen option for something. To check if it was, I had to get the fullscreen modes from VideoMode, then compare it. I feel there must be a better way. Should Window have a getStyle?

3
Network / List of std::pair<sf::TcpSocket, std::mutex> (Solved)
« on: January 01, 2014, 07:24:44 pm »
Greetings. Now, like others, I plan to have a list active connections.

Like others, I ran into the copying problem. To prevent the socket from being copied, I can use a unique_ptr. The problem is, I cannot figure out how to make this work with an std::pair. It needs to be constructed by either moving or copying, and I cannot do either. Currently I was attempting this:

    sockets.push_back(std::make_unique<std::pair<sf::TcpSocket, std::mutex>>(sf::TcpSocket(), std::mutex()));

The mutex was my attempt at making it threadsafe. I plan to, for each client, have a blocking receiver in it's own thread. While this is going on, whenever I want to send a message, I would do it via the same connection. I don't know whether or not that works at the same time.

4
General / Statically linking SFML (Solved)
« on: December 30, 2013, 11:55:41 pm »
Greetings.

So, since I am terrible at distributing things properly, I was going to try linking statically again (that is, not using DLL's for the standard library, though this also means linking SFML statically).

It seems, though, that a change has occurred, as detailed here:

http://en.sfml-dev.org/forums/index.php?topic=9362.0

As I read it now, you need to link the various dependencies (as listed on the licenses page) when linking statically. Is this correct? Any other needed steps?

If so, is there a prebuilt version of libjpeg somewhere? I am having issues with it, and it's information and documentation seem to be rather outdated.

5
General / Running into seemingly random error in SFML code
« on: October 24, 2013, 04:41:17 am »
Greetings. So, go back a week ago. I was doing fine using VS 2012 with SFML.

Around this time, I got an odd error: while loading the font, is crashed. This after it had worked for weeks previous. I relinked everything, and it somehow worked.

It got me thinking, though: it would be useful to have the debug files on SFML, so I can step into it, as I would often like to. So, I was going to try building it again, to get said files.

All seemed well, and the pdb files DID work, but... it kept crashing there.

Not making any headway, I switched back. Until today, when I needed some variadic templates, which requires 2013. It gave me the same error while loading the font. I tried rebuilding it again, this time using 2013, with the same result.

It occurs when calling font.loadFromFile. Near the start of that is cleanup(). On the last line of cleanup - clearing the pixel buffer (of size 0), it... breaks.



Yes, this is my fourth attempt at making a snake clone :(. I was searching the memory locations - VS has some magic numbers it marks them with - but didn't find anything.

Any idea of the problem? It was suggested to me to make a minimal working example. In that test (same libraries and everything), it loaded the font fine, but died when I tried to draw it.


6
Graphics / Tilemap drawing breaks with different tile sizes
« on: October 17, 2013, 04:42:14 am »
Greetings. So, I made this little this that renders tiles. It looks like this:



So far, so good. But I wanted to have tiles bigger than 32x32. Or a different size,anyway. This gave me this:



The tree texture is 32x64. It has three leaf tiers: what you see is the top half.

Here is the drawing code:

static sf::Sprite sprite;

        for (int x = 0; x < world.getSize().x; ++x)
                for (int y = 0; y < world.getSize().y; ++y)
                {
                        sprite.setTexture(getTextureForType(world.getFirstLayer(x, y), resource, sf::Vector2i(x, y)));

                        sprite.setPosition(x*32, (target.getSize().y - (y*32 + 32)) - (sprite.getTexture()->getSize().y - 32));

                        target.draw(sprite);
                }

        for (int x = 0; x < world.getSize().x; ++x)
                for (int y = 0; y < world.getSize().y; ++y)
                {
                        sprite.setTexture(getTextureForType(world.getSecondLayer(x, y), resource, sf::Vector2i(x, y)));

                        sprite.setPosition(x*32, (target.getSize().y - (y*32 + 32)) - (sprite.getTexture()->getSize().y - 32));

                        target.draw(sprite);
                }

The first layer is things like the ground, second is trees, etc.

But, if I comment the first loop, I get this:



When I, between the loops, add:

    sprite.setTextureRect(sf::IntRect(0, 0, 32, 64));

I get this:



Note this is drawn multiple times, which is why (presumably) the ground is distorted like that.

What is going on here? I cannot figure it out. Also, I reverse the y coordinates of the tiles, so when generating, y + 1 is up the screen, not down.

A while back, I saw a thread stating that sprites are not a drawing tool. For example, a sprite should always be a spaceship, not switching between tiles. If need be, I can try that (one sprite per tile), but I am still curious.

Or perhaps a tilesheet, but I am yet to discover a good way to load them easily, and editing them in the past didn't work well for me.


EDIT: I was checking SFML's source, and apparently setTexture has a parameter to reset the rectangle. When I pass true for this, it seems to work correctly.

I am still interested in best practice for tilemaps, though.

7
Graphics / [Solved] View only moves once
« on: June 29, 2013, 04:20:11 pm »
Greetings. Well, I basically have something that draws a 2D array of colored squares. Easy enough, and that part works. I wanted it to scroll, however, as I plan for the random generation to be much wider than a single screen.

        view.move(100, 0);

        std::cout << view.getCenter().x << "\n";

        window.setView(view);

        drawWorld(world);

        std::cout << window.getView().getCenter().x << "\n";

Simple enough. Now, according to the debug lines, the window does have the same view as what it was set to. The view's center does move.



That is what it looks like. It started with the gradient in full view. The black space shows that the view moved. Changing the value (From 100) leaves different amounts of black space. However, it always looks like in the picture. It doesn't scroll.

What am I missing?

Also, the view (and the window) are members of a class, and the view is initialized like so, in the constructor:

view.reset(sf::FloatRect(0, 0, window.getSize().x, window.getSize().y));
               
view.setViewport(sf::FloatRect(0, 0, 1, 1));
[code]

8
Window / Error on window declaration
« on: June 02, 2013, 02:47:56 am »
Greetings. Anyway...yup. Another problem.

If I use a window in a function (local), it works fine. However, when I made a global container, with it as a static member, its declaration (in the cpp), it threw an exception:

Unhandled exception at 0x772222B2 (ntdll.dll) in BlockScreensaver.exe: 0xC0000005: Access violation writing location 0x00000004.

http://pastebin.com/9gZVpxn2

^the two files related to this. Anyway, it throws on the cpp, on the declaration of the window.

Any ideas?

9
General / Building SFML 2.0-rc for use with VS2012
« on: March 15, 2013, 09:46:29 pm »
Greetings. I switched IDEs, and after trying out JSFML, I figured knowing how to build things will be useful in the future, such as if I ever try a Linux distribution.

Anyway, I am now using Visual Studio (I don't need to hear whether or not it sucks). In this case, 2012, which apparently is actually version 11. Anyway,  the RC had libs for 2010, but I got the different versions of it error. So, I was on a quest to build it.

After downloading the snapshot from the download page (with the source), and followed the tutorial for 2.0 using cmake. I made a Visual Studio Win64 project (on 64-bit system). I was able to  build it in Release and Debug, which generated the debug and non-debug DLLS, as well as the static dll-initializing/loading libraries (without the s).

But there were no static builds. I asked around, and I heard there were supposed to be other build options, namely Debug-Static and Release-Static, but they are not listed in VS2012 in build -> configuration manager -> active solution configeration. Listed is Release, Debug, MinSizeRel and RelWithDebInfo.

How can I make the static libraries? I don't think this would make a difference according to the wording of the tutorial, but CMAKE_BUILD_OPTION was Release.

10
Java / Attempt running jsfml-test.jar, UnsatisfiedLinkError
« on: March 11, 2013, 01:42:41 am »
Greetings. Was going to try using JSFML... I ran the test, though, (jsfml-test.jar), and got an UnsatisfiedLinkError:

Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Users\Kids\.jsfml\windows_x64\sfml-system-2.dll: Can't find dependent libraries
   at java.lang.ClassLoader$NativeLibrary.load(Native Method)
   at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1939)
   at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1864)
   at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1825)
   at java.lang.Runtime.load0(Runtime.java:792)
   at java.lang.System.load(System.java:1059)
   at org.jsfml.internal.SFMLNative.loadNativeLibraries(Unknown Source)
   at org.jsfml.window.VideoMode.<clinit>(Unknown Source)
   at pong.Main.main(Main.java:11)

Note: this is the same error I get when I use jsfml.jar in a normal project in Netbeans, which is where the last live above comes from.

It cannot find the DLLS. At first, I couldn't either. I looked for the C++ DLLS, and tried putting them in the running directory, to no avail. On the wiki I found, it unpacks them to user/.jsfml. I found them there, tried copying them to the current directories, and again, to no avail.

It says it automatically unpacks them... but nothing is running, here. I feel like I am missing something obvious, though.

Any ideas?

11
Network / Odd Error with TcpSocket and HTTP
« on: January 13, 2013, 11:12:14 pm »
Greetings. After I discovered port forwarding, I decided to try to make my own server, for testing web things. This would be able to, unlike free hosts, offer more freedom, for obvious reasons, such as server-side scripting. Not to mention, I can learn a bunch - say, POP or HTTP and networking things - side by side with networking through the server for games and experimenting with HTML5 and such things.

Anyway, As I was testing the port forwarding, I was able to receive the HTTP requests fine, and regardless of what it said, I sent a test response back, with a rather basic page.

I am guessing my HTTP is pretty bad, but I DID manage to get something. IT appeared as though the browser decided to display everything I said it, as simple as possible. It did display the <p> element correctly. It read:

Quote
Some paragraph here...

Failed to set socket option "TCP_NODELAY" ; all your TCP packets will be bufferedFailed to enable broadcast on UDP socketCannot send data over the network (no data to send)Cannot receive data from the network (the destination buffer is invalid)vector::_M_fill_insertFailed to bind listener socket to port Failed to listen to port Failed to accept a new connection, the socket is not listening255.255.255.255www.sfml-dev.org/ip-provider.php˜6@Â6@Â6@Â6@Â6@Â6@Â6@Â6@Â6@Â6@Â6@Â6@Â6@Â6@Â6@Â6@Â6@´6@Ÿ6@¦6@Â6@Â6@»6@Â6@Â6@­6@vector::_M_fill_insert/GETPOSTHEAD HTTP/. : http/http://https://Fromuser@sfml-dev.orgUser-Agentlibsfml-network/2.xHostContent-LengthContent-Typeapplication/x-www-form-urlencodedConnectionclose$tI

Some paragraph here was my example <p> text, and is not actually another paragraph of relative information. AnywayI don't know where this content comes from, but I assume, somehow, SFML added this on, although I thought the error log normally redirected to the console, (like with a 0x0 texture). So I am pretty lost, but I don't think this is my doing. Anyway, my guess is, this message gets tacked in there with any HTTP/HTML, and so the browser is rather confused, and so making a proper server is a bit impossible till I fix this giberish. All I can assume is that it is an SFML sockets issue.

Not quite sure how to correctly format code in here, sorry.



int main()
{
    sf::TcpSocket socket;

    sf::TcpListener listener;

    listener.listen(11111);

    while (true)
    {
        if (listener.accept(socket) == sf::Socket::Done)
        {
            std::cout << "Connection!\n";

            socket.setBlocking(true);

            char buffer[1000];

            sf::IpAddress other;

            std::size_t t;

            socket.receive(buffer, sizeof(buffer), t);

            std::cout << buffer;

            socket.send("HTTP 1.1 200 OK\n\rConnection: close"
                              "\n\r\n\r"
                              "<!DOCTYPE html><html><head><title>TestPage</title>"
                              "</head><body style = \"background-color: lightblue;\" >"
                              "<p>Some paragraph here...</p></body></html>\r\n"
                              , 1000);
        }

        sf::sleep(sf::seconds(0.01));

    }

    std::cin.get();
}


This with including SFML/Network and iostream, as well as linking with the SFML libs. I used Firefox and typed in the URL bar my external ip followed by :11111 (this rather than 80). I don't think it is a browser issue, though, because chrome displays about the same thing, although is gets the style = "background-color: lightblue" part correct as well.


Thanks if you can help.

EDIT: SFML2-rc from... a few months back. Might be useful information.

12
Graphics / SFML 2 views
« on: August 09, 2012, 12:11:02 am »
Greeting all. Learned much in both C++ and SFML since I have been here last. My current project, though, would be much easier with views.

However, even after the doc and a tuturial I found regarding it (there was a forum post on here about it), and some attempts myself, I am very befuddled. In the game engine I had used previously, views were still a bit confusing at times, but simply consisted of variables like width/height of the view/viewport, and something along the lines of position. (top left corner, that is).

SFML views, though, have got me confused. So, I suppose, I can try to explain what I want to do.

What I want to do is, make the view the same size as the rendering region (and same for the viewport, but that is default). I then want this view to continue moving southEast-ish - that is, down and right - to follow a slope. Simply enough, you would think. At first, I first made it as simply sf::View view, and so center was 500/500. I later re-set the center, (as view height/2, view width/2) and this was better. (previously, a line that started at 0,0 was near the right of the screen, still at the top, when it should have been the top left - the view was somehow shifted right), but now looked as expected. Anyhow, this slope of mine is randomly generated. as such, if you use set incriments, you may either end up to far above, or to below, the slope. However, the camera will actually follow the player. I may impliment adding a zoom so the slope always stays in few, we shall see. Anyhow, currently (due to 'dropoffs" in the slope), I make it so if the view is further down then the highest point currently in view (more or less - technically, it is a point that was the highest when the last highest goes out of view), so when the player goes out of view, I can kill them and it isn't so ugly.

When I added this, though, the lines were there one second and gone the next. The y position went from 300.2 to -299.8, causing it to go out of view, I beleive. I just have no idea why. This prompted me to make this point - I figure things will all be easier if I understand just how allthe aspects of views work as they are implimented in SFML, specifically how the center works - what is it set relative to? How does it affect transformations?

So I suppose I am asking if somebody can go over each aspect of views and explain quite how they work, with emphasis on coordinates and the center.

I realize that is a bit general, but I feel it would all be useful information on a concept that, if the tuturial is any indication, and my own confusion at the lack in the documentation (setCenter is "set the center of the view", a fact I understand from the name but I don't really know exactly what that does, for exactly what it is relative from?)

Thanks if you can help clear this up for me at all.

13
General / More Problems...
« on: June 12, 2012, 08:22:18 pm »
Greetings all. A while back, I came here trying SFML as my first library, and had extensive troubles getting it to work (dynamically), but finally got it with help. Then , I tried it using a new computer, and it doesn't work anymore.

I  am using Code::Blocks with MinGW.

I made a new, empty project.

I went to project > properties, then set it to a GUI application for both debug and release.

I went to project > build options, search directories, and added the SFML/include folder for compiler, andlib for linker.

I went to other linker options, and had -lsfml-window, -lsfml-graphics, -lsfml-system. Although, I got the same results linking the respective libraries in that order the other way, both tried seperately.

I put those dlls (window, graphics, and system) - the plain .a versions of the libraries, as I was doing it dynamically.

Made some test code, included the libraries, with system first and the others following (I switched them to see if that was the problem but it wasn't). At first I screwed up but then I recalled you need the .hpp. Hrm.

I ran it, and get this error: The program cannot start because sfml-graphics-2.dll is missing. Try reinstalling...

etc. Anyhow, far as I know, backed up by searching in /lib, such a library does not exists. I tried removing the #include for the graphics mudle, and it jumped to system, so it does not seem to be a specific one. It seems as though it is quite similar to the problem whenyou don'tput the libraries next to the .exe, but I did. (In bin/debug/ , I think.)

Any ideas how to fix this? I feel like it is simple, but cannot find an answer. Searching the internet seemed to mention something about this occuring because you weren't using the debug libraries, but experimentation with this also proved to be inconclusive. They also mentioned Visual, so mabye that is why.

Can anybody offer me some guidance on how to fix this?

14
Greetings, all.

Longer stories short, I know C++ - sort of - but have never been able to get external libraries to work yet - and the console just isn't quite that good for making games. So, I decided to give SFML a try.

As I expected, it did not work. Quite likely my fault. Anyhow. So, I followed the tuturial on the wiki - or mabye the main site - on hot to link to it, etc with code blocks and mingw for 1.6.

In Global compiler settings, search directories, compiler I got the SFML include folder, and in linker the lib folder.

So far, so good.

Linking libraries themselves has always been my problem, it seems. SinceI have no idea how to use SFML at all, I decided to just try ti include the system library. Still in global compiler options (you could do it per project in project build options though) and then linker options (Or wherever the ability to link specific libraries is) and then the other linker options boxs, I added "-lsfml-system". I took the code on the wiki (uses some clock function) and tried to run it. The console came up, but I got an error popup, something about...

"This application has failed to start because sfml-system.dll was not found. Re-installing the application may fix the problem."

Note that I am using the toolchain exutables, etc from the minggw gcc thing on the wiki.

I tried adding several prefixes -  -d, -s, -s-d, all the same error. I also tried the SFML_DYNAMIC link, although I am not entirely certain how I will be linking them... the idea of static seems nice - just one exutable, not a folder with it, etc - but it seems dynamic is the prefered method. Ideas on that Either way, I cannot seem to get it to work.

I think I will, unless you have recomendations otherwise, try to link dynamically.

Any ideas how I can get past this?

Thanks.

Pages: [1]
anything