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

Pages: [1]
1
Graphics / Using SFML built-in rendering methods in another context
« on: May 07, 2015, 08:12:46 pm »
Hello,

I would like to know if it would be possible to use only the drawing methods of the SFML components ? The point is to use them in another context that an SFML window ? It's actually a raw glx window with some options like a depth and stencil buffer and some already existent drawing methods in 2D and 3D.

The point would be to draw SFML things on the top of what is already in the window (which is not my code). I've tried to create a RenderTexture but it obviously breaks everything (black screen and GL error, oops), because I guess it tempers with gl states and nothing can be drawn.

Could you help me ?
Thanks !

2
Audio / SoundStream for real-time audio
« on: May 01, 2015, 03:02:19 pm »
Hello,

In my project I need to be able to play "real time" sound (approx. 1100 samples per frame, at approx. 30fps). I tried the SoundStream class you provide ; it works, but the onGetData is not fast enough because I need to create a fifo queue and push/pop my samples while waiting for the stream to require them. The result is a late audio compared to the video (it's supposed to be syncd) ; from time to time there is a little throttle and it gets late, the more I play the more it's late.

So here is my question : how could I fix that ? I think that I need to edit SoundStream to make it a push-based system instead of a pull-based. Instead of requiring the chunks every times needed, it lets me fill the buffers on my own (at each frame). There would be no more need for a fifo queue and I think it would be fast enough and more synchronized.

Could you help me ?

Thanks !

3
Hello,

I'm using VideoMode::getFullscreenModes() to get the best fullscreen videomode for my game, but I don't really know what is the proper way to draw my things, knowing the window size.

Let's take an example : I want to draw a bar at the top of the screen, with some text at its left, middle and right. It takes the whole screen width. On my screen, I decided that a 30px height and 16px font was fine, buuuut... on some screens, it may be too large and on some screens it may be too small (the goal is to target a TV, so obviously 30px is ridiculous).

So my question is : what is the proper way to adapt this ? Should I pick a standard resolution and scale to it, and adding black bars ? Or scaling each UI component ? But how ?

Thanks ^^

4
System / Xbox 360 controller left and right triggers
« on: April 09, 2015, 09:14:28 am »
Hello,

I'm trying to use a wired Xbox 360 controller with SFML (on Linux) ; everything works perfectly (the 11 buttons + the dpad + the two joysticks) except that the left and right triggers are not recognized as buttons, so... I don't know how to use them.

Am I doing it wrong, is there a special way to use them or should I use another thing such as XInput or xboxdrv ?

Thanks !

5
Graphics / Convert from one pixel format to another
« on: April 03, 2015, 05:55:56 pm »
Hello,

I've been annoying you with this issue on the IRC Chat, I'll continue here instead, I find it more practical for me and more people might help.

So here is the deal : I am trying to create a tiny libretro frontend using SFML, which point is to eventually run on a Raspberry Pi. I have an emulation core which gives me every frame the image that I'm supposed to display. The thing is that the pixel format is not the same as the one SFML's using.

libretro can support several emulation consoles, which can use three different pixel formats. For now I'll just focus on one : RGB565.

The core provides me, every frame, an uint16_t * containing the pixels this way : { rrrrrggggggbbbbb, rrrrrggggggbbbbb, rrrrrggggggbbbbb, etc...}.

On the other hand, SFML requires an RGBA8888 format, plus a weird uint8_t * array disposition : {rrrrrrrr, gggggggg, bbbbbbbb, aaaaaaaa, rrrrrrrr, gggggggg, bbbbbbbb, aaaaaaaa, rrrrrrrr, gggggggg, bbbbbbbb, aaaaaaaa, etc...}.

On the IRC we eventually came to a working method to convert each pixel to three uint8_t containing the red, green and blue channels (well, I think it works).

Here is the snippet I have - pixelsBuffer is the final array containing the pixels to be displayed, and videoRefreshCallback is the function called every frame to update pixelsBuffer :

//The final pixels buffer (the size is fixed for now), which should be RGBA8888
uint8_t pixelsBuffer[229376];

void videoRefreshCallback(const void *data, unsigned width, unsigned height, size_t pitch)
{
    uint16_t * pixels = (uint16_t *) data; //the uint16_t array of RGB565 pixels

    for (int y = 0; y < height; y++)
    {
        for (int x = 0; x < width; x++)
        {
            uint16_t actualPixel = pixels[(pitch*y)/2 + x];

            uint8_t r = (actualPixel >> 8) & 0xF8;
            uint8_t g = (actualPixel >> 3) & 0xFC;
            uint8_t b = (actualPixel) << 3;

            pixelsBuffer[?] = r;
            pixelsBuffer[? * 4 + 1] = g;
            pixelsBuffer[? * 4 + 2] = b;
            pixelsBuffer[? * 4 + 3] = 0xFF;
        }
    }

    gameTexture.update(pixelsBuffer, width, height, 0, 0); //we update the texture drawn in the main loop
}
 

Okay, so the pixel conversion works here (I guess), but I don't really know how to put them in pixelsBuffer (where the ? are).

Could you help me ? I also have few other questions :
  • isn't there a more optimized solution to do this ? i think the double-loop solution is heavy, it's supposed to run on a Raspberry and I might need to implement some more high-qualities consoles (with more pixels to process each frame)
  • wouldn't be more easy to extend SFML to support more pixels formats ? I looked at the Texture::update() code, and I think we can change GL_ARGB to pretty much every format supported by GL (RGB565 included), but this doesn't solve the array format problem, switching from one array of pixels (one entry per pixel) to one array of pixel colors (3 or 4 entry per pixel, depending on the alpha channel)

Thanks a lot !

6
General / Using SFML with a Raspberry Pi 2 B ?
« on: April 01, 2015, 05:36:03 pm »
Hello,

I am actually testing some librairies for a small project, its point is to be running on a Raspberry Pi (Model 2B). I am actually testing SDL2, and I'm not very found of it (I think it's too scattered, it goes in all directions I hate it). I heard of SFML, and I think I might really like it, but before actually testing it I must be sure it'll work properly on the Raspberry.

I don't own the beast yet, it will be shipped within 1/2 weeks. Do you think SFML will work properly on it, with graphics working and fast enough to run a fluent 2D game on a HD TV ?

Thanks !

Pages: [1]
anything