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

Pages: [1]
General discussions / Re: Unofficial Nightly Builds
« on: January 21, 2013, 08:33:27 am »
I'm glad, my Nightly Builds are of use for you guys.
Good luck with your projects! :)

You don't want to live through this.
I followed the tutorial and compiled SFML 2.0 myself for MinGW GCC 4.7.
Everything went fine until I tested the exe.
Program crashed at random points. Rebuilds without any code/settings change removed some crashes.
In the end I noticed that there were some .o files compiled by gcc 4.4.
Dumped it, compiled the whole project and still got a crash.
When I loaded a picture the program printed all kinds of japanese characters on the console.
Figured out, I somehow didn't build SFML 2.0 right ... found this thread and was saved by a hero !

Your builds are god !

Graphics / Re: [SFML 2.0] Simple color changing frag-shader does not work
« on: October 14, 2012, 10:54:39 pm »
I'm not sure if it's the proper way to do it, but here's how I do it. (at least it works ^^ )

Add to your cpp Frag.setParameter("texture", sf::Shader::CurrentTexture);
Add to your your fragment shader uniform sampler2D texture;
and use vec4 pixel = gl_Color * texture2D(texture, gl_TexCoord[0].st);

Thanks a lot ! It's working !
Thanks for taking a look, makes me glad you took the time = )

But still I'm quite curious about a method without using an access to the texture.
I mean if :
void main()
   gl_FragColor = gl_Color;
is actually what the standard pipeline of OpenGL does, than there must be data flowing, which represents the sprites vertex color ?

I think when applying the shader to the sprite, the shader does only retrieve the pixels behind the sprite, which is indeed the white background drawn with
App.clear() (therefor the pure white pixels I received in the shader)

I'll keep this question here for some time, because it's SFML related, but I think I might visit some OpenGL forums for more information about it ...

It sets the current Texture (the one used by the sprite) and gets the color of the current pixel.

I thought only techniques like bump-mapping or effects on textures itself would require such a method.

Graphics / Re: [SFML 2.0] Simple color changing frag-shader does not work
« on: October 14, 2012, 04:52:13 pm »
It means that no color is pure white.

Try to add a small offset (remember that floating point numbers are sometimes not exact), like comparing to 0.99 instead of 1.

I can understand that, but this time I changed the whole condition to test if the pixel is pure white and the shader always detects only pure white pixels. (meaning it goes all blue)

if (pixel.r == 1.0 && pixel.g == 1.0 && pixel.b == 1.0)
                pixel = off_bit;
(off_bit == sf::Color::Blue -> every pixel in the frag shader is pure white?)

I also tried it with the vertex shader but it doesn't help.
It would be great if someone could take a quick look into my code.

[attachment deleted by admin]

Graphics / Re: [SFML 2.0] Simple color changing frag-shader does not work
« on: October 14, 2012, 03:40:24 am »
So if I want to replace every color(but white) with a certain color the following would be valid ?

vec4 pixel = gl_Color;
if (pixel.r < 1.0 || pixel.g < 1.0 || pixel.b < 1.0) // all non-white pixels are replaced ?
        pixel = on_bit;
        pixel = off_bit;
gl_FragColor = pixel;

While changing the code to
m_ShaderContainer[SHADER_1BPP].setParameter("on_bit", sf::Color::Black);

The sprite goes all blue, indicating gl_Color is always blank ?

Graphics / [SFML 2.0] Simple color changing frag-shader does not work
« on: October 13, 2012, 07:49:56 pm »

I would like to change the color palette as an effect.
So I could replace all colors with just two different colors, so basically changing the color depth to 1 bit.
I decided to use the fragment shader :

uniform vec4 on_bit;
uniform vec4 off_bit;

void main()
        vec4 pixel = gl_Color;
        if (pixel.r < 255 || pixel.g < 255 || pixel.b < 255)
                pixel = on_bit;
                pixel = off_bit;
        gl_FragColor = pixel;


And the sfml-part :

    if (!sf::Shader::isAvailable() ||
        !m_ShaderContainer[0].loadFromFile("data//Shader//1bbp.frag", sf::Shader::Fragment))
          // error messages

        std::cout << "Engine : Shader OK !\n";

        m_ShaderContainer[SHADER_1BPP].setParameter("on_bit", sf::Color::Black);

But all what happens is that the the sprite applied with this shader goes black.
Any help would be appreciated!

Graphics / Re: Rendering clear text (SFML 2.0)
« on: September 02, 2012, 11:20:27 pm »
Text editors use points, whereas SFML uses pixels.

