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,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);
}