SDL2 and a Open Sans font added
This commit is contained in:
parent
6e8e09149f
commit
948a9a76a6
@ -1,20 +1,21 @@
|
|||||||
# Minimum required version of CMake
|
# Minimum required version of CMake
|
||||||
cmake_minimum_required(VERSION 3.20)
|
cmake_minimum_required(VERSION 3.28)
|
||||||
|
|
||||||
# Set the project name, version, homepage, and description
|
# Project setup
|
||||||
project(main VERSION 1.0.0
|
project(main VERSION 1.0.0
|
||||||
HOMEPAGE_URL "https://git.noorlander.info/E.Noorlander/CMake_SDL_CPP.git"
|
HOMEPAGE_URL "https://git.noorlander.info/E.Noorlander/CMake_SDL_CPP.git"
|
||||||
DESCRIPTION "Demo embedded Linux C++ project"
|
DESCRIPTION "Demo embedded Linux C++ project"
|
||||||
LANGUAGES CXX) # Use CXX for C++ projects
|
LANGUAGES CXX)
|
||||||
|
|
||||||
# Set a custom application name and definitions
|
# Set C++ standard
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
# Set binary name
|
||||||
set(BIN_NAME "test")
|
set(BIN_NAME "test")
|
||||||
add_compile_definitions(APP_NAME="${BIN_NAME}")
|
add_compile_definitions(APP_NAME="${BIN_NAME}")
|
||||||
|
|
||||||
# Set 1 to compile static (Standalone) or 0 to use shared libraries
|
# Set binary suffix based on OS
|
||||||
set(BIN_STATIC 1)
|
|
||||||
|
|
||||||
# Set binary suffix based on the operating system
|
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||||
set(BIN_SUFFIX ".exe")
|
set(BIN_SUFFIX ".exe")
|
||||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||||
@ -25,12 +26,15 @@ else()
|
|||||||
set(BIN_SUFFIX ".bin")
|
set(BIN_SUFFIX ".bin")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# For Windows-specific configurations
|
# Compiler settings for Windows
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
# Uncomment to specify the C++ standard explicitly
|
add_compile_options(/std:c++17)
|
||||||
add_compile_options(/std:c++11)
|
|
||||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
|
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
|
||||||
set(BUILD_SHARED_LIBS TRUE)
|
endif()
|
||||||
|
|
||||||
|
# SDL2 & SDL2_ttf setup
|
||||||
|
if(BIN_STATIC)
|
||||||
|
set(SDL2_USE_STATIC_LIBS ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# List of subprojects to include (e.g., external libraries or modules)
|
# List of subprojects to include (e.g., external libraries or modules)
|
||||||
@ -38,15 +42,21 @@ set(SubProjects
|
|||||||
myDynamicLibrary # Example subproject, replace with actual subprojects
|
myDynamicLibrary # Example subproject, replace with actual subprojects
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create the main executable, specifying the source file
|
# Copy the font
|
||||||
|
file(COPY ${CMAKE_SOURCE_DIR}/include/Open_Sans/static/OpenSans-Regular.ttf DESTINATION ${CMAKE_BINARY_DIR}/assets)
|
||||||
|
|
||||||
|
# Add executable
|
||||||
add_executable(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp)
|
add_executable(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp)
|
||||||
|
|
||||||
# Set target properties like output name and suffix
|
# Set target properties (output name & suffix)
|
||||||
set_target_properties(${PROJECT_NAME}
|
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${BIN_NAME} SUFFIX ${BIN_SUFFIX})
|
||||||
PROPERTIES
|
|
||||||
OUTPUT_NAME ${BIN_NAME}
|
# Include SDL2
|
||||||
SUFFIX ${BIN_SUFFIX}
|
find_package(SDL2 REQUIRED)
|
||||||
)
|
find_package(SDL2_ttf REQUIRED)
|
||||||
|
|
||||||
|
target_include_directories(${PROJECT_NAME} PRIVATE ${SDL2_INCLUDE_DIRS} ${SDL2_TTF_INCLUDE_DIRS})
|
||||||
|
target_link_libraries(${PROJECT_NAME} PRIVATE SDL2::SDL2 SDL2_ttf::SDL2_ttf)
|
||||||
|
|
||||||
# Loop over the subprojects and link them to the main executable
|
# Loop over the subprojects and link them to the main executable
|
||||||
foreach(Project IN LISTS SubProjects)
|
foreach(Project IN LISTS SubProjects)
|
||||||
@ -56,19 +66,13 @@ foreach(Project IN LISTS SubProjects)
|
|||||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/${Project})
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/${Project})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Link the subproject to the main project executable
|
target_link_libraries(${PROJECT_NAME} PRIVATE ${Project})
|
||||||
if(BIN_STATIC)
|
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE ${Project} -static)
|
|
||||||
else()
|
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE ${Project})
|
|
||||||
endif()
|
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Add processor count and parallel build support
|
# Enable parallel build support
|
||||||
include(ProcessorCount)
|
include(ProcessorCount)
|
||||||
ProcessorCount(N)
|
ProcessorCount(N)
|
||||||
if(NOT N EQUAL 0)
|
if(NOT N EQUAL 0)
|
||||||
set(CTEST_BUILD_FLAGS -j${N})
|
set(CTEST_BUILD_FLAGS -j${N})
|
||||||
set(ctest_test_args ${PROJECT_NAME} PARALLEL_LEVEL ${N})
|
set(ctest_test_args ${PROJECT_NAME} PARALLEL_LEVEL ${N})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
93
include/Open_Sans/OFL.txt
Normal file
93
include/Open_Sans/OFL.txt
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
Copyright 2020 The Open Sans Project Authors (https://github.com/googlefonts/opensans)
|
||||||
|
|
||||||
|
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||||
|
This license is copied below, and is also available with a FAQ at:
|
||||||
|
https://openfontlicense.org
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------
|
||||||
|
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
PREAMBLE
|
||||||
|
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||||
|
development of collaborative font projects, to support the font creation
|
||||||
|
efforts of academic and linguistic communities, and to provide a free and
|
||||||
|
open framework in which fonts may be shared and improved in partnership
|
||||||
|
with others.
|
||||||
|
|
||||||
|
The OFL allows the licensed fonts to be used, studied, modified and
|
||||||
|
redistributed freely as long as they are not sold by themselves. The
|
||||||
|
fonts, including any derivative works, can be bundled, embedded,
|
||||||
|
redistributed and/or sold with any software provided that any reserved
|
||||||
|
names are not used by derivative works. The fonts and derivatives,
|
||||||
|
however, cannot be released under any other type of license. The
|
||||||
|
requirement for fonts to remain under this license does not apply
|
||||||
|
to any document created using the fonts or their derivatives.
|
||||||
|
|
||||||
|
DEFINITIONS
|
||||||
|
"Font Software" refers to the set of files released by the Copyright
|
||||||
|
Holder(s) under this license and clearly marked as such. This may
|
||||||
|
include source files, build scripts and documentation.
|
||||||
|
|
||||||
|
"Reserved Font Name" refers to any names specified as such after the
|
||||||
|
copyright statement(s).
|
||||||
|
|
||||||
|
"Original Version" refers to the collection of Font Software components as
|
||||||
|
distributed by the Copyright Holder(s).
|
||||||
|
|
||||||
|
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||||
|
or substituting -- in part or in whole -- any of the components of the
|
||||||
|
Original Version, by changing formats or by porting the Font Software to a
|
||||||
|
new environment.
|
||||||
|
|
||||||
|
"Author" refers to any designer, engineer, programmer, technical
|
||||||
|
writer or other person who contributed to the Font Software.
|
||||||
|
|
||||||
|
PERMISSION & CONDITIONS
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||||
|
redistribute, and sell modified and unmodified copies of the Font
|
||||||
|
Software, subject to the following conditions:
|
||||||
|
|
||||||
|
1) Neither the Font Software nor any of its individual components,
|
||||||
|
in Original or Modified Versions, may be sold by itself.
|
||||||
|
|
||||||
|
2) Original or Modified Versions of the Font Software may be bundled,
|
||||||
|
redistributed and/or sold with any software, provided that each copy
|
||||||
|
contains the above copyright notice and this license. These can be
|
||||||
|
included either as stand-alone text files, human-readable headers or
|
||||||
|
in the appropriate machine-readable metadata fields within text or
|
||||||
|
binary files as long as those fields can be easily viewed by the user.
|
||||||
|
|
||||||
|
3) No Modified Version of the Font Software may use the Reserved Font
|
||||||
|
Name(s) unless explicit written permission is granted by the corresponding
|
||||||
|
Copyright Holder. This restriction only applies to the primary font name as
|
||||||
|
presented to the users.
|
||||||
|
|
||||||
|
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||||
|
Software shall not be used to promote, endorse or advertise any
|
||||||
|
Modified Version, except to acknowledge the contribution(s) of the
|
||||||
|
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||||
|
permission.
|
||||||
|
|
||||||
|
5) The Font Software, modified or unmodified, in part or in whole,
|
||||||
|
must be distributed entirely under this license, and must not be
|
||||||
|
distributed under any other license. The requirement for fonts to
|
||||||
|
remain under this license does not apply to any document created
|
||||||
|
using the Font Software.
|
||||||
|
|
||||||
|
TERMINATION
|
||||||
|
This license becomes null and void if any of the above conditions are
|
||||||
|
not met.
|
||||||
|
|
||||||
|
DISCLAIMER
|
||||||
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||||
|
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||||
|
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||||
|
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||||
|
OTHER DEALINGS IN THE FONT SOFTWARE.
|
BIN
include/Open_Sans/OpenSans-Italic-VariableFont_wdth,wght.ttf
Normal file
BIN
include/Open_Sans/OpenSans-Italic-VariableFont_wdth,wght.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/OpenSans-VariableFont_wdth,wght.ttf
Normal file
BIN
include/Open_Sans/OpenSans-VariableFont_wdth,wght.ttf
Normal file
Binary file not shown.
100
include/Open_Sans/README.txt
Normal file
100
include/Open_Sans/README.txt
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
Open Sans Variable Font
|
||||||
|
=======================
|
||||||
|
|
||||||
|
This download contains Open Sans as both variable fonts and static fonts.
|
||||||
|
|
||||||
|
Open Sans is a variable font with these axes:
|
||||||
|
wdth
|
||||||
|
wght
|
||||||
|
|
||||||
|
This means all the styles are contained in these files:
|
||||||
|
OpenSans-VariableFont_wdth,wght.ttf
|
||||||
|
OpenSans-Italic-VariableFont_wdth,wght.ttf
|
||||||
|
|
||||||
|
If your app fully supports variable fonts, you can now pick intermediate styles
|
||||||
|
that aren’t available as static fonts. Not all apps support variable fonts, and
|
||||||
|
in those cases you can use the static font files for Open Sans:
|
||||||
|
static/OpenSans_Condensed-Light.ttf
|
||||||
|
static/OpenSans_Condensed-Regular.ttf
|
||||||
|
static/OpenSans_Condensed-Medium.ttf
|
||||||
|
static/OpenSans_Condensed-SemiBold.ttf
|
||||||
|
static/OpenSans_Condensed-Bold.ttf
|
||||||
|
static/OpenSans_Condensed-ExtraBold.ttf
|
||||||
|
static/OpenSans_SemiCondensed-Light.ttf
|
||||||
|
static/OpenSans_SemiCondensed-Regular.ttf
|
||||||
|
static/OpenSans_SemiCondensed-Medium.ttf
|
||||||
|
static/OpenSans_SemiCondensed-SemiBold.ttf
|
||||||
|
static/OpenSans_SemiCondensed-Bold.ttf
|
||||||
|
static/OpenSans_SemiCondensed-ExtraBold.ttf
|
||||||
|
static/OpenSans-Light.ttf
|
||||||
|
static/OpenSans-Regular.ttf
|
||||||
|
static/OpenSans-Medium.ttf
|
||||||
|
static/OpenSans-SemiBold.ttf
|
||||||
|
static/OpenSans-Bold.ttf
|
||||||
|
static/OpenSans-ExtraBold.ttf
|
||||||
|
static/OpenSans_Condensed-LightItalic.ttf
|
||||||
|
static/OpenSans_Condensed-Italic.ttf
|
||||||
|
static/OpenSans_Condensed-MediumItalic.ttf
|
||||||
|
static/OpenSans_Condensed-SemiBoldItalic.ttf
|
||||||
|
static/OpenSans_Condensed-BoldItalic.ttf
|
||||||
|
static/OpenSans_Condensed-ExtraBoldItalic.ttf
|
||||||
|
static/OpenSans_SemiCondensed-LightItalic.ttf
|
||||||
|
static/OpenSans_SemiCondensed-Italic.ttf
|
||||||
|
static/OpenSans_SemiCondensed-MediumItalic.ttf
|
||||||
|
static/OpenSans_SemiCondensed-SemiBoldItalic.ttf
|
||||||
|
static/OpenSans_SemiCondensed-BoldItalic.ttf
|
||||||
|
static/OpenSans_SemiCondensed-ExtraBoldItalic.ttf
|
||||||
|
static/OpenSans-LightItalic.ttf
|
||||||
|
static/OpenSans-Italic.ttf
|
||||||
|
static/OpenSans-MediumItalic.ttf
|
||||||
|
static/OpenSans-SemiBoldItalic.ttf
|
||||||
|
static/OpenSans-BoldItalic.ttf
|
||||||
|
static/OpenSans-ExtraBoldItalic.ttf
|
||||||
|
|
||||||
|
Get started
|
||||||
|
-----------
|
||||||
|
|
||||||
|
1. Install the font files you want to use
|
||||||
|
|
||||||
|
2. Use your app's font picker to view the font family and all the
|
||||||
|
available styles
|
||||||
|
|
||||||
|
Learn more about variable fonts
|
||||||
|
-------------------------------
|
||||||
|
|
||||||
|
https://developers.google.com/web/fundamentals/design-and-ux/typography/variable-fonts
|
||||||
|
https://variablefonts.typenetwork.com
|
||||||
|
https://medium.com/variable-fonts
|
||||||
|
|
||||||
|
In desktop apps
|
||||||
|
|
||||||
|
https://theblog.adobe.com/can-variable-fonts-illustrator-cc
|
||||||
|
https://helpx.adobe.com/nz/photoshop/using/fonts.html#variable_fonts
|
||||||
|
|
||||||
|
Online
|
||||||
|
|
||||||
|
https://developers.google.com/fonts/docs/getting_started
|
||||||
|
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Fonts/Variable_Fonts_Guide
|
||||||
|
https://developer.microsoft.com/en-us/microsoft-edge/testdrive/demos/variable-fonts
|
||||||
|
|
||||||
|
Installing fonts
|
||||||
|
|
||||||
|
MacOS: https://support.apple.com/en-us/HT201749
|
||||||
|
Linux: https://www.google.com/search?q=how+to+install+a+font+on+gnu%2Blinux
|
||||||
|
Windows: https://support.microsoft.com/en-us/help/314960/how-to-install-or-remove-a-font-in-windows
|
||||||
|
|
||||||
|
Android Apps
|
||||||
|
|
||||||
|
https://developers.google.com/fonts/docs/android
|
||||||
|
https://developer.android.com/guide/topics/ui/look-and-feel/downloadable-fonts
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
Please read the full license text (OFL.txt) to understand the permissions,
|
||||||
|
restrictions and requirements for usage, redistribution, and modification.
|
||||||
|
|
||||||
|
You can use them in your products & projects – print or digital,
|
||||||
|
commercial or otherwise.
|
||||||
|
|
||||||
|
This isn't legal advice, please consider consulting a lawyer and see the full
|
||||||
|
license for all details.
|
BIN
include/Open_Sans/static/OpenSans-Bold.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans-Bold.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans-BoldItalic.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans-BoldItalic.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans-ExtraBold.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans-ExtraBold.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans-ExtraBoldItalic.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans-ExtraBoldItalic.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans-Italic.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans-Italic.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans-Light.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans-Light.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans-LightItalic.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans-LightItalic.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans-Medium.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans-Medium.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans-MediumItalic.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans-MediumItalic.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans-Regular.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans-Regular.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans-SemiBold.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans-SemiBold.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans-SemiBoldItalic.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans-SemiBoldItalic.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans_Condensed-Bold.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans_Condensed-Bold.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans_Condensed-BoldItalic.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans_Condensed-BoldItalic.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans_Condensed-ExtraBold.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans_Condensed-ExtraBold.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans_Condensed-ExtraBoldItalic.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans_Condensed-ExtraBoldItalic.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans_Condensed-Italic.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans_Condensed-Italic.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans_Condensed-Light.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans_Condensed-Light.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans_Condensed-LightItalic.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans_Condensed-LightItalic.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans_Condensed-Medium.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans_Condensed-Medium.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans_Condensed-MediumItalic.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans_Condensed-MediumItalic.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans_Condensed-Regular.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans_Condensed-Regular.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans_Condensed-SemiBold.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans_Condensed-SemiBold.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans_Condensed-SemiBoldItalic.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans_Condensed-SemiBoldItalic.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans_SemiCondensed-Bold.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans_SemiCondensed-Bold.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans_SemiCondensed-BoldItalic.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans_SemiCondensed-BoldItalic.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans_SemiCondensed-ExtraBold.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans_SemiCondensed-ExtraBold.ttf
Normal file
Binary file not shown.
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans_SemiCondensed-Italic.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans_SemiCondensed-Italic.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans_SemiCondensed-Light.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans_SemiCondensed-Light.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans_SemiCondensed-LightItalic.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans_SemiCondensed-LightItalic.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans_SemiCondensed-Medium.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans_SemiCondensed-Medium.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans_SemiCondensed-MediumItalic.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans_SemiCondensed-MediumItalic.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans_SemiCondensed-Regular.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans_SemiCondensed-Regular.ttf
Normal file
Binary file not shown.
BIN
include/Open_Sans/static/OpenSans_SemiCondensed-SemiBold.ttf
Normal file
BIN
include/Open_Sans/static/OpenSans_SemiCondensed-SemiBold.ttf
Normal file
Binary file not shown.
Binary file not shown.
@ -1,15 +1,22 @@
|
|||||||
// myDynamicLibrary.cpp
|
// myDynamicLibrary.cpp
|
||||||
|
|
||||||
#include "myDynamicLibrary.h"
|
#include "myDynamicLibrary.h"
|
||||||
#include <iostream>
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void myDynamicLibrary::sayHelloDynamic()
|
string myDynamicLibrary::sayHelloDynamic()
|
||||||
{
|
{
|
||||||
cout << "Hello from the dynamic library!\n";
|
std::string text = "You have given two numbers a ";
|
||||||
cout << "You have given two numbers a ";
|
text += std::to_string(myDynamicLibrary::a);
|
||||||
cout << myDynamicLibrary::a << " and number b ";
|
text += " and number b ";
|
||||||
cout << myDynamicLibrary::b << "\n";
|
text += std::to_string(myDynamicLibrary::b);
|
||||||
|
text += ".";
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
string myDynamicLibrary::text(){
|
||||||
|
return "This is the demo text from the library";
|
||||||
}
|
}
|
||||||
|
|
||||||
int myDynamicLibrary::multiply(){
|
int myDynamicLibrary::multiply(){
|
||||||
|
@ -2,13 +2,16 @@
|
|||||||
|
|
||||||
#ifndef MYDYNAMICLIBRARY_H
|
#ifndef MYDYNAMICLIBRARY_H
|
||||||
#define MYDYNAMICLIBRARY_H
|
#define MYDYNAMICLIBRARY_H
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class myDynamicLibrary{
|
class myDynamicLibrary{
|
||||||
public:
|
public:
|
||||||
int a;
|
int a;
|
||||||
int b;
|
int b;
|
||||||
|
|
||||||
void sayHelloDynamic();
|
std::string text();
|
||||||
|
std::string sayHelloDynamic();
|
||||||
int multiply();
|
int multiply();
|
||||||
int devide();
|
int devide();
|
||||||
};
|
};
|
||||||
|
84
src/main.cpp
84
src/main.cpp
@ -1,20 +1,90 @@
|
|||||||
// main.cpp
|
// main.cpp
|
||||||
#include "../lib/myDynamicLibrary/myDynamicLibrary.h"
|
#include "../lib/myDynamicLibrary/myDynamicLibrary.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include <SDL2/SDL_ttf.h>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
myDynamicLibrary myObj;
|
myDynamicLibrary myObj;
|
||||||
|
|
||||||
int main()
|
const int WINDOW_WIDTH = 800;
|
||||||
{
|
const int WINDOW_HEIGHT = 600;
|
||||||
|
|
||||||
myObj.a = 10;
|
int main(int argc, char* argv[]) {
|
||||||
myObj.b = 5;
|
// SDL en TTF initialiseren
|
||||||
|
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||||
|
std::cerr << "SDL kon niet initialiseren: " << SDL_GetError() << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (TTF_Init() == -1) {
|
||||||
|
std::cerr << "TTF kon niet initialiseren: " << TTF_GetError() << std::endl;
|
||||||
|
SDL_Quit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
myObj.sayHelloDynamic();
|
// SDL Window en Renderer aanmaken
|
||||||
|
SDL_Window* window = SDL_CreateWindow("SDL2 Demo", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_SHOWN);
|
||||||
|
if (!window) {
|
||||||
|
std::cerr << "Kan window niet maken: " << SDL_GetError() << std::endl;
|
||||||
|
TTF_Quit();
|
||||||
|
SDL_Quit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
cout << "Addition: " << myObj.multiply() << endl;
|
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
|
||||||
cout << "Subtraction: " << myObj.devide() << endl;
|
if (!renderer) {
|
||||||
|
std::cerr << "Kan renderer niet maken: " << SDL_GetError() << std::endl;
|
||||||
|
SDL_DestroyWindow(window);
|
||||||
|
TTF_Quit();
|
||||||
|
SDL_Quit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Laad een font
|
||||||
|
TTF_Font* font = TTF_OpenFont("assets/OpenSans-Regular.ttf", 24);
|
||||||
|
if (!font) {
|
||||||
|
std::cerr << "Kan font niet laden: " << TTF_GetError() << std::endl;
|
||||||
|
SDL_DestroyRenderer(renderer);
|
||||||
|
SDL_DestroyWindow(window);
|
||||||
|
TTF_Quit();
|
||||||
|
SDL_Quit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_Color textColor = {255, 255, 255, 255};
|
||||||
|
|
||||||
|
myObj.a = 50;
|
||||||
|
myObj.b = 10;
|
||||||
|
std::string text_string = myObj.sayHelloDynamic();
|
||||||
|
const char *text = text_string.c_str();
|
||||||
|
|
||||||
|
SDL_Surface* textSurface = TTF_RenderText_Solid(font, text, textColor);
|
||||||
|
SDL_Texture* textTexture = SDL_CreateTextureFromSurface(renderer, textSurface);
|
||||||
|
SDL_Rect textRect = {WINDOW_WIDTH / 2 - textSurface->w / 2, WINDOW_HEIGHT / 2 - textSurface->h / 2, textSurface->w, textSurface->h};
|
||||||
|
SDL_FreeSurface(textSurface);
|
||||||
|
|
||||||
|
bool running = true;
|
||||||
|
SDL_Event event;
|
||||||
|
while (running) {
|
||||||
|
while (SDL_PollEvent(&event)) {
|
||||||
|
if (event.type == SDL_QUIT) {
|
||||||
|
running = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||||
|
SDL_RenderClear(renderer);
|
||||||
|
|
||||||
|
SDL_RenderCopy(renderer, textTexture, nullptr, &textRect);
|
||||||
|
SDL_RenderPresent(renderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_DestroyTexture(textTexture);
|
||||||
|
TTF_CloseFont(font);
|
||||||
|
SDL_DestroyRenderer(renderer);
|
||||||
|
SDL_DestroyWindow(window);
|
||||||
|
TTF_Quit();
|
||||||
|
SDL_Quit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user