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

Pages: [1] 2 3 ... 124
1
SFML development / Re: Font/Text Direction
« on: May 23, 2024, 06:26:52 am »
Adding vertical advance in sf::Font would unlock one thing: let users write own text code that does the vertical layout. I think this was the point Hapax made.

Same as now sf::Text has no per letter color, style, etc. but you can write a class that does, all using sf::Font, never dealing with FreeType yourself, or how in general you can make own drawables using vertex arrays or buffers.

Now if you want vertical text, you'd have to use FreeType 100% by yourself, just to get that y from advance that sf::Font doesn't expose (I'm not sure if anything else is missing or if just this one field will allow it).

2
SFML development / Re: Font/Text Direction
« on: May 20, 2024, 05:00:37 am »
I wonder if that advance is ever used in normal LTR text too or just for column writing systems. FT docs don't say. sf::Text and sf::Font are also a bit iffy for RTL text (technically you can reverse your string before inputting it but that's a bit of a hack to make RTL be just LTR backwards), and has 0 shaping needed for cursive scripts (like HarfBuzz has).

3
Feature requests / Re: export vertexes from the Shape class
« on: May 09, 2024, 01:40:07 am »
You can use a sf::Transform (or better - sf::Transformable).

I have my own helper class (called maker in the code) that lets me format Text with bold, italics, color and outline changing per character, and in the end I use an sf::Transform like so:

            sf::RenderStates states;
            states.texture = &font->getTexture(charsize);
            sf::Transformable trans;
            const auto bounds = maker.getBounds();
            trans.setPosition(kTileSize * sf::Vector2f(pos));
            const float scale = std::min(kTileSize / right(bounds), kTileSize / bottom(bounds));
            trans.setScale(scale, scale);
            states.transform = trans.getTransform();
            RENDERER_HISTORY(m_target->draw(maker.getTextVeritces(), states));
 

You should look into how ::draw() is implemented in SFML drawables, it's almost always just doing
states.transform *= getTransform();
since they derive from transformable (that's where setPosition, setRotation, etc. all come from). Some also add texture (sf::Sprite, sf::Text, even sf::Shape actually).

4
SFML projects / Re: [Release][GUI] ImGui-SFML
« on: September 19, 2023, 09:26:10 pm »
I am doing it right now in my own game and yes, it's simple (for basic cases, maybe it'll break later and require more code):
static bool isMouseEvent(const sf::Event& eve)
{
    switch(eve.type)
    {
    case sf::Event::MouseButtonPressed:
    case sf::Event::MouseButtonReleased:
    case sf::Event::MouseMoved:
        return true;
    default:
        return false;
    }
    return false;
}


static bool isKeyboardEvent(const sf::Event& eve)
{
    switch(eve.type)
    {
    case sf::Event::TextEntered:
    case sf::Event::KeyPressed:
    case sf::Event::KeyReleased:
        return true;
    default:
        return false;
    }
    return false;
}

bool Game::handleEventGui(const sf::Event& eve)
{
    ImGui::SFML::ProcessEvent(m_win, eve);

    if(ImGui::GetIO().WantCaptureMouse && isMouseEvent(eve))
        return true;

    if(ImGui::GetIO().WantTextInput && isKeyboardEvent(eve))
        return true;

    return false;
}

5
SFML projects / Re: [Release][GUI] ImGui-SFML
« on: September 10, 2023, 11:20:52 pm »
Imgui (not Imgui-SFML) has a few globals for that called WantCaptureMouse, WantCaptureKeyboard, WantTextInput, etc.: https://github.com/ocornut/imgui/blob/master/imgui.h#L2081C17-L2081C33

I remember using those plus SFML event type (so if WantCaptureKeyboard is true then don't handle keyboard SFML event myself, etc.) and it was quite fine, I think.. I don't have the code anymore, but I'm sure it was using those.

6
SFML projects / Re: Screenshot Thread
« on: May 30, 2023, 06:09:42 pm »


Inspired by some games I'm heavily considering making my own "RPG Maker Mystery/Horror Game" style game, in C++, SFML, with Lua for scripting events, and few other libraries.

7
General discussions / Re: Taking On the Role As BDFL
« on: May 15, 2023, 02:28:37 am »
It's been years since I was last active on this forum so I'm not sure if you remember me. I was thinking of dabbling in C++ gamedev recently, so I looked towards SFML (of course...  :P ), but then noticed Laurent is not active on the forums and GH, but then also noticed that website and GH repo are updated, and then this thread and I had to reply.

Anyway: this choice of eXpl0it3r for BDFL is a very good one.

8
General / Re: Apparently random error in Config.hpp
« on: August 21, 2022, 05:55:45 pm »
From the error I am guessing you have, just before the include:
1. a class with no ; after the closing } (but that'd be a different error in modern GCC),
2. something like 'const int x = 10' without a semicolon after it (that gives that error message exactly).

9
Graphics / Re: Font LoadFromMemory issue.
« on: August 08, 2022, 07:16:49 pm »
Hello, when your osb::AssetPacker::LoadFontFromBin function returns, the std::vector<char> buffer; is destroyed. For Fonts this is wrong, as documentation can tell you: https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Font.php#abf2f8d6de31eb4e1db02e061c323e346

This is unique to Font and Music objects, IIRC, you are right that other resources like Texture and Image don't have this problem (they don't need buffer to be alive).

You should make that buffer part of same class/object as the font, so they have same lifetime. Your code to load data from file could use some improvement too (load more than 1 byte at a time).

10
General / Re: Exception thrown when attempting to run an SFML project
« on: April 17, 2020, 02:49:22 am »
It's due to that sf::Texture being global, it tries to access things that aren't ready yet when it's being constructed.

Although I can't now quickly find what code would fail (it might be loadExtensions at https://github.com/SFML/SFML/blob/master/src/SFML/Window/GlContext.cpp#L235 , it gets called eventually due to sf::Texture constructor being called, and it accesses globals, so there's the order conflict potential) or why and can't reproduce it but writing location 0x00000004 looks like attempt to write via pointer that's null.

Here's someone else's thread of similar issue years ago and answer is (and still is, I think) to not use globals because they might mess init order of SFML's own globals: https://en.sfml-dev.org/forums/index.php?topic=5654.0

11
SFML website / Links in Tutorials lead to outdated DoxyGen docs
« on: August 04, 2019, 11:32:51 pm »
Minor nitpick I just ran into.

They now lead to "Documentation of SFML 2.5.0" which has the "Warning:  this page refers to an old version of SFML. Click here to switch to the latest version." instead of "Documentation of SFML 2.5.1" which is now the latest one.

12
To be clear: ffmpeg can do jpeg and others to png. It can't do svg to png. ImageMagick can.

13
ImageMagick can do it too if you have it installed or are willing to install it.

I once had a bunch of bmp files and wrote a similar tool to go from bmp, jpg, etc. to png ( https://github.com/FRex/topng/ ) because I didn't have ImageMagick and didn't want to install it just for this, but I later also found out ffmpeg also can do such conversions (and ffmpeg I do have installed) but mine is at least simple to invoke in find command or something.

14
General / Re: Link executable to work with all 2.x SFML libs
« on: July 21, 2019, 06:49:43 am »
I've seen app before bundle all needed files and use 'LD_LIBRARY_PATH' (see .wrapper script in these trial Linux versions): https://www.iforce2d.net/rube/#

There's also things like FlatPack and AppImage but I only ever heard of them as solution to this Linux distribution problem.

And SFML in repos is often out of date. :/

15
Graphics / Re: Array of rectangles
« on: July 08, 2019, 03:56:19 am »
std::vector has in it a copy of your original, this is how C++ works and it's different to Java and such.

Also: this isn't C question, you shouldn't use goto in C++, & is binary and - % is modulo.

Pages: [1] 2 3 ... 124