From f671eb83bf1c4cebd84bd7d730e02ad62c57ab11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Mon, 15 Jun 2026 21:10:12 -0700 Subject: [PATCH] Removed bgfx/platform.h (#3761) --- examples/common/entry/entry_glfw.cpp | 2 +- examples/common/entry/entry_html5.cpp | 2 +- examples/common/entry/entry_ios.mm | 2 +- examples/common/entry/entry_osx.mm | 2 +- examples/common/entry/entry_sdl.cpp | 2 +- examples/common/entry/entry_windows.cpp | 2 +- include/bgfx/bgfx.h | 2 - include/bgfx/platform.h | 141 ------------------------ scripts/temp.bgfx.hpp | 2 - scripts/temp.bgfx.idl.inl | 4 + src/bgfx.idl.inl | 4 + src/bgfx_p.h | 1 - src/config.h | 5 + 13 files changed, 19 insertions(+), 152 deletions(-) delete mode 100644 include/bgfx/platform.h diff --git a/examples/common/entry/entry_glfw.cpp b/examples/common/entry/entry_glfw.cpp index 481e2b5b7..38632efd5 100644 --- a/examples/common/entry/entry_glfw.cpp +++ b/examples/common/entry/entry_glfw.cpp @@ -27,7 +27,7 @@ #endif // #include -#include +#include #include #include diff --git a/examples/common/entry/entry_html5.cpp b/examples/common/entry/entry_html5.cpp index b2b064df1..475bf9439 100644 --- a/examples/common/entry/entry_html5.cpp +++ b/examples/common/entry/entry_html5.cpp @@ -7,7 +7,7 @@ #if BX_PLATFORM_EMSCRIPTEN -#include +#include #include #include diff --git a/examples/common/entry/entry_ios.mm b/examples/common/entry/entry_ios.mm index 4aa15f65e..8d91519bf 100644 --- a/examples/common/entry/entry_ios.mm +++ b/examples/common/entry/entry_ios.mm @@ -17,7 +17,7 @@ # define HAS_METAL_SDK #endif -#include +#include #include diff --git a/examples/common/entry/entry_osx.mm b/examples/common/entry/entry_osx.mm index 77cb5fa62..7a6640beb 100644 --- a/examples/common/entry/entry_osx.mm +++ b/examples/common/entry/entry_osx.mm @@ -9,7 +9,7 @@ #import -#include +#include #include #include diff --git a/examples/common/entry/entry_sdl.cpp b/examples/common/entry/entry_sdl.cpp index b8d051ce5..f9899b66e 100644 --- a/examples/common/entry/entry_sdl.cpp +++ b/examples/common/entry/entry_sdl.cpp @@ -21,7 +21,7 @@ BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG("-Wextern-c-compat") #include BX_PRAGMA_DIAGNOSTIC_POP() -#include +#include #if defined(None) // X11 defines this... # undef None #endif // defined(None) diff --git a/examples/common/entry/entry_windows.cpp b/examples/common/entry/entry_windows.cpp index f4d0defd9..18e647d78 100644 --- a/examples/common/entry/entry_windows.cpp +++ b/examples/common/entry/entry_windows.cpp @@ -7,7 +7,7 @@ #if ENTRY_CONFIG_USE_NATIVE && BX_PLATFORM_WINDOWS -#include +#include #include #include diff --git a/include/bgfx/bgfx.h b/include/bgfx/bgfx.h index 8b79aaa59..1ffe55400 100644 --- a/include/bgfx/bgfx.h +++ b/include/bgfx/bgfx.h @@ -12,8 +12,6 @@ #ifndef BGFX_H_HEADER_GUARD #define BGFX_H_HEADER_GUARD -#define BGFX_IDL_CPP 1 - #include // va_list #include // uint32_t #include // NULL diff --git a/include/bgfx/platform.h b/include/bgfx/platform.h deleted file mode 100644 index 7e561c818..000000000 --- a/include/bgfx/platform.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright 2011-2026 Branimir Karadzic. All rights reserved. - * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE - */ - -#ifndef BGFX_PLATFORM_H_HEADER_GUARD -#define BGFX_PLATFORM_H_HEADER_GUARD - -// NOTICE: -// This header file contains platform specific interfaces. It is only -// necessary to use this header in conjunction with creating windows. - -#include "bgfx.h" - -#if !BGFX_IDL_CPP - -namespace bgfx -{ - /// Render frame enum. - /// - /// @attention C99's equivalent binding is `bgfx_render_frame_t`. - /// - struct RenderFrame - { - enum Enum - { - NoContext, - Render, - Timeout, - Exiting, - - Count - }; - }; - - /// Render frame. - /// - /// @param _msecs Timeout in milliseconds. - /// - /// @returns Current renderer state. See: `bgfx::RenderFrame`. - /// - /// @attention `bgfx::renderFrame` is blocking call. It waits for - /// `bgfx::frame` to be called from API thread to process frame. - /// If timeout value is passed call will timeout and return even - /// if `bgfx::frame` is not called. - /// - /// @warning This call should be only used on platforms that don't - /// allow creating separate rendering thread. If it is called before - /// to bgfx::init, render thread won't be created by bgfx::init call. - /// - /// @attention C99's equivalent binding is `bgfx_render_frame`. - /// - RenderFrame::Enum renderFrame(int32_t _msecs = -1); - - /// Set platform data. - /// - /// @warning Must be called before `bgfx::init`. - /// - /// @attention C99's equivalent binding is `bgfx_set_platform_data`. - /// - void setPlatformData(const PlatformData& _data); - - /// Internal data. - /// - /// @attention C99's equivalent binding is `bgfx_internal_data_t`. - /// - struct InternalData - { - const struct Caps* caps; //!< Renderer capabilities. - void* context; //!< GL context, or D3D device. - }; - - /// Get internal data for interop. - /// - /// @attention It's expected you understand some bgfx internals before you - /// use this call. - /// - /// @warning Must be called only on render thread. - /// - /// @attention C99's equivalent binding is `bgfx_get_internal_data`. - /// - const InternalData* getInternalData(); - - /// Override internal texture with externally created texture. Previously - /// created internal texture will released. - /// - /// @attention It's expected you understand some bgfx internals before you - /// use this call. - /// - /// @param[in] _handle Texture handle. - /// @param[in] _ptr Native API pointer to texture. - /// @param[in] _layerIndex Layer index for texture arrays (only implemented for D3D11). - /// - /// @returns Native API pointer to texture. If result is 0, texture is not created yet from the - /// main thread. - /// - /// @warning Must be called only on render thread. - /// - /// @attention C99's equivalent binding is `bgfx_override_internal_texture_ptr`. - /// - uintptr_t overrideInternal(TextureHandle _handle, uintptr_t _ptr, uint16_t _layerIndex = 0); - - /// Override internal texture by creating new texture. Previously created - /// internal texture will released. - /// - /// @attention It's expected you understand some bgfx internals before you - /// use this call. - /// - /// @param[in] _handle Texture handle. - /// @param[in] _width Width. - /// @param[in] _height Height. - /// @param[in] _numMips Number of mip-maps. - /// @param[in] _format Texture format. See: `TextureFormat::Enum`. - /// @param[in] _flags Default texture sampling mode is linear, and wrap mode - /// is repeat. - /// - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap - /// mode. - /// - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic - /// sampling. - /// - /// @returns Native API pointer to texture. If result is 0, texture is not created yet from the - /// main thread. - /// - /// @warning Must be called only on render thread. - /// - /// @attention C99's equivalent binding is `bgfx_override_internal_texture`. - /// - uintptr_t overrideInternal( - TextureHandle _handle - , uint16_t _width - , uint16_t _height - , uint8_t _numMips - , TextureFormat::Enum _format - , uint64_t _flags = BGFX_TEXTURE_NONE|BGFX_SAMPLER_NONE - ); - -} // namespace bgfx - -#endif // BGFX_IDL_CPP - -#endif // BGFX_PLATFORM_H_HEADER_GUARD diff --git a/scripts/temp.bgfx.hpp b/scripts/temp.bgfx.hpp index bb9ef734e..a4f2ccbf6 100644 --- a/scripts/temp.bgfx.hpp +++ b/scripts/temp.bgfx.hpp @@ -12,8 +12,6 @@ #ifndef BGFX_H_HEADER_GUARD #define BGFX_H_HEADER_GUARD -#define BGFX_IDL_CPP 1 - #include // va_list #include // uint32_t #include // NULL diff --git a/scripts/temp.bgfx.idl.inl b/scripts/temp.bgfx.idl.inl index 97bfe2dd1..3ee3fedfe 100644 --- a/scripts/temp.bgfx.idl.inl +++ b/scripts/temp.bgfx.idl.inl @@ -50,6 +50,8 @@ BGFX_C99_STRUCT_SIZE_CHECK(bgfx::InternalData, bgfx_internal_data_t); #undef BGFX_C99_STRUCT_SIZE_CHECK +#if BGFX_CONFIG_C99_API + $c99 /* user define functions */ @@ -99,3 +101,5 @@ BGFX_C_API bgfx_interface_vtbl_t* bgfx_get_interface(uint32_t _version) return NULL; } + +#endif // BGFX_CONFIG_C99_API diff --git a/src/bgfx.idl.inl b/src/bgfx.idl.inl index 48f47e2f4..a77509909 100644 --- a/src/bgfx.idl.inl +++ b/src/bgfx.idl.inl @@ -50,6 +50,8 @@ BGFX_C99_STRUCT_SIZE_CHECK(bgfx::InternalData, bgfx_internal_data_t); #undef BGFX_C99_STRUCT_SIZE_CHECK +#if BGFX_CONFIG_C99_API + BGFX_C_API void bgfx_attachment_init(bgfx_attachment_t* _this, bgfx_texture_handle_t _handle, bgfx_access_t _access, uint16_t _layer, uint16_t _numLayers, uint16_t _mip, uint8_t _resolve) { bgfx::Attachment* This = (bgfx::Attachment*)_this; @@ -1545,3 +1547,5 @@ BGFX_C_API bgfx_interface_vtbl_t* bgfx_get_interface(uint32_t _version) return NULL; } + +#endif // BGFX_CONFIG_C99_API diff --git a/src/bgfx_p.h b/src/bgfx_p.h index e9a042417..58d307de5 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -141,7 +141,6 @@ namespace bgfx #include #include -#include #include #include "shader.h" #include "vertexlayout.h" diff --git a/src/config.h b/src/config.h index 5a752b361..20254ee32 100644 --- a/src/config.h +++ b/src/config.h @@ -546,4 +546,9 @@ static_assert(BGFX_CONFIG_MAX_VERTEX_STREAMS < 32, "Must be less than 32!"); # define BGFX_CONFIG_ENCODER_API_ONLY 0 #endif // BGFX_CONFIG_ENCODER_API_ONLY +/// C99 API is used for shared library and language bindings. +#ifndef BGFX_CONFIG_C99_API +# define BGFX_CONFIG_C99_API 1 +#endif // BGFX_CONFIG_C99_API + #endif // BGFX_CONFIG_H_HEADER_GUARD