edubart / sokol_gp

Minimal modern efficient cross platform 2D graphics painter in C
MIT No Attribution
457 stars 24 forks source link

non-vendored sokol (version?) #41

Open konsumer opened 1 week ago

konsumer commented 1 week ago

I get this error:

/Users/konsumer/Desktop/otherdev/null0-sokol/build/_deps/sokol_gp-src/sokol_gp.h:1583:10: error: no member named 'fs' in 'struct sg_shader_desc'
 1583 |     desc.fs.images[0].used = true;

and a bunch of others that look like the APIs don't match.

I think it is due to a mismatch of API for latest sokol from GitHub. What commit/tag should I target?

I am trying to build everything pulling sokol & sokol_gp from GitHub zips, so I don't have to vendor them. Here is my cmake:

FetchContent_Declare(sokol
  URL https://github.com/floooh/sokol/archive/refs/heads/master.zip
)
FetchContent_MakeAvailable(sokol)
include_directories(${sokol_SOURCE_DIR})

FetchContent_Declare(sokol_gp
  URL https://github.com/edubart/sokol_gp/archive/refs/heads/master.zip
)
FetchContent_MakeAvailable(sokol_gp)
include_directories(${sokol_gp_SOURCE_DIR})

add_executable(${PROJECT_NAME} src/main.c)

if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
    target_compile_options(${PROJECT_NAME} PRIVATE -x objective-c)
    target_link_libraries(${PROJECT_NAME}
        "-framework QuartzCore"
        "-framework Cocoa"
        "-framework MetalKit"
        "-framework Metal"
        "-framework OpenGL"
        "-framework AudioToolbox")
else()
    if (CMAKE_SYSTEM_NAME STREQUAL Linux)
        target_link_libraries(${PROJECT_NAME} INTERFACE X11 Xi Xcursor GL asound dl m)
        target_link_libraries(${PROJECT_NAME} PUBLIC Threads::Threads)
    endif()
endif()

Here are all the missing members, if an update of sokol_gp makes more sense:

sg_shader_desc.fs
sg_shader_desc.vs
sg_shader_vertex_attr.name
sg_shader_vertex_attr.sem_name
sg_shader_vertex_attr.sem_index
konsumer commented 1 week ago

Essentially, I want a Findsokol.cmake that looks something like this (with the version changed on sokol, so they match.)

Findsokol.cmake.zip

This is my current sokol entry-point (sokol.c) which I'd like to eventually also inline in the cmake build:

#define SOKOL_IMPL
#if defined(_MSC_VER)
#define SOKOL_D3D11
#elif defined(__EMSCRIPTEN__)
#define SOKOL_GLES3
#elif defined(__APPLE__)
// NOTE: on macOS, sokol.c is compiled explicitly as ObjC
//#define SOKOL_GLCORE
#define SOKOL_METAL
#else
#define SOKOL_GLCORE
#endif
#include "sokol_gfx.h"
#include "sokol_gp.h"
#include "sokol_app.h"
#include "sokol_glue.h"
#include "sokol_log.h"

Which would make cmake usage very simple:

find_package(sokol REQUIRED)
add_executable(${PROJECT_NAME} src/main.c)
target_link_libraries(${PROJECT_NAME} sokol)
konsumer commented 1 week ago

If not updating is preferred, I can actually resolve with

FetchContent_Declare(sokol
  URL https://github.com/floooh/sokol/archive/refs/tags/pre-bindings-cleanup.zip
)

which is a tag from last month.