Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cmake #535

Closed
wants to merge 23 commits into from
Closed

Cmake #535

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
14a393a
Add repeat fit mode to image decorator (#493)
viseztrance Aug 7, 2023
69479d6
Update Tracy dependency for compatibility with v0.9
mikke89 Aug 20, 2023
eb1d6ee
Add flexbox chat benchmark (see #498)
mikke89 Aug 20, 2023
cda1db7
Update readme.md gallery
mikke89 Aug 23, 2023
a9bb4ac
Fix usage of data variables in selected `option`s (#510)
Dakror Sep 17, 2023
131a963
Transforms: Disallow percentages in perspective and translateZ
mikke89 Sep 22, 2023
6cbf961
Minor layout details cleanup
mikke89 Sep 22, 2023
a123c9d
Set CMake minimum version to 3.5
mikke89 Sep 22, 2023
eeb380a
Make the unit tests runnable with RTTI disabled
mikke89 Sep 22, 2023
70d0d5e
Add rmlui_static_cast to assert validity of down casts, see #514
mikke89 Sep 22, 2023
a602da2
Update comments in ElementDocument::Show based on #515
mikke89 Sep 26, 2023
1607e10
Readme: Fix outdated link
mikke89 Oct 1, 2023
4c6597a
Samples: Make input text fields left-aligned
mikke89 Oct 3, 2023
2ec97da
Fix shrink-to-fit width in cases with 'box-sizing: border-box'
mikke89 Oct 11, 2023
ee2986e
Visual tests: Make search box text left-aligned again
mikke89 Oct 11, 2023
8a94ab7
Make flex containers and tables with fixed width work in shrink-to-fi…
mikke89 Oct 11, 2023
3b75dca
Update tracy integration, allow parent projects to include RmlUi prof…
mikke89 Sep 30, 2023
f43ee36
Merge pull request #518 from mikke89/tracy
mikke89 Oct 11, 2023
836e6c4
GLFW backends: Properly convert mouse position to pixel coordinates, …
mikke89 Oct 16, 2023
61606db
GLFW backend: Fix mouse position scaling ratio, see #521
mikke89 Oct 17, 2023
1d9b651
GL3 backend: Set forward compatibility flag to fix running on macOS (…
NaLiJa Oct 18, 2023
d3876e6
CMake: Small fixes for macOS build (#525)
NaLiJa Oct 21, 2023
25d242b
Minimal changes to get the demos working on macos (not deployable tho…
Nov 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Backends/RmlUi_Backend_GLFW_GL2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ static void SetupCallbacks(GLFWwindow* window)
glfwSetCursorEnterCallback(window, [](GLFWwindow* /*window*/, int entered) { RmlGLFW::ProcessCursorEnterCallback(data->context, entered); });

// Mouse input
glfwSetCursorPosCallback(window, [](GLFWwindow* /*window*/, double xpos, double ypos) {
RmlGLFW::ProcessCursorPosCallback(data->context, xpos, ypos, data->glfw_active_modifiers);
glfwSetCursorPosCallback(window, [](GLFWwindow* window, double xpos, double ypos) {
RmlGLFW::ProcessCursorPosCallback(data->context, window, xpos, ypos, data->glfw_active_modifiers);
});

glfwSetMouseButtonCallback(window, [](GLFWwindow* /*window*/, int button, int action, int mods) {
Expand Down
6 changes: 4 additions & 2 deletions Backends/RmlUi_Backend_GLFW_GL3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ bool Backend::Initialize(const char* name, int width, int height, bool allow_res
glfwWindowHint(GLFW_RESIZABLE, allow_resize ? GLFW_TRUE : GLFW_FALSE);
glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE);

glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);

GLFWwindow* window = glfwCreateWindow(width, height, name, nullptr, nullptr);
if (!window)
return false;
Expand Down Expand Up @@ -242,8 +244,8 @@ static void SetupCallbacks(GLFWwindow* window)
glfwSetCursorEnterCallback(window, [](GLFWwindow* /*window*/, int entered) { RmlGLFW::ProcessCursorEnterCallback(data->context, entered); });

// Mouse input
glfwSetCursorPosCallback(window, [](GLFWwindow* /*window*/, double xpos, double ypos) {
RmlGLFW::ProcessCursorPosCallback(data->context, xpos, ypos, data->glfw_active_modifiers);
glfwSetCursorPosCallback(window, [](GLFWwindow* window, double xpos, double ypos) {
RmlGLFW::ProcessCursorPosCallback(data->context, window, xpos, ypos, data->glfw_active_modifiers);
});

glfwSetMouseButtonCallback(window, [](GLFWwindow* /*window*/, int button, int action, int mods) {
Expand Down
4 changes: 2 additions & 2 deletions Backends/RmlUi_Backend_GLFW_VK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ static void SetupCallbacks(GLFWwindow* window)
glfwSetCursorEnterCallback(window, [](GLFWwindow* /*window*/, int entered) { RmlGLFW::ProcessCursorEnterCallback(data->context, entered); });

// Mouse input
glfwSetCursorPosCallback(window, [](GLFWwindow* /*window*/, double xpos, double ypos) {
RmlGLFW::ProcessCursorPosCallback(data->context, xpos, ypos, data->glfw_active_modifiers);
glfwSetCursorPosCallback(window, [](GLFWwindow* window, double xpos, double ypos) {
RmlGLFW::ProcessCursorPosCallback(data->context, window, xpos, ypos, data->glfw_active_modifiers);
});

glfwSetMouseButtonCallback(window, [](GLFWwindow* /*window*/, int button, int action, int mods) {
Expand Down
4 changes: 4 additions & 0 deletions Backends/RmlUi_Backend_SDL_GL3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <RmlUi/Core/Context.h>
#include <RmlUi/Core/Core.h>
#include <RmlUi/Core/FileInterface.h>
#include <RmlUi/Core/Profiling.h>
#include <SDL.h>
#include <SDL_image.h>

Expand Down Expand Up @@ -321,4 +322,7 @@ void Backend::PresentFrame()

data->render_interface.EndFrame();
SDL_GL_SwapWindow(data->window);

// Optional, used to mark frames during performance profiling.
RMLUI_FrameMark;
}
16 changes: 14 additions & 2 deletions Backends/RmlUi_Platform_GLFW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <RmlUi/Core/Context.h>
#include <RmlUi/Core/Input.h>
#include <RmlUi/Core/Log.h>
#include <RmlUi/Core/Math.h>
#include <RmlUi/Core/StringUtilities.h>
#include <RmlUi/Core/SystemInterface.h>
#include <GLFW/glfw3.h>
Expand Down Expand Up @@ -135,12 +136,23 @@ bool RmlGLFW::ProcessCursorEnterCallback(Rml::Context* context, int entered)
return result;
}

bool RmlGLFW::ProcessCursorPosCallback(Rml::Context* context, double xpos, double ypos, int mods)
bool RmlGLFW::ProcessCursorPosCallback(Rml::Context* context, GLFWwindow* window, double xpos, double ypos, int mods)
{
if (!context)
return true;

bool result = context->ProcessMouseMove(int(xpos), int(ypos), RmlGLFW::ConvertKeyModifiers(mods));
using Rml::Vector2i;
using Vector2d = Rml::Vector2<double>;

Vector2i window_size, framebuffer_size;
glfwGetWindowSize(window, &window_size.x, &window_size.y);
glfwGetFramebufferSize(window, &framebuffer_size.x, &framebuffer_size.y);

// Convert from mouse position in GLFW screen coordinates to framebuffer coordinates (pixels) used by RmlUi.
const Vector2d mouse_pos = Vector2d(xpos, ypos) * (Vector2d(framebuffer_size) / Vector2d(window_size));
const Vector2i mouse_pos_round = {int(Rml::Math::Round(mouse_pos.x)), int(Rml::Math::Round(mouse_pos.y))};

bool result = context->ProcessMouseMove(mouse_pos_round.x, mouse_pos_round.y, RmlGLFW::ConvertKeyModifiers(mods));
return result;
}

Expand Down
2 changes: 1 addition & 1 deletion Backends/RmlUi_Platform_GLFW.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace RmlGLFW {
bool ProcessKeyCallback(Rml::Context* context, int key, int action, int mods);
bool ProcessCharCallback(Rml::Context* context, unsigned int codepoint);
bool ProcessCursorEnterCallback(Rml::Context* context, int entered);
bool ProcessCursorPosCallback(Rml::Context* context, double xpos, double ypos, int mods);
bool ProcessCursorPosCallback(Rml::Context* context, GLFWwindow* window, double xpos, double ypos, int mods);
bool ProcessMouseButtonCallback(Rml::Context* context, int button, int action, int mods);
bool ProcessScrollCallback(Rml::Context* context, double yoffset, int mods);
void ProcessFramebufferSizeCallback(Rml::Context* context, int width, int height);
Expand Down
4 changes: 2 additions & 2 deletions Backends/RmlUi_Renderer_GL2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ bool RenderInterface_GL2::GenerateTexture(Rml::TextureHandle& texture_handle, co
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

texture_handle = (Rml::TextureHandle)texture_id;

Expand Down
4 changes: 2 additions & 2 deletions Backends/RmlUi_Renderer_GL3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,8 +731,8 @@ bool RenderInterface_GL3::GenerateTexture(Rml::TextureHandle& texture_handle, co
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

texture_handle = (Rml::TextureHandle)texture_id;

Expand Down
20 changes: 0 additions & 20 deletions CMake/Modules/FindTracy.cmake

This file was deleted.

14 changes: 14 additions & 0 deletions CMake/ResourceTree.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function(resourceTree VAR SOURCE_PATH DESTINATION PATTERN)
file(GLOB_RECURSE _LIST CONFIGURE_DEPENDS ${SOURCE_PATH}/${PATTERN})
foreach (RESOURCE ${_LIST})
get_filename_component(_PARENT ${RESOURCE} DIRECTORY)
if (${_PARENT} STREQUAL ${SOURCE_PATH})
set(_DESTINATION ${DESTINATION})
else ()
file(RELATIVE_PATH _DESTINATION ${SOURCE_PATH} ${_PARENT})
set(_DESTINATION ${DESTINATION}/${_DESTINATION})
endif ()
set_property(SOURCE ${RESOURCE} PROPERTY MACOSX_PACKAGE_LOCATION ${_DESTINATION})
endforeach (RESOURCE)
set(${VAR} ${_LIST} PARENT_SCOPE)
endfunction()
93 changes: 69 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Build script for RmlUi ===========
#===================================

cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.5)

if(APPLE)
# This has to be before most other options so CMake properly handles the
Expand Down Expand Up @@ -254,29 +254,64 @@ else()
endif()
endif()

option(ENABLE_TRACY_PROFILING "Enable profiling with Tracy. Source files can be placed in Dependencies/tracy." OFF)
if( ENABLE_TRACY_PROFILING )
find_package(Tracy REQUIRED)
function(EnableConfigurationType name enable)
if(enable)
list(APPEND CMAKE_CONFIGURATION_TYPES "${name}")
list(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
else()
list(REMOVE_ITEM CMAKE_CONFIGURATION_TYPES "${name}")
endif()
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "List of configurations to enable" FORCE)
endfunction()

include_directories(${TRACY_INCLUDE_DIR})
option(RMLUI_TRACY_PROFILING "Enable profiling with Tracy. Source files can be placed in Dependencies/tracy." OFF)
if( RMLUI_TRACY_PROFILING )
option(RMLUI_TRACY_MEMORY_PROFILING "Overload global operator new/delete to track memory allocations in Tracy." ON)

if( CMAKE_CONFIGURATION_TYPES )
list(APPEND CMAKE_CONFIGURATION_TYPES Tracy)
list(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
"Add the configurations that we need"
FORCE)
set(CMAKE_C_FLAGS_TRACY "${CMAKE_CXX_FLAGS_RELEASE} -DRMLUI_ENABLE_PROFILING")
set(CMAKE_CXX_FLAGS_TRACY "${CMAKE_CXX_FLAGS_RELEASE} -DRMLUI_ENABLE_PROFILING")
set(CMAKE_EXE_LINKER_FLAGS_TRACY "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
set(CMAKE_SHARED_LINKER_FLAGS_TRACY "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
option(RMLUI_TRACY_CONFIGURATION "Enable a separate Tracy configuration type for multi-config generators such as Visual Studio, otherwise enable Tracy in all configurations." ON)

if( RMLUI_TRACY_CONFIGURATION )
EnableConfigurationType(Tracy ON)
list(APPEND CMAKE_MAP_IMPORTED_CONFIG_TRACY Release)
set(CMAKE_C_FLAGS_TRACY "${CMAKE_C_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_TRACY "${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_EXE_LINKER_FLAGS_TRACY "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
set(CMAKE_SHARED_LINKER_FLAGS_TRACY "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
else()
EnableConfigurationType(Tracy OFF)
endif()
endif()

if(NOT TARGET Tracy::TracyClient)
find_package(Tracy QUIET)
endif()

if(NOT TARGET Tracy::TracyClient)
message("Trying to add Tracy from subdirectory 'Dependencies/tracy'.")
add_subdirectory("Dependencies/tracy")
endif()

if(NOT TARGET Tracy::TracyClient)
message(FATAL_ERROR "Tracy client not found. Either (a) make sure target Tracy::TracyClient is available from parent project,"
"(b) Tracy can be found as a config package, or (c) Tracy source files are located in 'Dependencies/Tracy'.")
endif()

if( CMAKE_CONFIGURATION_TYPES AND RMLUI_TRACY_CONFIGURATION )
message("-- Tracy profiling enabled in configuration 'Tracy'.")
set(RMLUI_TRACY_CONDITION "$<CONFIG:Tracy>")
else()
message("-- Tracy profiling enabled.")
list(APPEND CORE_PUBLIC_DEFS -DRMLUI_ENABLE_PROFILING)
set(RMLUI_TRACY_CONDITION "1")
endif()

list(APPEND CORE_PUBLIC_LINK_LIBS "$<${RMLUI_TRACY_CONDITION}:Tracy::TracyClient>")
list(APPEND CORE_PUBLIC_DEFS "$<${RMLUI_TRACY_CONDITION}:RMLUI_TRACY_PROFILING>")
if(RMLUI_TRACY_MEMORY_PROFILING)
list(APPEND CORE_PRIVATE_DEFS "$<${RMLUI_TRACY_CONDITION}:RMLUI_TRACY_MEMORY_PROFILING>")
endif()
elseif( CMAKE_CONFIGURATION_TYPES )
list(REMOVE_ITEM CMAKE_CONFIGURATION_TYPES Tracy)
EnableConfigurationType(Tracy OFF)
endif()

option(ENABLE_LOTTIE_PLUGIN "Enable plugin for Lottie animations. Requires the rlottie library." OFF)
Expand Down Expand Up @@ -383,7 +418,7 @@ elseif( ENABLE_LOTTIE_PLUGIN )

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/rlottie/build)
find_package(rlottie CONFIG)
find_path(rlottie_INCLUDE_DIR rlottie.h HINTS ${rlottie_DIR} $ENV{rlottie_DIR} PATH_SUFFIXES inc rlottie/inc )
find_path(rlottie_INCLUDE_DIR rlottie.h HINTS ${rlottie_DIR} $ENV{rlottie_DIR} PATH_SUFFIXES inc rlottie/inc ../inc)

if(rlottie_FOUND AND rlottie_INCLUDE_DIR)
message("-- Can Lottie plugin be added to RmlCore - yes - rlottie library found")
Expand Down Expand Up @@ -600,12 +635,14 @@ if(NOT BUILD_FRAMEWORK)
target_include_directories(RmlCore PRIVATE ${CORE_INCLUDE_DIRS})
target_include_directories(RmlCore INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Include> $<INSTALL_INTERFACE:include>)
target_link_libraries(RmlCore PRIVATE ${CORE_LINK_LIBS})
target_link_libraries(RmlCore PUBLIC ${CORE_PUBLIC_LINK_LIBS})
target_link_libraries(RmlDebugger RmlCore)
target_compile_definitions(RmlCore PRIVATE ${CORE_PRIVATE_DEFS})
target_compile_definitions(RmlCore PUBLIC ${CORE_PUBLIC_DEFS})
else()
target_include_directories(RmlUi PRIVATE ${CORE_INCLUDE_DIRS})
target_link_libraries(RmlUi PRIVATE ${CORE_LINK_LIBS})
target_link_libraries(RmlUi PUBLIC ${CORE_PUBLIC_LINK_LIBS})
target_compile_definitions(RmlUi PRIVATE ${CORE_PRIVATE_DEFS})
target_compile_definitions(RmlUi PUBLIC ${CORE_PUBLIC_DEFS})
endif()
Expand All @@ -625,12 +662,20 @@ endif()
# Build samples ====================
#===================================

include(ResourceTree)

# Build and link the samples
macro(bl_sample NAME)
macro(bl_sample NAME SAMPLE_SUB_DIR)
if (WIN32)
add_executable(${NAME} WIN32 ${${NAME}_SRC_FILES} ${${NAME}_HDR_FILES} )
elseif(APPLE)
add_executable(${NAME} MACOSX_BUNDLE ${${NAME}_SRC_FILES} ${${NAME}_HDR_FILES} )
resourceTree(ASSETS ${SAMPLES_DIR}/assets Resources/assets *)
resourceTree(DATA ${SAMPLES_DIR}/${SAMPLE_SUB_DIR}/data Resources/${SAMPLE_SUB_DIR}/data *)
resourceTree(LUA ${SAMPLES_DIR}/${SAMPLE_SUB_DIR}/lua Resources/${SAMPLE_SUB_DIR}/lua *)

set(RESOURCE_FILES ${ASSETS} ${DATA} ${LUA})

add_executable(${NAME} MACOSX_BUNDLE ${${NAME}_SRC_FILES} ${${NAME}_HDR_FILES} ${RESOURCE_FILES})

# The first rpath is to the proper location where the framework/library SHOULD be, the second is to the location actually seen
# in the build environment
Expand Down Expand Up @@ -668,7 +713,7 @@ if(BUILD_SAMPLES OR BUILD_TESTING)
)
endif()

set(SAMPLES_DIR opt/RmlUi/Samples CACHE PATH "Path to samples directory.")
set(SAMPLES_DIR ${PROJECT_SOURCE_DIR}/Samples CACHE PATH "Path to samples directory.")
if(WIN32)
mark_as_advanced(SAMPLES_DIR)
endif()
Expand Down Expand Up @@ -826,7 +871,7 @@ if(BUILD_SAMPLES)

# Build and install the basic samples
foreach(sample ${samples})
bl_sample(${sample} ${sample_LIBRARIES})
bl_sample(${sample} basic/${sample} ${sample_LIBRARIES} )

# The samples always set this as their current working directory
install(DIRECTORY DESTINATION ${SAMPLES_DIR}/basic/${sample})
Expand All @@ -838,7 +883,7 @@ if(BUILD_SAMPLES)
# Build and install the tutorials
foreach(tutorial ${tutorials})
set(tutorial_fullname tutorial_${tutorial})
bl_sample(${tutorial_fullname} ${sample_LIBRARIES})
bl_sample(${tutorial_fullname} tutorial/${tutorial} ${sample_LIBRARIES})

# The tutorials always set this as their current working directory
install(DIRECTORY DESTINATION ${SAMPLES_DIR}/tutorial/${tutorial})
Expand All @@ -848,14 +893,14 @@ if(BUILD_SAMPLES)
endforeach()

# Build and install invaders sample
bl_sample(invaders ${sample_LIBRARIES})
bl_sample(invaders invaders ${sample_LIBRARIES})
install(DIRECTORY DESTINATION ${SAMPLES_DIR}/invaders)
install(TARGETS invaders
RUNTIME DESTINATION ${SAMPLES_DIR}/invaders
BUNDLE DESTINATION ${SAMPLES_DIR})

if(BUILD_LUA_BINDINGS)
bl_sample(luainvaders RmlLua ${sample_LIBRARIES} ${LUA_BINDINGS_LINK_LIBS})
bl_sample(luainvaders luainvaders RmlLua ${sample_LIBRARIES} ${LUA_BINDINGS_LINK_LIBS})
install(DIRECTORY DESTINATION ${SAMPLES_DIR}/luainvaders)
install(TARGETS luainvaders
RUNTIME DESTINATION ${SAMPLES_DIR}/luainvaders
Expand Down
5 changes: 2 additions & 3 deletions Include/RmlUi/Core/Profiling.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@
#ifndef RMLUI_CORE_PROFILING_H
#define RMLUI_CORE_PROFILING_H

#ifdef RMLUI_ENABLE_PROFILING
#ifdef RMLUI_TRACY_PROFILING

#define TRACY_ENABLE
#include <Tracy.hpp>
#include <tracy/Tracy.hpp>

#define RMLUI_ZoneNamed(varname, active) ZoneNamed(varname, active)
#define RMLUI_ZoneNamedN(varname, name, active) ZoneNamedN(varname, name, active)
Expand Down
16 changes: 16 additions & 0 deletions Include/RmlUi/Core/Traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#define RMLUI_CORE_TRAITS_H

#include "../Config/Config.h"
#include "Debug.h"
#include "Header.h"
#include <type_traits>

Expand Down Expand Up @@ -136,6 +137,13 @@ Derived rmlui_dynamic_cast(Base base_instance)
return nullptr;
}

template <class Derived, class Base>
Derived rmlui_static_cast(Base base_instance)
{
static_assert(std::is_pointer<Derived>::value && std::is_pointer<Base>::value, "rmlui_static_cast can only cast pointer types");
return static_cast<Derived>(base_instance);
}

template <class T>
const char* rmlui_type_name(const T& /*var*/)
{
Expand All @@ -162,6 +170,14 @@ Derived rmlui_dynamic_cast(Base base_instance)
return dynamic_cast<Derived>(base_instance);
}

template <class Derived, class Base>
Derived rmlui_static_cast(Base base_instance)
{
static_assert(std::is_pointer<Derived>::value && std::is_pointer<Base>::value, "rmlui_static_cast can only cast pointer types");
RMLUI_ASSERT(dynamic_cast<Derived>(base_instance));
return static_cast<Derived>(base_instance);
}

template <class T>
const char* rmlui_type_name(const T& var)
{
Expand Down
Binary file added Samples/assets/alien_small.tga
Binary file not shown.
Loading