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
1
I had to double check - according to this GLES2 is a mix of both 😅
https://www.khronos.org/opengles/sdk/docs/reference_cards/OpenGL-ES-2_0-Reference-card.pdf

It uses varyings rather than in/out and has the gl_FragColor constant (old style), however there's no gl_TexCoord array, texture coords need to be passed via a varying instead (new style)... It also uses the old style texture2D() sampler functions.

So, uh.. probably best to forget I mentioned GLES 😅

2
I think the most important thing when starting out is to know that there *are* different versions of OpenGL/GLSL... and that they're kind of a mess 😅

Mixing OpenGL versions is not particularly recommended - it *might* work on Windows, *kinda* works on Linux and definitely doesn't work on macOS.

Once you get your head around that just make sure to stick with one particular version and use an appropriate library. There's the "old" style, which SFML uses (as does WebGL and GLES2 if memory serves, but don't quote me on that) or the "new" style, as taught by most OpenGL learning resources.

"Old" style OpenGL versions are up to 2.1, which uses GLSL up to 1.2
OpenGL3, 3.1 and 3.2 use GLSL 1.3, 1.4 and 1.5 - though you rarely see these anywhere
"New" style OpenGL is 3.3+ and the GLSL version numbers match (3.3, 4.0, 4.1 etc)

When you have the basics down in either version from there it's actually pretty easy to see the differences and swap between the various versions as you need to.

3
Unless things have changed on the development branch, SFML 2 uses GLSL 1.2

Try:
#version 120
uniform sampler2D u_texture;

void main()
{
    gl_FragColor = texture2D(u_texture, gl_TexCoord[0].xy);
}

 

https://www.sfml-dev.org/tutorials/2.6/graphics-shader.php#minimal-shaders

4
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

5
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.

6
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.

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

8
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)

9
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:

https://github.com/fallahn/VideoTexture

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

10
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
https://github.com/phoboslab/pl_mpeg

or there's more comprehensive support with libvlc:
https://github.com/kjetand/vlc4sfml

11
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

12
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

13
Graphics / Re: Drawing Vertex Array with big Texture
« on: January 29, 2024, 10:54:59 am »
Quote
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.

14
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 :)

15
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.

Pages: [1] 2 3 ... 34