Welcome, Guest. Please login or register. Did you miss your activation email?

Recent Posts

Pages: 1 ... 8 9 [10]
91
Feature requests / subpixel multi-channel text rendering for SFML: A demonstration
« Last post by GoS on March 19, 2025, 09:44:46 pm »
This is more than a feature request - and also as yet less than a pull request. See attached image for example text output.

Objective: Make text rendered by SFML crisper on suitable monitors[1] by making use of Freetype's ability to supply position offsets for each of the red, green, and blue channels in glyph bitmap data. This feature got added to SDL during v3 development; SFML deserves no less.

[1] These being horizontally decimated LCD displays. Most LCD desktop- or laptop-type monitors qualify when in landscape orientation.

The below code is not yet suitable for a proper pull request. For starters, it provides no way for users of the library to control which Freetype glyph rendering option they would prefer. It is merely a demo.


You need:
1. A standard LCD desktop- or laptop-type monitor, in landscape orientation.
2. A working SFML development setup.
3. A program that displays text on screen using the sfml-graphics library. Text size should be anything from 8 to 12 points for the most obvious effect. The objective here is to make it display text as crisply on your LCD monitor as does a native GTK or Windows application.


Instructions:
Open the file <SFML>\src\SFML\Graphics\Font.cpp.
Find the method "Glyph Font::loadGlyph(". In this method, find "FT_LOAD_TARGET_NORMAL"; change to "FT_LOAD_TARGET_LCD". Find "FT_RENDER_MODE_NORMAL"; change to "FT_RENDER_MODE_LCD".

Now we need to make the SFML code cooperate with the new input from Freetype. Instead of one 8-bit input pixel per output pixel, we are now given three. So, find "Extract the glyph's pixels from the bitmap" and add the following code after the block "if (bitmap.pixel_mode == FT_PIXEL_MODE_MONO)":

        else if ((bitmap.pixel_mode == FT_PIXEL_MODE_LCD) || (bitmap.pixel_mode == FT_PIXEL_MODE_LCD_V))
        {
            // Input pixels are 3x8 bit gray levels
            for (unsigned int y = padding; y < size.y - padding; ++y)
            {
                std::size_t index = padding + y * size.x;

                // Output is 32-bit RGBA. Advance x by three per output pixel.
                for (unsigned int x = padding; x < size.x - padding;)
                {
                    // Fill all three color channels. Compute and fill the alpha channel.
                    uint8_t r = pixels[x++ - padding];
                    uint8_t g = pixels[x++ - padding];
                    uint8_t b = pixels[x++ - padding];
                    int     a_calc = r + g + b; // XXX - check this for correctness
                    if (a_calc > 255)
                        a_calc = 255;
                    uint8_t a = (uint8_t)a_calc;

                    m_pixelBuffer[index * 4 + 0] = r;
                    m_pixelBuffer[index * 4 + 1] = g;
                    m_pixelBuffer[index * 4 + 2] = b;
                    m_pixelBuffer[index * 4 + 3] = a;
                    index++; // Advance index by one per three input pixels.
                }
                pixels += bitmap.pitch;
            }
        }
 

If these instructions are unclear, incorrect, or do not give you crisp output on an LCD monitor, please advise.
92
SFML projects / Re: Dispersio 3
« Last post by achpile on March 19, 2025, 08:47:50 am »
Finally I have something to show. Here you can download demo (win/osx).

https://github.com/achpile/dispersio3/releases/tag/v0.4.0

Not sure about osx build tho - have no way of testing it myself  ;D

Yep, it's pretty different from what I've shown you in the video and more like my first game. I just realized that making interesting run and gun game is way harder than I thought  :D
93
General / Re: Trying to inspect Textures stalls Visual Studio
« Last post by eXpl0it3r on March 19, 2025, 08:41:13 am »
Maybe run SMART checks on your HDD. Such odd behavior shouldn't happen and might indicate an imminent failure of the drive.
94
General / Re: Trying to inspect Textures stalls Visual Studio
« Last post by Reicha7 on March 19, 2025, 01:00:30 am »
Oh it also turns out that somehow I had set up my project on my HDD rather than my SSD. Switching over to SSD seems to have helped too!

That's probably the real issue at play here
95
General / Re: Trying to inspect Textures stalls Visual Studio
« Last post by Reicha7 on March 18, 2025, 11:55:10 pm »
Yeah I tried rebuilding and even got latest to see if maybe there was one version. I used these cmake settings (attached), launched in VS, hit rebuild, and then moved the built lib files into my project location but same issue.

It does seem to be intermittent actually as I had it stall on prebuilt as well so maybe it is my PC. Prebuilt does seem to have it happen less often though

I will just use prebuilt for now as there's nothing I needed from compiling from source other than the chance to learn a bit :)
96
Window / Re: How to create a window with debugging context?
« Last post by Eugene on March 18, 2025, 04:41:47 pm »
I found the problem :).
It was that in a project with SFML I use advanced shaders that access transform matrices from GL_UNIFORM_BUFFER.
In the GLFW project, on the other hand, I was using shaders where the matrices were sent directly to the shader program every iteration of the game loop by calling glUniformMatrix4fv.
It was calling this function with the shaders disabled that caused the debug callback to trigger and I would get error messages.
Thank you for your help!
97
Window / Re: How to create a window with debugging context?
« Last post by eXpl0it3r on March 18, 2025, 11:29:39 am »
The fact that you're getting warnings means, that the debug context is active.

glUseProgram(0) alone shouldn't necessarily trigger an error.

Can you post your GLFW and SFML code?
98
General / Re: Trying to inspect Textures stalls Visual Studio
« Last post by Reicha7 on March 18, 2025, 11:06:26 am »
Never heard of such an issue, so maybe it's more some temporary VS problem?

Yeah it's not something I've ever seen before either and it only happened when I was using my own built SFML 3.0 static libs.

I will see if I can get the dynamic libs to build again.
99
General / Re: Trying to inspect Textures stalls Visual Studio
« Last post by eXpl0it3r on March 18, 2025, 08:33:19 am »
Never heard of such an issue, so maybe it's more some temporary VS problem?

I couldn't get it to create the dynamic libraries so have linked it statically but am not sure that's even the issue.
You'd need to set BUILD_SHARED_LIBS to ON
100
Window / Re: How to create a window with debugging context?
« Last post by Eugene on March 18, 2025, 06:08:41 am »
I don't use the sfml-graphics module, I don't even compile it. My CMakeLists.txt:

...
set(SFML_BUILD_GRAPHICS OFF CACHE BOOL "" FORCE)
set(SFML_BUILD_AUDIO OFF CACHE BOOL "" FORCE)
set(SFML_BUILD_NETWORK OFF CACHE BOOL "" FORCE)
...

I also use glad to initialize OpenGL functions on my own. I am probably missing checking and initializing some OpenGL extension
Pages: 1 ... 8 9 [10]
anything