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

General / Re: Whats wrong with my collision detection?
« on: March 25, 2023, 09:36:41 am »
Collision detection is pretty easy if you break it down into smaller actions - it's only really complicated when you start trying to calculate complex physics simulations.

The basics of a collision involve calculating what's called a 'collision manifold'. This is composed of two things: a normal vector indicating the direction of the collision, and a penetration value - ie how much the two objects overlap. With these, resolving the collision usually boils down to moving the colliding object back along the normal vector by the penetration amount.

For AABB - AABB collision and circle-circle collision, finding this manifold is also really easy. I wrote this blog post for SFML specifically, which explains how to do it. Once you have an understanding of these types of collision then it's much easier to extend the technique to other shapes, although in many cases I've found AABB and circle collision is enough  ;D

Graphics / Re: Draw sprite to renderwindow automatically
« on: December 23, 2022, 05:39:34 pm »
A simple approach would be to place your sprites in a vector, and loop over it when you draw:

std::vector<sf::Sprite> sprites;

//insert sprites here

for (const auto& sprite : sprites)

However if you're getting more serious about your code design I highly recommend reading SFML Game Development and Game Programming Patterns - both of which I found invaluable when I was learning SFML.

General / Re: VertexArray size impacting gl_Vertex value in Vertex shader
« on: December 14, 2022, 05:21:16 pm »
To be honest that's probably the best work around you'll get. For a while I supplied my own set of matrices to the vertex shader (and did my own funky 3D things with it) but then decided if I was going to put in that much work I might as well just switch to pure OpenGL. Credit to SFML though, I wouldn't have learned enough about OpenGL without it  ;D

General / Re: Render to several render textures in one draw ?
« on: December 14, 2022, 02:25:46 pm »
I did make an SFML-compatible(ish) MRT some time ago, which you can check out here:


I say 'ish' it breaks compatibility with the version of OpenGL SFML uses, so while it works on Windows using a compatibility context it won't work on macOS (and I think linux was spotty too, but it's been a while and I don't recall for sure  ;D)

General / Re: VertexArray size impacting gl_Vertex value in Vertex shader
« on: December 14, 2022, 02:17:51 pm »
This is an SFML optimisation - if a drawable has four or fewer vertices then the positions are pretransformed to world-view coordinates, and the model-view matrix is set to an identity. I came across this when working with a lighting shader and the inverse of the model-view matrix wasn't giving me what I expected.

Graphics / Re: SFML and Shaders
« on: November 19, 2022, 02:52:57 pm »
Another thing, in general... How do you get the position sent to the shaders in SFML?
I haven't seen any good tutorial on it yet.
Like in "proper" openGL you usually use in vertex shader:

layout (location = 0) in vec3 aPos;

void main()
   gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);

but I'm not sure if this works in SFML like that?
All the examples I've seen use deprecated 1.0 stuff, that is really old.
I mean I try to use 3.3 core, and even that's old, but at least it's a bit modern...

If you're using the graphics module of SFML then up to version 2.5 (maybe 2.6, I've not kept up) you're restricted to GLSL 1.2 / #version 120 without a compatibility context. So, you're probably OK to use other versions of GLSL on Windows, maybe on Linux, and not at all on macOS which only supports core profiles.

The vertex position is provided in gl_Vertex and the world/view/projection matrix in gl_ModelViewProjectionMatrix - see the shader tutorial. It might also be worth noting that SFML drawables with 4 or fewer vertices will have their positions in world space with an identity matrix set for model/world matrix (this has caught me out before when trying to do lighting stuff, trying to take the inverse of it will just give you another identity matrix).

Pages: [1] 2 3 ... 33