I'm sorry but your main problem is confusing me. What is wrong exactly? What is shown here, the version with CLEAR_FONT defined or the other one? Can you show a comparison of both?

Thanks for that info, didn't know that since 1.6

Here is a image with both versions :

obviously I failed to explain my question.
I'm wondering if it's possible to print a clear/non-smooth text between the size 8 and 16.
When printing with such a size I end up with characters with parts streched out ugly, like the 3rd and 5th text in the left example (the a's are readable , but ugly)

Graphics / Rendering clear text (SFML 2.0)
« on: September 02, 2012, 10:50:55 pm »
I know there are many post about blurry text, but I feel the need to open a new Thread, since there are things I don't understand yet.

So, I tried to print a small text and discovered  that (with the font I used) SFML can only draw clear texts , when certain sizes are used.
In my case SFML only prints clear, if I use the size 8 or a multiple of it.
Here is image which shows 9 sf::Text object starting with the character size 8 and incrementing to 16.

As you can see, all texts are printed clear(but some still ugly). To achieve this I used the object with the size 8 and scaled every string with it and had to turn smooth of the Font off. Note that all multiples of 8 would draw fine without such a trick. (btw the font used is Pokemon GB.ttf from http://www.fontspace.com/jackster-productions/pokemon-gb)

On the right there are two screenshots from notepad written with the same font.
The top extract is drawn with the size 6 and the bottom one is written with the size 12, so that charactersize 8 is linked to font size 6 in Notepad and 16 equals 12.
So what exactly is meant with charactersize, since it doesnt provide the same result given by notepad, when using equal sizes. This would be my first question.

It is clear to me, that with this technique only multiples of 8 can be drawn correctly , since they only will result in an even scale factor.
Not using this technique will leave most sizes blurry.

The example above is given by the following code :
#include <SFML/Graphics.hpp>
#include <iostream>

//#define CLEAR_FONT // commented, SFML will only draw texts clear with size % 8 == 0
int main()
    // Create the main window
    sf::RenderWindow window(sf::VideoMode(320, 180), "SFML window 2.0");

    // Create a graphical text to display
    sf::Font font;
    if (!font.loadFromFile("GB.ttf"))
        return EXIT_FAILURE;
    // 'old' Sfml 1.6 trick
    const sf::Texture* tex = &font.getTexture(8);
    ((sf::Texture*) tex)->setSmooth(false);

    sf::Text MyTexts[9] = { sf::Text("Example", font, 8),  
                            sf::Text("Example", font, 8),
                            sf::Text("Example", font, 8),
                            sf::Text("Example", font, 8),
                            sf::Text("Example", font, 8),
                            sf::Text("Example", font, 8),
                            sf::Text("Example", font, 8),
                            sf::Text("Example", font, 8),
                            sf::Text("Example", font, 8)};

    for (unsigned int i = 1;i < 9;i++)
        MyTexts[i].setScale( (i+8) / 8.0 , (i+8) / 8.0);   // every text will be clear, even when zooming in ( e.g. by resize)

    sf::Text MyTexts[9] = { sf::Text("Example", font, 8),  // will be clear, but blurry when zooming in ( e.g. by resize)
                            sf::Text("Example", font, 9),
                            sf::Text("Example", font, 10),
                            sf::Text("Example", font, 11),
                            sf::Text("Example", font, 12),
                            sf::Text("Example", font, 13),
                            sf::Text("Example", font, 14),
                            sf::Text("Example", font, 15),
                            sf::Text("Example", font, 16)}; // will be clear, but blurry when zooming in ( e.g. by resize)


    float OffSet_Y = 1;
    for (unsigned int i = 0;i < 9;i++)

        OffSet_Y += MyTexts[i].getGlobalBounds().height + 2;

    // Start the game loop
    while (window.isOpen())
        // Process events
        sf::Event event;
        while (window.pollEvent(event))
            // Close window : exit
            if (event.type == sf::Event::Closed)

        // Clear screen

        // Draw the string
        for (unsigned int i = 0;i < 9;i++)

        // Update the window

     return EXIT_SUCCESS;

So using this font, I'm forced to only use the character size 8,16,24 and so on.
(If the picture is not available, it's in the attachment)

[attachment deleted by admin]

Graphics / Simulating character movement - How do? [SOLVED]
« on: July 21, 2011, 05:42:20 pm »
It's your while loop what indicates the crash.
Image when you click A , your variable "leftkeydown" is set to TRUE.
Then if you reach the while loop the programm gets stuck because the condition is always true.

To solve your problem just replace the while loop by a single if condition

Graphics / sf::string draws in bad quality
« on: July 21, 2011, 05:27:07 pm »
Quote from: "Laurent"
It's not the "quality", it's the characters size. So for a perfect result it must match the string size (here it's 8 ), so that no rescaling happens.

Thanks, I can't believe I've never tried this out, thats really simple.
I'm ashamed : S

Graphics / sf::string draws in bad quality
« on: July 21, 2011, 04:56:11 pm »
Thanks for your reply !

Yea, I load fonts with greater sizes than displaying them with smaller ones.
The code is easy :
Code: [Select]

    sf::Font myCourier;
    myCourier.LoadFromFile("cour.ttf",100); // Note : cour.ttf is actually Courier New , exactly what c::b is using
    sf::String tst("Text", myCourier, 8);

   // sfml routines ...

And here's a screen shot :
Note : Left pictures come from sfml, the text under each picture is drawn in MS Paint. (Arial, 8 Pixels)
Right picture shows the text written in c::b.

You will notice that sfml will give up when you try to display a string under 10pixels.

Is there any function or possibility to display the orginal font, as GUI's do or a similar thing like SetSmooth (sf::Image).
Then is there a chance to integrate glutBitmapCharacter() from OpenGl with right positions ?

PS : It seems decreasing the quality param down to 10 makes the string look better, but not as perfect as in c::b : (
PPS : I saw this question twice I think on this forum and you're the first to reply on this topic, so I'm really glad : D

Graphics / sf::string draws in bad quality
« on: June 27, 2011, 08:07:00 am »
So I want to display strings with an text and small sizes.
I tried to copy the font in codeblocks.
There you have a Courier font (by default) only 8 pixels big.
Now I go other to sfml, load the font and set the strings size also to 8 pixels, but the quality is completely different than in codeblocks.

I also tried to change the second parameter in the LoadfromFile function from the font object.

Is there any way to reproduce the font-quality from codeblocks or is there just no way to draw that small?

Thank's in advance.

General / Child Frames in wxWidgets
« on: May 25, 2011, 09:56:27 pm »
Hi all

So, I want to build an editor for my game with 2 sfml RenderWindows in order to display the map in one frame and the tiles in the other one.
I've done this with a win32 interface but now i want to try it with wxWidgets.
I followed the tutorial and it compiles fine, but it seems when I add the wxSFMLCanvas class to an wxFrame it's position is forced everytime to the origin (0,0) of the wxFrame.
Also the size of the sfml frame is stretched to the size of the whole app.
So I have to catch these events and force it's size and position back to normal.

General / [SOLVED]SFML freezes when operating with Win-Api
« on: March 14, 2011, 06:47:41 pm »

I'm using SFML with the Win32 Api.
I followed the tutorial "Integrating to a Win32 interface" but changed it :
Code: [Select]

    HWND View1 = CreateWindow(szClassName, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, 20,  20, 800, 800, hwnd, NULL, hThisInstance, NULL);

    HWND View2 = CreateWindow(szClassName, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, 1320,  20, 400, 800, hwnd, NULL, hThisInstance, NULL);

Instead of "STATIC" I'm using the same string for the main app and for the two sfml views.
This way I can handle events in SFML and main Winproc.

My main loop looks like this :
Code: [Select]

while (messages.message != WM_QUIT)
        if (PeekMessage(&messages, NULL, 0, 0, PM_REMOVE))
            // If a message was waiting in the message queue, process it
        /*if (!pause) */ // Why sfml is freezing with this ???

        Sleep(1 - (DWORD)Sleeptimer.GetElapsedTime());

As you can see I'm using an global bool to stop drawing both subapps.
It can be changed through WinProc of the main app :

Code: [Select]

LRESULT CALLBACK WindowProcedure(HWND hWnd, UINT umsg, WPARAM wParam, LPARAM lParam)
     switch (umsg)
         // [...]
         case WM_KILLFOCUS :
              pause = true;
              return 0;
          case WM_SETFOCUS :
              pause = false;
              return 0;

        // [...]
    return DefWindowProc(hWnd, umsg, wParam, lParam);

So , I click on the menu in order to pop up an dialog and wait 2 secs and the whole thing freezes.
I noticed this also when I build the sfml app without win32-Api.
If you drag the window for a certain time sfml freezes either.

Is there a way while catching the lostfocus event to tell sfml to stop actually ?

I'm using 1.6 : D

Thanks in advance !


Ok I've got it working
The sleeptimer was the problem - I can't use it, when sfview1/2 lost their focus.

Pages: [1]