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

Pages: 1 2 [3] 4
31
General / Problems redirecting sf::err() in another language.
« on: August 20, 2013, 07:24:57 pm »
I'm working on a modified version of CSFML to use for my binding, and one of the things I wanted to be able to do was to get the text inside sf::err() and send it to D. I did some experiments with redirecting sf::err() to a ostringstream, and then getting the text from that when I know something had been written to sf::err(). This actually works, until SFML writes to sf::err() internally. At that point, the redirection I did earlier doesn't seem to apply anymore. Is there something I'm missing?

I'm not sure how much this will help, but here's some code to explain what I mean.

Err.cpp(added to my modified CSFML):
//Headers
#include <SFML/System/Err.h>
#include <SFML/System/Err.hpp>
#include <sstream>
#include <string>

namespace
{
    std::ostringstream outputStream;//stream sf::err() get's redirected to
    std::string outputString;//string for storing output
}

void sfErr_redirect(void)
{
    //redirect sf::err() to write to outputStream
    sf::err().rdbuf(outputStream.rdbuf());
}

const char* sfErr_getOutput(void)
{
    //get the contents of outputstream
    outputString = outputStream.str();

    //and then clear the stream
    outputStream.str("");

    return outputString.c_str();
}
//test function to make sure sf::err() has been redirected correctly
void sfErr_writeTo(const char* text)
{
        sf::err() << text << std::endl;
}


This code in D works as expected(nothing is written to the console):
void main(string[] args)
{
        sfErr_redirect();
        sfErr_writeTo("Writting some text to sf::err() from D!");
}

This D code also works as expected(grabs the contents and outputs it to the console):
void main(string[] args)
{
        sfErr_redirect();
        sfErr_writeTo("Writting some text to sf::err() from D!");
        writeln(text(sfErr_getOutput()));
}

However, like I said above, something that uses sf::err() internally seems to ignore the redirect. This shouldn't write anything to the console, but it does(says it failed to load the font face):
void main(string[] args)
{
        sfErr_redirect();

        Font font = new Font();
        if(!font.loadFromFile("fontThatDoesntExist.ttf"))
        {
                return;
        }
}

SFML seems to have its own version of sf::err() separate from the one I am accessing. The following code tells me that it failed to load the font face, but the code I personally write to sf::err() does get redirected:
void main(string[] args)
{
        sfErr_redirect();

        Font font = new Font();
        if(!font.loadFromFile("fontThatDoesntExist.ttf"))
        {
                sfErr_writeTo("Writting some text to sf::err() from D!");
                return;
        }
}

I thought I was on to something, but now I'm at a loss. Any suggestions for how I can proceed with this?

32
SFML game jam / SFML Game Jam Time info
« on: August 08, 2013, 06:28:25 am »
Hey guys,

Out of all the things we should decide on for the next jam, I feel like when the next jam should be is the most important thing to decide as soon as possible. On the same lines, we can also talk about how often we should have the event.

Currently, I'm thinking every 4 months, which would put the next jam in December.

33
SFML game jam / Welcome to the SFML Game Jam Forums!
« on: August 06, 2013, 09:06:52 pm »
Laurent generously provided this forum for all threads related to the SFML Game Jams so that we don't have to start threads in the General section anymore. I think they(the jams) are only going to get bigger, so I think it makes sense for us to have a place just for this stuff.

Feel free to post about anything regarding past and future jams!

Now that the first one is over, we can take the time to really make the SFML Game Jam a great event. :)

34
General discussions / SFML Game Jam Submissions!
« on: August 04, 2013, 12:12:35 am »
We are almost half way through the game jam, so I thought it was a good time to open up the submission thread.

Feel free to talk about the jam in this thread, but please use this one only for submissions to the jam itself.

Awesome job so far everyone! Keep up the good work!

35
General discussions / SFML Game Jam Begins!
« on: August 02, 2013, 05:08:07 pm »
The SFML Game Jam has now begun!

Good luck everyone and have fun!

36
General discussions / SFML Game Jam Theme Announcement!
« on: August 02, 2013, 04:03:46 pm »
The top 5 themes as voted by everyone were:

Game-ize an Algorithm

Lights and Shadows

Survival

Roguelike

Multitasking


But there can only be one!


And the theme of the game jam is....

Lights and Shadows!

37
General discussions / SFML Game Jam 1 Theme Submission Thread
« on: July 19, 2013, 11:58:32 pm »
Please use this thread to submit your ideas for a possible theme for the first SFML Game Jam.

