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

Pages: [1] 2 3 ... 33
Graphics / Re: Perspective distortion issue
« on: February 15, 2024, 07:36:49 pm »
What you're getting is Affine Texture Mapping - caused by the vertex stage interpolating the UV coordinates in 2D space. (It's actually what the PS One did).

For Perspective Texture Mapping you'll need to supply some sort of depth value. This article explains more: https://mtrebi.github.io/2017/03/15/texture-mapping-affine-perspective.html as does wikipedia: https://en.wikipedia.org/wiki/Texture_mapping#Affine_texture_mapping

Graphics / Re: LineStrip VertexArray and ConvexShape problem
« on: February 02, 2024, 10:54:32 am »
SelbaWard looks like it supports this: https://github.com/Hapaxia/SelbaWard/wiki/Polygon

Graphics / Re: Drawing Vertex Array with big Texture
« on: January 29, 2024, 10:54:59 am »
I'm not against the idea, I just have no clue how I'd approach it.
I'm aware that may be due to my lack of understanding of OpenGL, so if that's the case please let me know. Thank you

I apologise if this is jumping in at the deep end a little - I just wanted to highlight what's possible if you're able to mix some OpenGL with SFML.

However, if there are any SFML devs reading this, I think sf::ArrayTexture might not be a bad idea? It would also be useful for animating sprites, for example. Array textures are available though this extension.

Graphics / Re: Drawing Vertex Array with big Texture
« on: January 26, 2024, 11:39:00 am »
If you're willing to get your hands dirty with some OpenGL the Array Texture would help here (and would also be a nice addition to SFML, but that's another matter ;))

For example, if you have individual textures, as Hapax says, each containing an atlas of a single frame, you can load each one of these into a slot in the texture array - resulting in a single texture bind/single vertex array for all the frames.

In the first case where all characters are on the same frame, you can simply set the current frame index in the shader:

Code: [Select]
uniform sampler2DArray u_texture;
uniform float u_frameIndex;

in vec2 v_texCoord;

out vec4 o_colour;

void main()
    o_colour = texture(u_texture, vec3(v_texCoord, u_frameIndex));

Animating characters individually is a little more work, however can be done by setting the frame index of a character in its vertex data:

Code: [Select]
//vertex shader
in vec2 a_position;
in vec2 a_texCoord;
in float a_frameIndex;

out vec2 v_texCoord;
flat out float v_frameIndex;

void main()
    gl_Position = //usual stuff here
    v_texCoord = a_texCoord;
    v_frameIndex = a_frameIndex;

//then in the fragment shader we do as before, only the frame index comes from the vertex shader, not a uniform:

uniform sampler2DArray u_texture;

in vec2 v_texCoord;
flat in float u_frameIndex;

out vec4 o_colour;

void main()
    o_colour = texture(u_texture, vec3(v_texCoord, u_frameIndex));

In the latter case you could even combine the coordinates in the vertex shader if you don't mind losing the flat qualifier. It's a relatively large chunk of work to set up, however it results in a single vertex array and a single texture object for your text, and if encapsulated would be a nice addition to any library :)

General / Re: Help with distribution for macOS (Xcode not working)
« on: December 16, 2023, 04:31:53 pm »
To distribute applications on macOS you need to pay Apple $99 a year for a developer license, which lets you sign and notorize your binaries.

Graphics / Re: How to render in color emojis?
« on: December 10, 2023, 01:11:44 pm »
Short story: You can't; SFML doesn't support coloured fonts. However there is a monochrome version of the noto emoji font which might work: https://fonts.google.com/noto/specimen/Noto+Emoji

Long story: I've been through this experience recently with my own engine, which uses SFML fonts/text/string as a basis for text renderering. Here's a brief summary of what I've found:

As you point out one font won't contain all the emojis and text characters. You need to use multiple fonts with multiple strings/text which can make it difficult to mix emojis with text in SFML. DearImGui takes an interesting approach which allows assigning multiple fonts to different ranges of unicode - you can read about it here.

I used this approach to modify what was essentially SFML's font class to allow loading multiple ttf files into a single Font, mapping them to different character ranges. This would be a nice feature, I think, to add to SFML.

