first commit

This commit is contained in:
Alejandro Guerrero 2026-09-27 17:21:39 +02:00
commit e6a42e28e9
4355 changed files with 4626605 additions and 0 deletions

View file

@ -0,0 +1,20 @@
cmake_minimum_required (VERSION 3.8)
project(LGFX_LINUX_FB)
add_definitions(-DLGFX_LINUX_FB)
file(GLOB Target_Files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS
*.cpp
LovyanGFX/src/lgfx/Fonts/efont/*.c
LovyanGFX/src/lgfx/Fonts/IPA/*.c
LovyanGFX/src/lgfx/utility/*.c
LovyanGFX/src/lgfx/v1/*.cpp
LovyanGFX/src/lgfx/v1/misc/*.cpp
LovyanGFX/src/lgfx/v1/panel/Panel_Device.cpp
LovyanGFX/src/lgfx/v1/platforms/framebuffer/*.cpp
)
add_executable (LGFX_LINUX_FB ${Target_Files})
target_include_directories(LGFX_LINUX_FB PUBLIC "LovyanGFX/src/")
target_compile_features(LGFX_LINUX_FB PUBLIC cxx_std_17)
target_link_libraries(LGFX_LINUX_FB -lpthread)

View file

@ -0,0 +1,29 @@
#include <linux/fb.h>
#include <thread>
#define LGFX_USE_V1
#include <LovyanGFX.hpp>
#include <LGFX_AUTODETECT.hpp>
void setup(void);
void loop(void);
void loopThread(void)
{
setup();
for (;;)
{
loop();
std::this_thread::yield();
}
}
int main(int, char**)
{
std::thread sub_thread(loopThread);
for (;;)
{
std::this_thread::yield();
std::this_thread::sleep_for(std::chrono::milliseconds(5));
}
}

View file

@ -0,0 +1,38 @@
#include <stdio.h> // for drawBmpFile / drawJpgFile / drawPngFile
#define LGFX_USE_V1
#include <LovyanGFX.hpp>
#include <LGFX_AUTODETECT.hpp>
#define SCREEN_X 320
#define SCREEN_Y 240
#define DEVICE_NAME "/dev/fb0"
// 引数1 画面の幅
// 引数2 画面の高さ
// 引数3 操作対象とするフレームバッファのパス名、またはデバイス名称 ("st7789") 等の文字列
LGFX lcd ( SCREEN_X, SCREEN_Y, DEVICE_NAME );
int32_t target_x = (SCREEN_X / 2) * 256;
int32_t target_y = (SCREEN_Y / 2) * 256;
int32_t current_x = 0;
int32_t current_y = 0;
int32_t add_x = 0;
int32_t add_y = 0;
void setup()
{
lcd.init();
}
void loop()
{
static int i;
++i;
lcd.fillCircle(current_x >> 8, current_y >> 8, 5, i);
current_x += add_x;
current_y += add_y;
add_x += (current_x < target_x) ? 1 : -1;
add_y += (current_y < target_y) ? 1 : -1;
lgfx::delay(1);
}

View file

@ -0,0 +1,34 @@
cmake_minimum_required (VERSION 3.8)
project(LGFXOpenCV)
add_definitions(-DLGFX_OPENCV)
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/Zc:__cplusplus>")
# ビルド対象にするファイルを指定する;
# LovyanGFXのあるパスと位置関係を変えた場合は相対パス記述を環境に合わせて調整すること;
file(GLOB Target_Files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS
*.cpp
../../../LovyanGFX/src/lgfx/Fonts/efont/*.c
../../../LovyanGFX/src/lgfx/Fonts/IPA/*.c
../../../LovyanGFX/src/lgfx/utility/*.c
../../../LovyanGFX/src/lgfx/v1/*.cpp
../../../LovyanGFX/src/lgfx/v1/misc/*.cpp
../../../LovyanGFX/src/lgfx/v1/panel/Panel_Device.cpp
../../../LovyanGFX/src/lgfx/v1/platforms/opencv/*.cpp
)
add_executable (LGFXOpenCV ${Target_Files})
# includeするファイルのパスを指定する;
# LovyanGFXのあるパスと位置関係を変えた場合は相対パス記述を環境に合わせて調整すること;
target_include_directories(LGFXOpenCV PUBLIC "../../../LovyanGFX/src")
# OpenCVを配置したパス内のincludeのパスを指定する;
target_include_directories(LGFXOpenCV PUBLIC "C:/opencv/build/include")
# OpenCVを配置したパス内の.libファイルのパスを指定する;
target_link_libraries(LGFXOpenCV PUBLIC "C:/opencv/build/x64/vc15/lib/opencv_world452d.lib" )
target_compile_features(LGFXOpenCV PUBLIC cxx_std_17)

View file

@ -0,0 +1,15 @@
{
"configurations": [
{
"name": "x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "clang_cl_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": ""
}
]
}

View file

@ -0,0 +1,30 @@
#include <stdio.h>
#include <opencv2/opencv.hpp>
#include <thread>
#define LGFX_USE_V1
#include <LovyanGFX.hpp>
#include <LGFX_AUTODETECT.hpp>
void setup(void);
void loop(void);
void loopThread(void)
{
setup();
for (;;)
{
std::this_thread::yield();
loop();
}
}
int main(int, char**)
{
std::thread sub_thread(loopThread);
for (;;)
{
std::this_thread::yield();
lgfx::Panel_OpenCV::imshowall();
}
}

View file

@ -0,0 +1,53 @@

// If you write this, you can use drawBmpFile / drawJpgFile / drawPngFile
// #include <stdio.h>
// If you write this, you can use drawBmpUrl / drawJpgUrl / drawPngUrl ( for Windows )
// #include <windows.h>
// #include <winhttp.h>
// #pragma comment (lib, "winhttp.lib")
#define LGFX_USE_V1
#include <LovyanGFX.hpp>
#include <LGFX_AUTODETECT.hpp>
LGFX lcd ( 320, 240 );
LGFX lcd2( 135, 240 );
int32_t target_x = 160 * 256;
int32_t target_y = 120 * 256;
int32_t current_x = 0;
int32_t current_y = 0;
int32_t add_x = 0;
int32_t add_y = 0;
void setup()
{
lcd.init();
lcd2.init();
// lcd.drawJpgFile("C:\\test.jpg", 0, 0);
// lcd.drawPngUrl("http://cyberjapandata.gsi.go.jp/xyz/pale/14/14550/6451.png", 0, 0);
}
void loop()
{
static int i;
++i;
lcd.fillCircle(current_x >> 8, current_y >> 8, 5, i);
current_x += add_x;
current_y += add_y;
add_x += (current_x < target_x) ? 1 : -1;
add_y += (current_y < target_y) ? 1 : -1;
lgfx::touch_point_t new_tp;
if (lcd.getTouch(&new_tp))
{
target_x = new_tp.x * 256;
target_y = new_tp.y * 256;
lcd.drawCircle(new_tp.x, new_tp.y, 5, TFT_WHITE);
}
lgfx::delay(1);
lcd2.fillRect(i & 127, i >> 7, 16, 16, i);
}

View file

@ -0,0 +1,56 @@
# See how to install sdl2: https://wiki.libsdl.org/SDL2/Installation
cmake_minimum_required (VERSION 3.8)
project(LGFX_SDL)
add_definitions(-DLGFX_SDL)
# ビルド対象にするファイルを指定する;
# LovyanGFXのあるパスと位置関係を変えた場合は相対パス記述を環境に合わせて調整すること;
file(GLOB Target_Files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS
*.cpp
../../../LovyanGFX/src/lgfx/Fonts/efont/*.c
../../../LovyanGFX/src/lgfx/Fonts/IPA/*.c
../../../LovyanGFX/src/lgfx/utility/*.c
../../../LovyanGFX/src/lgfx/v1/*.cpp
../../../LovyanGFX/src/lgfx/v1/misc/*.cpp
../../../LovyanGFX/src/lgfx/v1/panel/Panel_Device.cpp
../../../LovyanGFX/src/lgfx/v1/panel/Panel_FrameBufferBase.cpp
../../../LovyanGFX/src/lgfx/v1/platforms/sdl/*.cpp
)
add_executable (LGFX_SDL ${Target_Files})
# includeするファイルのパスを指定する;
# LovyanGFXのあるパスと位置関係を変えた場合は相対パス記述を環境に合わせて調整すること;
target_include_directories(LGFX_SDL PUBLIC "../../../LovyanGFX/src/")
IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
# Linux環境の場合;
# SDL2_INCLUDE_DIRS と SDL2_LIBRARIES を事前に設定しておく;
find_package(SDL2 REQUIRED SDL2)
include_directories(${SDL2_INCLUDE_DIRS})
target_link_libraries(LGFX_SDL -lpthread ${SDL2_LIBRARIES})
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows")
# Windows環境の場合;
# SDL2を配置したパス内のincludeのパスを指定する;
target_include_directories(LGFX_SDL PUBLIC "C:/SDL2/include")
# SDL2を配置したパス内の.libファイルのパスを指定する;
target_link_libraries(LGFX_SDL PUBLIC "C:/SDL2/lib/x64/SDL2.lib")
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/Zc:__cplusplus>")
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
# MacOS(Darwin)環境の場合;
find_package(SDL2 REQUIRED COMPONENTS SDL2)
target_link_libraries(LGFX_SDL PRIVATE SDL2::SDL2)
ENDIF ()
target_compile_features(LGFX_SDL PUBLIC cxx_std_17)

View file

@ -0,0 +1,27 @@
{
"configurations": [
{
"name": "x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "clang_cl_x64_x64" ],
"buildRoot": "${projectDir}\\.out\\build\\${name}",
"installRoot": "${projectDir}\\.out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": ""
},
{
"name": "x64-Release",
"generator": "Ninja",
"configurationType": "Release",
"buildRoot": "${projectDir}\\.out\\build\\${name}",
"installRoot": "${projectDir}\\.out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "clang_cl_x64_x64" ],
"variables": []
}
]
}

View file

@ -0,0 +1,23 @@
#include <lgfx/v1/platforms/sdl/Panel_sdl.hpp>
#if defined ( SDL_h_ )
void setup(void);
void loop(void);
__attribute__((weak))
int user_func(bool* running)
{
setup();
do
{
loop();
} while (*running);
return 0;
}
int main(int, char**)
{
return lgfx::Panel_sdl::main(user_func);
}
#endif

View file

@ -0,0 +1,53 @@

// If you write this, you can use drawBmpFile / drawJpgFile / drawPngFile
// #include <stdio.h>
// If you write this, you can use drawBmpUrl / drawJpgUrl / drawPngUrl ( for Windows )
// #include <windows.h>
// #include <winhttp.h>
// #pragma comment (lib, "winhttp.lib")
#define LGFX_USE_V1
#include <LovyanGFX.hpp>
#include <LGFX_AUTODETECT.hpp>
LGFX lcd ( 320, 240 );
LGFX lcd2( 135, 240 );
int32_t target_x = 160 * 256;
int32_t target_y = 120 * 256;
int32_t current_x = 0;
int32_t current_y = 0;
int32_t add_x = 0;
int32_t add_y = 0;
void setup()
{
lcd.init();
lcd2.init();
// lcd.drawJpgFile("C:\\test.jpg", 0, 0);
// lcd.drawPngUrl("http://cyberjapandata.gsi.go.jp/xyz/pale/14/14550/6451.png", 0, 0);
}
void loop()
{
static int i;
++i;
lcd.fillCircle(current_x >> 8, current_y >> 8, 5, i);
current_x += add_x;
current_y += add_y;
add_x += (current_x < target_x) ? 1 : -1;
add_y += (current_y < target_y) ? 1 : -1;
lgfx::touch_point_t new_tp;
if (lcd.getTouch(&new_tp))
{
target_x = new_tp.x * 256;
target_y = new_tp.y * 256;
lcd.drawCircle(new_tp.x, new_tp.y, 5, TFT_WHITE);
}
lgfx::delay(1);
lcd2.fillRect(i & 127, i >> 7, 16, 16, i);
}

View file

@ -0,0 +1,26 @@
cmake_minimum_required(VERSION 3.12)
project (lv_wasm)
add_definitions(-DLGFX_SDL)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -s USE_SDL=2")
include_directories(../../../LovyanGFX/src/)
file(GLOB MY_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS
*.cpp
../../../LovyanGFX/src/lgfx/Fonts/efont/*.c
../../../LovyanGFX/src/lgfx/Fonts/IPA/*.c
../../../LovyanGFX/src/lgfx/utility/*.c
../../../LovyanGFX/src/lgfx/v1/*.cpp
../../../LovyanGFX/src/lgfx/v1/misc/*.cpp
../../../LovyanGFX/src/lgfx/v1/panel/Panel_Device.cpp
../../../LovyanGFX/src/lgfx/v1/panel/Panel_FrameBufferBase.cpp
../../../LovyanGFX/src/lgfx/v1/platforms/sdl/*.cpp
)
set(SOURCES ${MY_SOURCES})
add_executable(index ${SOURCES} ${INCLUDES})
set(CMAKE_EXECUTABLE_SUFFIX ".html")
target_link_libraries(index -lembind)
set_target_properties(index PROPERTIES LINK_FLAGS "--shell-file ${PROJECT_SOURCE_DIR}/lgfx_wasm.html -s SINGLE_FILE=1")

View file

@ -0,0 +1,15 @@
{
"configurations": [
{
"name": "x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "clang_cl_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": ""
}
]
}

View file

@ -0,0 +1,21 @@
#define LGFX_USE_V1
#include <LovyanGFX.hpp>
#include <LGFX_AUTODETECT.hpp>
#include <emscripten.h>
void setup(void);
void loop(void);
void loopThread(void *arg)
{
loop();
lgfx::Panel_sdl::sdl_event_handler();
}
int monitor_hor_res, monitor_ver_res;
int main(int argc, char **argv)
{
setup();
emscripten_set_main_loop_arg(loopThread, NULL, -1, true);
}

View file

@ -0,0 +1,17 @@
# WebAssembly port
# Step
## Install SDL
[follow this](https://wiki.libsdl.org/SDL2/Installation)
## Install Emscripten SDK
[follow this](https://emscripten.org/docs/getting_started/downloads.html)
## Build and Run
1. `mkdir build`
2. `cd build`
3. `emcmake cmake ..`
4. `emmake make`
5. open `index.html` in your browser.

View file

@ -0,0 +1,47 @@
<html>
<head>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no'/>
<style type="text/css">
html, body {
margin: 0;
width: 100%;
height: 100%;
min-width: 100%;
min-height: 100%;
}
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
#output {
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<p id="output">
<canvas id="canvas"></canvas>
</p>
<script>
var canvas = document.getElementById('canvas');
var Module = {
print: function(text) {
console.log("log: " + text);
},
printErr: function(text) {
console.error(text);
},
canvas: (function() {
return canvas;
})(),
};
window.addEventListener("click", () => window.focus());
</script>
{{{ SCRIPT }}}
</body>
</html>

View file

@ -0,0 +1,89 @@

// If you write this, you can use drawBmpFile / drawJpgFile / drawPngFile
// #include <stdio.h>
// If you write this, you can use drawBmpUrl / drawJpgUrl / drawPngUrl ( for Windows )
// #include <windows.h>
// #include <winhttp.h>
// #pragma comment (lib, "winhttp.lib")
#define LGFX_USE_V1
#include <LovyanGFX.hpp>
#include <LGFX_AUTODETECT.hpp>
#include <emscripten.h>
#include <emscripten/bind.h>
using namespace emscripten;
LGFX lcd(320, 240);
int32_t target_x = 160 * 256;
int32_t target_y = 120 * 256;
int32_t current_x = 0;
int32_t current_y = 0;
int32_t add_x = 0;
int32_t add_y = 0;
void setup()
{
lcd.init();
lcd.clear(TFT_PINK);
lcd.setFont(&fonts::DejaVu24);
}
void loop()
{
static int i;
++i;
lcd.fillCircle(current_x >> 8, current_y >> 8, 5, i);
current_x += add_x;
current_y += add_y;
add_x += (current_x < target_x) ? 1 : -1;
add_y += (current_y < target_y) ? 1 : -1;
lgfx::touch_point_t new_tp;
if (lcd.getTouch(&new_tp))
{
target_x = new_tp.x * 256;
target_y = new_tp.y * 256;
lcd.drawCircle(new_tp.x, new_tp.y, 5, TFT_WHITE);
}
lcd.drawCenterString("LGFX & WASM", 160, 100);
lgfx::delay(5);
}
/// exported funcitons
void lgfx_clear(int color)
{
lcd.clear(color);
}
void lgfx_drawString(const std::string &s, uint32_t x, uint32_t y)
{
lcd.drawString(s.c_str(), x, y);
}
void lgfx_drawRect(int32_t x, int32_t y, int32_t w, int32_t h, int color)
{
lcd.drawRect(x, y, w, h, color);
}
void lgfx_drawTriangle(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int color)
{
lcd.drawTriangle(x0, y0, x1, y1, x2, y2, color);
}
void lgfx_drawCircle(int32_t x, int32_t y, int32_t r, int color)
{
lcd.drawCircle(x, y, r, color);
}
/// binding C++ functions to JavaScript
EMSCRIPTEN_BINDINGS(lgfx_module)
{
function("clear", &lgfx_clear);
function("drawString", &lgfx_drawString);
function("drawRect", &lgfx_drawRect);
function("drawTriangle", &lgfx_drawTriangle);
function("drawCircle", &lgfx_drawCircle);
}

View file

@ -0,0 +1,79 @@
## Visual Studio Code + PlatformIO + SDL2 環境で LovyanGFXを使用する手順
まず最初にVisual Studio Code をインストールし、PlatformIO を使用できる状態にする。
---
### PlatformIOにて、 `platform = native` のビルドができる状態にする。
手順は下記 URL から `Installation` の項目を読んで実施する。
https://docs.platformio.org/en/latest/platforms/native.html#installation
#### Linuxの場合
`apt` で `build-essential` をインストールする。
```
sudo apt update
sudo apt install build-essential
```
#### macOSの場合
ターミナルから `xcode-select` をインストールする。
```
xcode-select --install
```
#### Windowsの場合
`MSYS2` をここ https://www.msys2.org/ から入手してインストールする。
そのあと、Windowsの`システムのプロパティ`->`環境変数` を開き、 `PATH` に以下の3つのパスを追加する。
```
C:\msys64\mingw64\bin
C:\msys64\ucrt64\bin
C:\msys64\usr\bin
```
---
### PlatformIOにて、 SDL2 が使用できる状態にする。
手順は下記 URL から `Install SDL2` の項目を読んで実施する。
https://docs.lvgl.io/latest/en/html/get-started/pc-simulator.html#install-sdl-2
#### Linuxの場合
apt-getでlibsdl2をインストールする。
```
sudo apt-get install libsdl2 libsdl2-dev
```
#### MacOS OSXの場合
Homebrewを使ってsdl2をインストールする。
```
brew install sdl2
```
#### Windowsの場合
`platform = native` のビルドを可能にする手順において、 msys2をインストール済みのはずなので、
githubの SDLのリポジトリにアクセスし、SDL2-devel-x.xx.x-mingw のリリースパッケージを入手する。
https://github.com/libsdl-org/SDL/releases
本記事作成時点のファイル名は `SDL2-devel-2.28.1-mingw.zip`
これを解凍し、出てきたフォルダの中にある `x86_64-w64-mingw32` フォルダを開き、中に以下の 4つのフォルダがあることを確認。
- share
- bin
- include
- lib
C:\msys64\mingw64\ を開き、上記の4つのフォルダと同名のフォルダが存在することを確認したら、C:\msys64\mingw64\ 内に上記フォルダの内容を追加する。(上書きコピー)
---

View file

@ -0,0 +1,34 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:native]
platform = native
build_type = debug
build_flags = -O0 -xc++ -std=c++14 -lSDL2
-I"/usr/local/include/SDL2" ; for intel mac homebrew SDL2
-L"/usr/local/lib" ; for intel mac homebrew SDL2
-I"${sysenv.HOMEBREW_PREFIX}/include/SDL2" ; for arm mac homebrew SDL2
-L"${sysenv.HOMEBREW_PREFIX}/lib" ; for arm mac homebrew SDL2
[esp32_base]
build_type = debug
platform = espressif32
board = esp32dev
upload_speed = 1500000
monitor_speed = 115200
monitor_filters = esp32_exception_decoder
[env:esp32_arduino]
extends = esp32_base
framework = arduino
[env:esp32_idf]
extends = esp32_base
framework = espidf

View file

@ -0,0 +1,23 @@
#include <lgfx/v1/platforms/sdl/Panel_sdl.hpp>
#if defined ( SDL_h_ )
void setup(void);
void loop(void);
__attribute__((weak))
int user_func(bool* running)
{
setup();
do
{
loop();
} while (*running);
return 0;
}
int main(int, char**)
{
return lgfx::Panel_sdl::main(user_func);
}
#endif

View file

@ -0,0 +1,34 @@
#define LGFX_AUTODETECT
#include <LovyanGFX.h>
#include <LGFX_AUTODETECT.hpp>
#if defined ( SDL_h_ )
static LGFX lcd ( 320, 240, 2 );
#else
static LGFX lcd;
#endif
void setup(void)
{
lcd.init();
}
void loop(void)
{
lcd.fillCircle(rand()%lcd.width(), rand()%lcd.height(), 16, rand());
}
#if defined ( ESP_PLATFORM ) && !defined ( ARDUINO )
extern "C" {
int app_main(int, char**)
{
setup();
for (;;) {
loop();
}
return 0;
}
}
#endif

View file

@ -0,0 +1,71 @@
# How to build LovyanGFX for Windows.
### VisualStudio で clang を使用できるようにする
- [VisualStudioのサイト](https://visualstudio.microsoft.com/ja/vs/)から `VisualStudio Community 2022` をダウンロード
- VisualStudio をインストールする際に以下のオプションを追加する
- ` C++ によるデスクトップ開発 ` にチェックを入れる
- 右ペインの ` インストールの詳細 ` から ` Windows用 C++ Clang ツール ` にチェックを入れる <br>
![VisualStudio_Installer](./images/vs_install.png)
---
### SDL または OpenCV を入手し任意のフォルダに配置する
- SDLの場合 [こちらのダウンロードページ](https://www.libsdl.org/download-2.0.php) から `Development Libraries` を入手 <br>
![sdl2_download_page](./images/sdl2_download_page.png)
- OpenCVの場合 [こちらのダウンロードページ](https://opencv.org/releases/) から `Releases` の `Windows` を入手 <br>
![opencv_download_page](./images/opencv_download_page.png)
- OpenCVの場合、インストーラを起動して任意の場所に展開。例ではC直下に作成 (C:\opencvに作成される) <br>
![opencv_install_directory](./images/opencv_install_directory.png)
- サンプルのCMakeListsは `C:\SDL2` や `C:\opencv` に配置した場合のパスを初期設定値としている
---
### 環境変数の編集を行い、パスを追加する
- 環境変数 > ユーザー環境変数 > `Path` を選択 > 編集 > 新規
- SDL2の場合、`C:/SDL2/lib/x64/` を追加 ( 配置した場所に合わせて調整すること )
- OpenCVの場合、`C:/opencv/build/x64/vc15\bin` を追加 ( 配置した場所に合わせて調整すること )
- ※ パスの場所にDLLファイルが含まれていることを確認すること
- ※ パスを追加したあと、PCを再起動(または再ログオン)すること <br>
![env_path](./images/env_path.png)
---
### サンプルフォルダ内のCMakeLists.txtを調整する
- CMakeLists.txt を開き、環境に合わせてパスやファイル名の記述を調整する
- SDL2 の場合 `examples_for_PC/CMake_SDL/CMakeLists.txt`
- OpenCV の場合 `examples_for_PC/CMake_OpenCV/CMakeLists.txt`
- OpenCV の場合は`.lib`ファイル名にバージョン番号が含まれているので、これも入手したバージョンと一致するよう調整する <br>
![cmakelists_edit](./images/cmakelists_edit.png)
---
### VisualStudioを起動し、サンプルフォルダを開く
- VisualStudioを起動して `ローカル フォルダーを開く` をクリックし、サンプルフォルダを選択する
- SDL2 の場合 examples_for_PC/CMake_SDL
- OpenCV の場合 examples_for_PC/CMake_OpenCV <br>
![vs_open](./images/vs_open.png)
- 画面上部にあるビルドターゲットの設定枠で `LGFX_SDL` または `LGFX_OpenCV` を選択する
- `デバッグ` > `デバッグの開始` をクリックする <br>
![vs_build](./images/vs_build.png)
![vs_debug](./images/vs_debug.png)
- デバッグ中の様子(サンプルコード) <br>
![vs_debugging_example](./images/vs_debugging_example.png)
- デバッグの停止<br>
![vs_debug_stop](./images/vs_debug_stop.png)
- ビルド時に以下のようなエラーが出る場合や、実行時にDLLが見つからないエラーが出る場合は、環境設定のパスやCMakeLists.txtのパスおよびファイル名を見直す。環境設定後は再起動(または再ログオン)を忘れずに。
```txt
重大度レベル コード 説明 プロジェクト ファイル 行 抑制状態
エラー 'C:/opencv/build/x64/vc15/lib/opencv_world452d.lib', needed by 'LGFXOpenCV.exe', missing and no known rule to make it C:\sandbox\LovyanGFX\examples\Advanced\CMake_OpenCV\out\build\x64-Debug\CMake_OpenCV C:\sandbox\LovyanGFX\examples\Advanced\CMake_OpenCV\out\build\x64-Debug\ninja 1
```
![vs_error_notfound_sdl](./images/vs_error_notfound_sdl.png)
![vs_error_notfound_opencv](./images/vs_error_notfound_opencv.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB