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 ... 34
Audio / Re: sf::sound causes severe performance lag.
« on: May 30, 2024, 05:11:08 pm »
Make sure you're only loading the buffer from file *once* then keeping it around, and not trying to load it every frame

General / Re: Can you integrate allegro into an sfml window?
« on: May 26, 2024, 11:43:02 am »
Based on your earlier post I assume you're using Dev C++ in which case check their FAQ: https://bloodshed.net/FAQ#9

Else if you're using CMake use the FindOpenGL command https://cmake.org/cmake/help/latest/module/FindOpenGL.html

Or in Visual Studio add "opengl32.lib" to the library list in the project properties and it'll find the file automatically.

General / Re: Can you integrate allegro into an sfml window?
« on: May 23, 2024, 10:56:07 am »
Just tried it with gcc and there were a few typos which needed fixing 😅

I've updated the repo with a version that I've tested on my linux box and added a CMake project for the demo if you'd like to try it.

General / Re: Can you integrate allegro into an sfml window?
« on: May 22, 2024, 05:22:14 pm »
It depends on you compiler/toolchain setup.

For example Visual Studio lists 2 folders in its source tree "Header Files" and "Source Files". Only the files which are included in the "Source Files" folder are sent for compilation. It's at this point any header files which are #include 'd in the *.cpp files are pulled in by the compiler for compilation. (Well, kinda, they're put in place by the preprocessor just before compilation).

On the other hand *.hpp files listed in the "Header Files" section are ignored, except for when they're explicitly #include 'd in a *.cpp file. If you try adding an *.hpp file to the "Source Files" folder, Visual Studio will try to compile it directly which may or may not be what you want (probably not in most cases, and definitely not in this specific case).

Other toolchain/compiler setups are similar: you list the source files (*.c and *.cpp) you want to compile, followed by the directories containing the header files. That way the compiler will only pull in any header files for compilation as is needed.

So what I mean is - make sure the *.hpp files are not being added to the list of files to be compiled, either by accidentally adding them to the "Source Files" folder in Vidual Studio, or by any other means with a different compiler.

General / Re: Can you integrate allegro into an sfml window?
« on: May 19, 2024, 11:57:24 am »
When you add the files to your project, make sure you're only compiling VideoTexture.cpp (not the header files)

General / Re: Can you integrate allegro into an sfml window?
« on: May 18, 2024, 12:05:47 pm »
This should get you off on the right foot:


Just add the files in the 'src' directory to your project, and check the example for usage :)

General / Re: Can you integrate allegro into an sfml window?
« on: May 15, 2024, 10:46:39 am »
What sort of video do you need to support? If it's just for some intro videos/cutscenes pl_mpeg is pretty easy to integrate with a RenderTexture/AudioStream

or there's more comprehensive support with libvlc:

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.

Pages: [1] 2 3 ... 34