So far(from the other thread) we have:

  • Classic games combined
  • Non-traditional geometry
  • Two rights (don't) make a wrong

Get creative! One week from now I will compile a list of every theme idea, and set up a way for everyone to vote on their favorite ones. Serious theme ideas only please. :P

38
General discussions / SFML Game Jam
« on: July 17, 2013, 07:51:58 am »
I was thinking today that it might be pretty cool to have some sort of SFML Game Jam. While I don't have time to put anything like this together, I was wondering what other people would think of something like this.

Having some kind of sanctioned SFML Game Jam could also help to increase awareness for SFML, which is great.

Thoughts? Ideas?

39
C / Question about sfTcpListener_accept
« on: June 30, 2013, 08:54:36 am »
I noticed this a while ago, but thought there must be a reason for it so I never asked, but I have a question about sfTcpListener_accept since I was doing some binding related work when and reminded myself about it.

Anyways, let's take a quick look at this guy.
sfSocketStatus sfTcpListener_accept(sfTcpListener* listener, sfTcpSocket** connected)
{
    CSFML_CHECK_RETURN(listener, sfSocketError);
    CSFML_CHECK_RETURN(connected, sfSocketError);

    *connected = new sfTcpSocket;
    return static_cast<sfSocketStatus>(listener->This.accept((*connected)->This));
}

Is there any reason we give this function the address of the pointer instead of just the pointer itself?
And wouldn't this do the exact same thing?

sfSocketStatus sfTcpListener_accept(sfTcpListener* listener, sfTcpSocket* connected)
{
    CSFML_CHECK_RETURN(listener, sfSocketError);
    CSFML_CHECK_RETURN(connected, sfSocketError);

    connected = new sfTcpSocket;
    return static_cast<sfSocketStatus>(listener->This.accept(connected->This));
}

I'm just curious about what the difference is.

40
Feature requests / VideoMode method to find native Resolution
« on: June 03, 2013, 11:57:51 pm »
I was thinking that it could be very handy to know the native resolution of the user's monitor. I would like to request a method(presumably for VideoMode) that returns a Vector2u with the native resolution.

I didn't see anything related to this when I did a search, so I'm guessing there hasn't been a lot/any request for this previously?

41
I'm not sure if this was intentional or not, and I don't know how I have missed this until now, but I feel like there is a naming inconsistency with how Music's loading methods are named.

Everything I checked in the graphical module, plus even the SoundBuffer class' loading methods are named loadFromXXX, but only Music's methods are named openFromXXX.

Not that it really matters or has any kind of serious impact. I was just curious!


42
D / Candidate for new official DSFML
« on: March 25, 2013, 05:16:35 pm »
Hey all!

A while back I became very interested in the D programming language and had already fallen in love with SFML, but when I looked into it there didn't seem to be much support. Unfortunately, deadalnix's repo for a DSFML seems to not have had much work done on it in about a year and I think we deserve a good D binding. I wrote this(https://github.com/Jebbs/DSFML) from scratch, and I think I did a pretty good job of making it work well and as if it was an actual D API. There are definitely some parts that could use improvement, but I plan on doing active development to make sure everything is up to date and that the binding continues to improve overall! Hopefully I didn't jump the gun on giving it the name DSFML!

It's very similar to krzat's binding in a lot of ways, so if you were able to get his working then the same process will apply to mine for the most part. Things my binding feature are lot's of code compatibility with the C++ API, overloaded operators for many things, and a general avoidance of pointers in favor of built in D types. I also wrote some code to make Drawable inheritance possible and only have the need to write the draw code once and still it work with a RenderTexture and a RenderWindow. More cool updates/improvements to follow!

In any case, let me know what you guys think! This is my first project I have ever had done that other people would use. The very next things I want to work on for the binding are getting it up to date and then writing some tutorials, which I will do soon, but I wanted to finally release something for others to see!

43
C / user data variable in sfInputStream
« on: March 07, 2013, 07:13:36 pm »
I've been looking through a bunch of source code regarding sfInputStreams today and I couldn't seem to find anywhere the void* userData actually get's used other than inside CallbackStream. I'm just curious what it is used for and what "user data" get's assigned to it. Or what I should be assigning to it when using sfInputStream. I was thinking that it could be used to store the current contents on the stream, but I wasn't completely sure.

Thanks!

44
C / Odd sfVideoMode_getFullscreenModes issue
« on: February 08, 2013, 07:32:05 am »
I'm having an interesting problem when I call sfVideoMode_getFullscreenModes. The number of modes it tells me I have is absurdly high, but only 9 seem to have any valid information. I am using the current version of CSFML, but I am using the library in D though I doubt that would make much of a difference.

Here is an example program I wrote:
void main(string[] args)
{
        sfVideoMode* modes;
        size_t count;
        int size = sfVideoMode.sizeof;

        modes = sfVideoMode_getFullscreenModes(&count);
        writeln("Number of fullscreen modes: ",count);
        writeln();

        for(int i = 0; i<count; i++)
        {
                try
                {
                        sfVideoMode temp = modes[i*size];
                       
                        writeln("VideoMode number ", i+1);
                        writeln(VideoModeAsString(temp));
                        writeln();
                }
                catch
                {

                }
        }
}

string VideoModeAsString(sfVideoMode videoMode)
{
        return "Width: " ~ text(videoMode.width) ~
                   " Height: " ~ text(videoMode.height) ~
                   " Bits per pixel: " ~ text(videoMode.bitsPerPixel);
}
 

If I don't include the try/catch blocks the program throws a runtime error after the 9th video mode. Anyways, here is what the program outputs for me.

Quote
Number of fullscreen modes: 57

VideoMode number 1
Width: 1920 Height: 1080 Bits per pixel: 32

VideoMode number 2
Width: 1280 Height: 720 Bits per pixel: 32

VideoMode number 3
Width: 1366 Height: 768 Bits per pixel: 16

VideoMode number 4
Width: 720 Height: 480 Bits per pixel: 16

VideoMode number 5
Width: 1280 Height: 800 Bits per pixel: 8

VideoMode number 6
Width: 0 Height: 0 Bits per pixel: 0

VideoMode number 7
Width: 0 Height: 0 Bits per pixel: 0

VideoMode number 8
Width: 0 Height: 0 Bits per pixel: 0

VideoMode number 9
Width: 1305645974 Height: 50482155 Bits per pixel: 6357136


I'm not sure what exactly is going on, but  I also want to point out that the very last video mode that I get's written to the console has changing values.  My guess I'll probably be ok if I stop when I get to a {0,0,0} videomode. I don't know if this happens on anyone else's system, but I just thought I would bring this to Laurent's attention.

45
C / Finding the size of things!
« on: December 08, 2012, 10:31:54 am »
Hey guys,

In the various createFromMemory functions, one of the parameters is the size of the object in bytes. How would one go about finding the size of the object so that they could enter in the correct size to use these functions?

Thanks!

Pages: 1 2 [3] 4
anything