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

Pages: [1]
1
SFML game jam / Re: new sfml game jam
« on: November 12, 2022, 12:42:55 am »
Uhh... I wanted to have some fun with recreational 2D graphics, and so I started learning SFML last week. I've seen the deadline, and thought leaving yesterday evening for writing a simple game was a great idea.

... and just when I opened the lid I'm daily driver MBP the backlight broke :( ... checkout "flexgate" if you care.

Anyhow, I have no idea what the rules of the code jam were, but feel free to accept this video as a late submission.
I can share the code later, whichever way it's expected.

Yeah, yeah, it's very basic, but it's my first SFML app, and just one evening.


2
C / Re: C API Limitations
« on: November 06, 2022, 09:44:47 pm »
I would of course never ever recommend doing that … but …

In this specific case, with the specific memory layout we have today, a forced cast from sfRenderWindow* to sfWindow* should end up pointing to the exact slice of the sf::RenderWindow that looks like a wrapped sf::Window.

I wouldn’t want to maintain code like this over the long term, but if for whatever reason you would want to keep the sf objects directly embedded inside the struct, it should work.

3
General / Re: Building with Bazel (on macOS)
« on: November 06, 2022, 06:12:40 pm »
I'm starting with SFML and I insist to use it with Bazel on macOS Monterey.
I'm not an expert on Bazel or macOS specific development, and I didn't manage to get a fully hermetic setup, but I got a few steps closer.

The setup is not perfect, but I didn't find any better one on the Internet, so I've decided to share it here.
My goal is to have some fun with SFML, and this approach works of me for now, but if you manage to improve it, I'm happy to try it out.

What works:
  • Once installed, you can build and run SFML based applications with Bazel.
  • This works on macOS.

What could work better:
  • I did no attempt to support other systems.
  • I did no attempt to build SFML from source.
  • The application is a command line application, not an application bundle, and so it is not distribution ready.
  • The frameworks from extlibs/ have to be manually downloaded, unquarantined, and copied to "/Library/Frameworks/"

I'm using the dylib distribution of SFML, because Bazel is able to easily make them available to the binary through a simple srcs = glob(["lib/*"]) inclusion in a hermetic way.
I don't know if there is a simple way to include framework based distribution hermetically.

It is simple enough to use frameworks installed in the OS with brew (non-hermetic):

This is what I did for the SFML extlibs/. I'm not an expert in macOS application bundles, and I don't know how, and if at all it's possible to point SFML dylibs to frameworks located in custom directories, or easy or hard would it be to build them together as a cc_binary in Bazel, or finally how much work would it be to package it into an Application bundle, without Xcode doing all the heavy lifting.

Now, to the good stuff:

My WORKSPACE.bazel file:

workspace(name = "my workspace")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "sfml",
    build_file = "@//external/sfml:BUILD.bazel",
    sha256 = "6af0f14fbd41dc038a00d7709f26fb66bb7ccdfe6187657ef0ef8cba578dcf14",
    strip_prefix = "SFML-2.5.1-macos-clang",
    urls = ["https://www.sfml-dev.org/files/SFML-2.5.1-macOS-clang.tar.gz"],
)


My external/sfml:BUILD.bazel file

load("@rules_cc//cc:defs.bzl", "cc_library")

cc_library(
    name = "sfml",
    srcs = glob(["lib/*"]),
    hdrs = glob([
        "include/**/*.hpp",
        "include/**/*.inl",
    ]),
    # This is not a hermetic http_archive, because SFML depends on additional frameworks.
    # These had to be manually unquarantined and copied to "/Library/Frameworks/"
    # % cd /Users/tojot/Downloads/SFML-2.5.1-macos-clang/extlibs
    # % xattr *
    # % xattr -rd com.apple.quarantine  *
    # % xattr *
    copts = [
        "-framework libogg",
        "-framework flac",
        "-framework libpng",
        "-framework freetype",
        "-framework vorbisenc",
    ],
    # Include libraries like this: #include "SFML/Graphics.hpp"
    strip_include_prefix = "include/",
    visibility = ["//visibility:public"],
)


Pages: [1]