Coder Social home page Coder Social logo

Comments (4)

floooh avatar floooh commented on August 24, 2024 2

Those declarations are required by sokol_gfx_imgui.h, you'll need to include at least sokol_gfx.h and sokol_imgui.h before sokol_gfx_imgui.h, only sokol_app.h is optional (that's because sokol_gfx_imgui.h needs to use those new-ish simgui_image_t handles for rendering UI-embedded textures via sokol_imgui.h, this is a relatively recent change).

The decision to require the user to include dependency headers for "layer 2 headers" (instead of integrating those include statements in the headers) might be a bit untraditional, but it was a conscious decision :)

E.g. everywhere where you include sokol_gfx_imgui.h, you need an include-chain like this:

#include "sokol_gfx.h"
#include "sokol_imgui.h"
#include "sokol_gfx_imgui.h"

...and if you don't define SOKOL_IMGUI_NO_SOKOL_APP on the build system level, it should look like this:

#define SOKOL_IMGUI_NO_SOKOL_APP
#include "sokol_gfx.h"
#include "sokol_imgui.h"
#include "sokol_gfx_imgui.h"

from sokol.

floooh avatar floooh commented on August 24, 2024

Correct, but the sokol_app.h dependency can be removed with a define SOKOL_IMGUI_NO_SOKOL_APP before including sokol_imgui.h.

See:

sokol/util/sokol_imgui.h

Lines 35 to 38 in 5b6b743

Optionally provide the following configuration defines before including the
implementation:
SOKOL_IMGUI_NO_SOKOL_APP - don't depend on sokol_app.h (see below for details)

And:

sokol/util/sokol_imgui.h

Lines 78 to 82 in 5b6b743

The sokol_app.h dependency is optional and used for input event handling.
If you only use sokol_gfx.h but not sokol_app.h in your application,
define SOKOL_IMGUI_NO_SOKOL_APP before including the implementation
of sokol_imgui.h, this will remove any dependency to sokol_app.h, but
you must feed input events into Dear ImGui yourself.

...e.g. if you use SDL2, you would need to take care yourself to feed input event from SDL into Dear ImGui (there's also a couple other things in sokol_imgui.h like clipboard support, but those should all be inside an #ifdef SOKOL_IMGUI_NO_SOKOL_APP.

PS: there's actually a small error in the documentation, I will correct that now:

define SOKOL_IMGUI_NO_SOKOL_APP before including the implementation

...this is no longer correct, it must also be defined before including the declaration (maybe best to define SOKOL_IMGUI_NO_SOKOL_APP on the build system level).

from sokol.

roig avatar roig commented on August 24, 2024

Don't know how I missed that... Sorry! Thanks!

from sokol.

roig avatar roig commented on August 24, 2024

I reopened because while I have the define set: SOKOL_IMGUI_NO_SOKOL_APP, the compilation is failing:

In file included from C:\dev\destral_zig\src\deps\sokol\destral_sokol_gfx.c:12:
C:\dev\destral_zig\src\deps\sokol/sokol_gfx_imgui.h:263:5: error: unknown type name 'simgui_image_t'
C:\dev\destral_zig\src\deps\sokol/sokol_gfx_imgui.h:1582:5: error: use of undeclared identifier 'simgui_image_desc_t'
C:\dev\destral_zig\src\deps\sokol/sokol_gfx_imgui.h:1583:22: error: use of undeclared identifier 'simgui_img_desc'
C:\dev\destral_zig\src\deps\sokol/sokol_gfx_imgui.h:1583:46: error: use of undeclared identifier 'simgui_img_desc'
C:\dev\destral_zig\src\deps\sokol/sokol_gfx_imgui.h:1584:5: error: use of undeclared identifier 'simgui_img_desc'
C:\dev\destral_zig\src\deps\sokol/sokol_gfx_imgui.h:1586:23: error: call to undeclared function 'simgui_make_image'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
C:\dev\destral_zig\src\deps\sokol/sokol_gfx_imgui.h:1586:42: error: use of undeclared identifier 'simgui_img_desc'
C:\dev\destral_zig\src\deps\sokol/sokol_gfx_imgui.h:1593:5: error: call to undeclared function 'simgui_destroy_image'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
C:\dev\destral_zig\src\deps\sokol/sokol_gfx_imgui.h:3410:21: error: call to undeclared function 'simgui_imtextureid'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

These functions and types are not ifdefed. Have we to provide these?

from sokol.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.