SFML's fonts don't support colour - however they *could* if the way the underlying freetype library is used was changed slightly. Again, this would be a nice addition to SFML. *HOWEVER* that being said, while this will apparently work with Windows built in emoji font (C:/Windows/Fonts/seguiemj.ttf - license forbids redistribution) it still doesn't work with the colour format used by Google's Noto colour font  ::)

To print emojis with sf::String is relatively easy, though you will probably have to use codepoints directly, rather than string literals
Code: [Select]
sf::String str(u8"🌙");
This might work for single codepoint emojis, but for multi-point emojis you'll need to combine them yourself:
Code: [Select]
sf::String str(0x2600);
str += sf::String(0xFE0F);

Emojipedia is a good reference source - the technical tab will list any codepoints you need to combine.


Window / Re: Issue with full screen switching
« on: November 14, 2023, 05:23:58 pm »
If you're only using SFML for windowing you'll probably be better off with sf::Window rather than sf::RenderWindow which manages a bunch of OpenGL stuff for SFML's graphics module. This way you won't need to push and pop any internal OpenGL state.

You probably won't be able to use SFML's Shader class though, and will have to manage your own shaders - however this is likely better in the long run as experience has taught me that mixing OpenGL with SFML's graphics module can cause problems, such as the one you're describing, anyway.

General / Re: cannot setup SFML 2.6 on Visual Studio 2022.
« on: September 29, 2023, 01:13:28 pm »
This is a weird quirk of Visual Studio - if you created a 'new empty project' the C/C++ option won't appear until you add at least one source file, even if it's just an empty one. Add something like main.cpp and the option will become available.

General discussions / Re: Console for SFML Devs and players
« on: September 26, 2023, 04:56:35 pm »
Not sure you really need a custom OS - you can use this with your regular Linux pi distro - https://github.com/mickelson/sfml-pi - it'll run without X11/windowing so it can draw directly to the screen (like a console). I've used it in the past to create a 'digital scoreboard' for a darts game at a local bar.

Or, in other words, using the that version of SFML to create a console-like frontend (similar to what I mentioned in my previous post) have it launch immediately once the pi boots. From there you can load any game etc from SD card, and developers have a familiar environment (SFML) to create games for your console :D

Graphics / Re: draw triangles primitives as wires?
« on: August 11, 2023, 10:27:23 am »
There's nothing like that in the SFML api as far as I know, but you can probably expose the OpenGL function by including <SFML/OpenGL.hpp> then calling it around your vertex array

Code: [Select]

Graphics / Re: National letters - input text on screen
« on: August 03, 2023, 07:12:05 pm »
Assuming name_input_string is a std::string (hard to tell without a namespace) try:

Code: [Select]
char_creation_name_input_txt.setString(sf::String::fromUtf8(name_input_string.begin(), name_input_string.end());

General / Re: A problem with platformer side collisions.
« on: July 13, 2023, 10:35:00 am »
You need to calculate from which direction the collision occurs - ie the 'collision normal', then correct the position along it. I wrote a post about it here:


Graphics / Re: Text.getLocalBounds() returns strange coordinates
« on: June 04, 2023, 12:18:45 pm »
Basically because taller characters can extend outside the bounding box. There's more info in this topic (and the topic it links): https://en.sfml-dev.org/forums/index.php?topic=27711.msg174750#msg174750

General discussions / Re: Console for SFML Devs and players
« on: June 04, 2023, 12:15:35 pm »
I thought about this some time ago, and even did some experiments. The idea was to use an x86 SBC as the hardware (something like an UDOO bolt or LattePanda) and run a minimal version of linux on it - for example with no desktop environement. x86 would be ideal as there would be no need for cross-compiler setup (although perhaps some wrangling of libraries to get a compatible development environment).

For software I created this as a working proof of concept: https://github.com/fallahn/osgc

It basically runs a front-end executable (written with SFML of course ;) ) that allows browsing games similarly to Kodi for videos or RetroArch for emulators.

Games themselves are then built as DLLs (or SOs as we're on linux) instead of executables. Then they can be copied to an SD card or the storage of the SBC so that the frontend can load the games at runtime.

With a bit of work and a 3D printed case, maybe it could be turned into a console-like device :D

General / Re: console disable c++
« on: March 31, 2023, 02:07:07 pm »
It depends on your IDE / tool chain. For example in Visual Studio go to your project settings, Linker>System>SubSystem and set the value to Windows.

Pages: [1] 2 3 ... 33