This commit is contained in:
Ilusha 2024-03-16 12:07:49 +03:00
parent 65cb26a627
commit 1ead32d84a
71 changed files with 199 additions and 282 deletions

View file

@ -10,11 +10,14 @@ file(GLOB HEADERS "./public/*.hpp")
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})
target_include_directories(${PROJECT_NAME} PUBLIC ./public/)
target_include_directories(${PROJECT_NAME} PRIVATE ${BINDINGS_INCLUDE})
target_link_libraries(${PROJECT_NAME} PUBLIC Strings Math Utils)
target_link_libraries(${PROJECT_NAME} PUBLIC Strings Math Allocators)
target_link_libraries(${PROJECT_NAME} PRIVATE ${BINDINGS_LIBS})
### -------------------------- Examples -------------------------- ###
add_executable(${PROJECT_NAME}Example ./examples/Example.cpp)
target_link_libraries(${PROJECT_NAME}Example ${PROJECT_NAME} ${BINDINGS_LIBS})
target_include_directories(${PROJECT_NAME}Example PRIVATE ${BINDINGS_INCLUDE})
add_executable(Example${PROJECT_NAME} ./examples/Example.cpp)
target_link_libraries(Example${PROJECT_NAME} ${PROJECT_NAME} ${BINDINGS_LIBS})
target_include_directories(Example${PROJECT_NAME} PRIVATE ${BINDINGS_INCLUDE})
file(COPY "examples/Font.ttf" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/")

BIN
Graphics/examples/Font.ttf Normal file

Binary file not shown.

View file

@ -1,6 +1,7 @@
#include "GraphicsCommon.hpp"
#include "MathCommon.hpp"
namespace tp {
static ModuleManifest* deps[] = { &gModuleStrings, &gModuleMath, nullptr };
static ModuleManifest* deps[] = { &gModuleAllocators, nullptr };
ModuleManifest gModuleGraphics = ModuleManifest("Graphics", nullptr, nullptr, deps);
}

View file

@ -71,7 +71,7 @@ void Graphics::Canvas::popClamp() {
}
void Graphics::Canvas::text(
const String& string, const RectF& aRec, halnf size, Align align, halnf marging, const RGBA& col
const char* string, const RectF& aRec, halnf size, Align align, halnf marging, const RGBA& col
) {
RectF rec = { aRec.x + marging, aRec.y + marging, aRec.z - marging * 2, aRec.w - marging * 2 };
@ -107,7 +107,7 @@ void Graphics::Canvas::text(
nvgTextAlign(mContext->vg, alignNVG);
nvgText(mContext->vg, centerX, centerY, string.read(), nullptr);
nvgText(mContext->vg, centerX, centerY, string, nullptr);
popClamp();
}

View file

@ -2,7 +2,7 @@
#include "GraphicsCommon.hpp"
// TODO : fix this ugly shit
// TODO : ugly
namespace tp {
class Window;
@ -85,7 +85,7 @@ namespace tp {
void pushClamp(const RectF& rec);
void popClamp();
void rect(const RectF& rec, const RGBA& col, halnf round = 0);
void text(const String&, const RectF&, halnf size, Align, halnf marging, const RGBA&);
void text(const char*, const RectF&, halnf size, Align, halnf marging, const RGBA&);
// TODO : API

View file

@ -2,9 +2,10 @@
#include "Color.hpp"
#include "Rect.hpp"
#include "Strings.hpp"
#include "Timing.hpp"
#include "Allocators.hpp"
namespace tp {
extern ModuleManifest gModuleGraphics;
}