Skip to content

Commit 6a38e57

Browse files
committed
fix build
1 parent 10315fc commit 6a38e57

File tree

10 files changed

+372
-61
lines changed

10 files changed

+372
-61
lines changed
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
# CLAUDE.md
22

3-
このファイルは、Claude Code (claude.ai/code) がこのリポジトリ内のコードを操作する際のガイダンスを提供します。
4-
5-
63
## リポジトリアーキテクチャ
74

85
Lumino は、以下の主要なアーキテクチャレイヤーを備えたマルチプラットフォームゲームエンジンライブラリです。
96

107
### コアパッケージ構造
118
- **LuminoCore**: 基盤レイヤー (演算、I/O、スレッド、シリアル化、文字列)
129
- **LuminoEngine**: コアエンジンモジュール (グラフィックス RHI、オーディオ、レンダリング、プラットフォーム抽象化)
13-
- **LuminoFramework**: 高レベルゲームフレームワーク (シーン、物理演算、UI、エフェクト)
1410
- **LuminoFFI**: 他言語との統合のための C API バインディング
1511
- **lumino-js**: JavaScript/WebAssembly バインディング
1612

docs/how-to-build.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Prepare vcpkg in the root of the repository by referring to [here](https://learn.microsoft.com/ja-jp/vcpkg/get_started/get-started).
44

55
```
6-
git clone -b 2025.03.19 https://github.com/microsoft/vcpkg.git
6+
git clone https://github.com/microsoft/vcpkg.git
77
```
88

99
```sh
@@ -21,7 +21,6 @@ npm run build
2121

2222
```
2323

24-
2524
## WebGPU (Dawn)
2625

2726
```sh

packages/LuminoEngine/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,9 @@ if(LN_BUILD_EMBEDDED_SHADER_TRANSCOMPILER)
291291
)
292292
endif()
293293
if (LUMINO_USE_SLANG)
294+
find_package(slang CONFIG REQUIRED)
295+
target_link_libraries(${PROJECT_NAME} PRIVATE slang::slang)
294296
target_compile_definitions(${PROJECT_NAME} PUBLIC LN_USE_SLANG=1)
295-
#target_link_libraries(${PROJECT_NAME} PRIVATE slang::slang)
296297
endif()
297298

298299
if(LN_USE_OPENGL)

packages/LuminoEngine/src/Graphics/ShaderCompiler/ShaderCompiler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifdef LN_USE_SLANG
1010
// https://shader-slang.org/slang/user-guide/compiling#using-the-compilation-api
1111
// https://github.com/shader-slang/slang/pull/6679
12-
#pragma comment(lib, "C:/Proj/Lumino/vcpkg/packages/shader-slang_x64-windows/lib/slang.lib")
12+
//#pragma comment(lib, "C:/Proj/Lumino/vcpkg/packages/shader-slang_x64-windows/lib/slang.lib")
1313
//#pragma comment(lib, "E:/Proj/Lumino/vcpkg/packages/shader-slang_x64-windows/lib/slang.lib")
1414
static slang::CompilerOptionValue fromInt3(uint8_t v0, int v1, int v2) {
1515
slang::CompilerOptionValue value;
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
#include <stdio.h>
2+
#include <vector>
3+
#include <string>
4+
#include <lumino.h>
5+
6+
static size_t GetFileSize(FILE* stream) {
7+
struct stat stbuf;
8+
int handle = fileno(stream);
9+
if (handle == 0) return 0;
10+
if (fstat(handle, &stbuf) == -1) return 0;
11+
return stbuf.st_size;
12+
}
13+
14+
std::vector<uint8_t> ReadAllBytes(const std::string& filePath) {
15+
FILE* file = fopen(filePath.c_str(), "rb");
16+
if (!file) {
17+
printf("Error: %s\n", filePath.c_str());
18+
return {};
19+
}
20+
size_t size = GetFileSize(file);
21+
std::vector<uint8_t> buffer(size);
22+
fread(buffer.data(), 1, size, file);
23+
fclose(file);
24+
return buffer;
25+
}
26+
27+
int main() {
28+
LNConfig_SetGraphicsBackend(LN_GRAPHICS_BACKEND_WEBGPU);
29+
30+
LNResult result = LNInstance_Initialize();
31+
if (result != LN_OK) {
32+
return 1;
33+
}
34+
35+
LNHandle window = LN_NULL_HANDLE;
36+
LNHandle graphicsContext = LN_NULL_HANDLE;
37+
LNHandle viewPoint = LN_NULL_HANDLE;
38+
LNWindow_Create(640, 480, "RenderItem Example", &window);
39+
LNWindow_GetGraphicsContext(window, &graphicsContext);
40+
LNViewPoint_Create(&viewPoint);
41+
42+
// テクスチャの読み込み
43+
std::string assetsDir = ASSETS_DIR;
44+
std::vector<uint8_t> imageData = ReadAllBytes(assetsDir + "/icon256.png");
45+
LNHandle texture1 = LN_NULL_HANDLE;
46+
if (LNTexture2D_CreateFromImageFileData(imageData.data(), imageData.size(), &texture1) != LN_OK) {
47+
return 1;
48+
}
49+
50+
// マテリアルの作成
51+
LNHandle material1 = LN_NULL_HANDLE;
52+
LNMaterial_Create(&material1);
53+
LNMaterial_SetMainTexture(material1, texture1);
54+
55+
// RenderItem の作成と設定 (事前に作成しておく)
56+
LNHandle renderItem = LN_NULL_HANDLE;
57+
LNRenderItem_Create(&renderItem);
58+
59+
// スプライトを追加
60+
LNVector2 size = {100.0f, 100.0f};
61+
LNVector2 anchorRatio = {0.5f, 0.5f};
62+
LNRect uvRect = {0.0f, 0.0f, 1.0f, 1.0f};
63+
LNRenderItem_AddSprite(renderItem, &size, texture1, &uvRect, &anchorRatio);
64+
65+
// マテリアルと基本設定
66+
LNRenderItem_SetMaterial(renderItem, material1);
67+
LNRenderItem_SetBillboardType(renderItem, LN_BILLBOARD_TYPE_NONE);
68+
LNRenderItem_SetBaseDirection(renderItem, LN_SPRITE_BASE_DIRECTION_BASIC2D);
69+
70+
// 色を設定
71+
LNColor white = {1.0f, 1.0f, 1.0f, 1.0f};
72+
LNRenderItem_SetColor(renderItem, &white);
73+
74+
// 2つ目の RenderItem (別の位置に表示)
75+
LNHandle renderItem2 = LN_NULL_HANDLE;
76+
LNRenderItem_Create(&renderItem2);
77+
LNRenderItem_AddSprite(renderItem2, &size, texture1, &uvRect, &anchorRatio);
78+
LNRenderItem_SetMaterial(renderItem2, material1);
79+
LNRenderItem_SetBillboardType(renderItem2, LN_BILLBOARD_TYPE_NONE);
80+
LNRenderItem_SetBaseDirection(renderItem2, LN_SPRITE_BASE_DIRECTION_BASIC2D);
81+
LNColor tint = {1.0f, 0.5f, 0.5f, 1.0f}; // 赤みがかった色
82+
LNRenderItem_SetColor(renderItem2, &tint);
83+
84+
int frameCount = 0;
85+
while (true) {
86+
LNBool quit = LN_FALSE;
87+
LNInstance_ProcessEvents();
88+
LNInstance_ShouldQuit(&quit);
89+
if (quit) {
90+
break;
91+
}
92+
93+
int width = 0;
94+
int height = 0;
95+
LNHandle colorBuffer = LN_NULL_HANDLE;
96+
LNHandle depthBuffer = LN_NULL_HANDLE;
97+
LNWindow_GetFramebufferSize(window, &width, &height);
98+
LNGraphicsContext_BeginFrame(graphicsContext, width, height, &colorBuffer, &depthBuffer);
99+
100+
LNViewPoint_SetupOrtho2D(viewPoint, 0, 0, 0, width, height, -500, 500);
101+
102+
LNHandle renderingPass = LN_NULL_HANDLE;
103+
LNRenderPassDescriptor descriptor;
104+
descriptor.renderTargets[0].renderTarget = colorBuffer;
105+
descriptor.renderTargets[0].clearColor[0] = 0.20f;
106+
descriptor.renderTargets[0].clearColor[1] = 0.25f;
107+
descriptor.renderTargets[0].clearColor[2] = 0.30f;
108+
descriptor.renderTargets[0].clearColor[3] = 1.0f;
109+
descriptor.renderTargets[0].clearEnable = LN_TRUE;
110+
descriptor.depthBuffer.depthBuffer = depthBuffer;
111+
descriptor.depthBuffer.clearDepth = 1.0f;
112+
descriptor.depthBuffer.clearStencil = 0;
113+
descriptor.depthBuffer.clearDepthEnable = LN_TRUE;
114+
descriptor.depthBuffer.clearStencilEnable = LN_TRUE;
115+
LNGraphicsContext_BeginSceneRenderPass(graphicsContext, descriptor, viewPoint, &renderingPass);
116+
117+
// RenderItem の位置を更新 (毎フレーム円運動)
118+
float x1 = 320.0f + 100.0f * cosf(0.05f * frameCount);
119+
float y1 = 240.0f + 100.0f * sinf(0.05f * frameCount);
120+
LNRenderItem_SetPosition(renderItem, x1, y1, 0.0f);
121+
122+
// 2つ目の RenderItem は逆回転
123+
float x2 = 320.0f + 100.0f * cosf(-0.05f * frameCount + 3.14159f);
124+
float y2 = 240.0f + 100.0f * sinf(-0.05f * frameCount + 3.14159f);
125+
LNRenderItem_SetPosition(renderItem2, x2, y2, 0.0f);
126+
127+
// 回転も設定 (Z軸回転)
128+
LNRenderItem_SetRotation(renderItem, 0.0f, 0.0f, frameCount * 2.0f);
129+
LNRenderItem_SetRotation(renderItem2, 0.0f, 0.0f, -frameCount * 2.0f);
130+
131+
// RenderItem を描画 (実際の描画内容は事前に設定済み)
132+
LNSceneRenderPass_DrawRenderItem(renderingPass, renderItem);
133+
LNSceneRenderPass_DrawRenderItem(renderingPass, renderItem2);
134+
135+
LNGraphicsContext_EndSceneRenderPass(graphicsContext, renderingPass);
136+
LNGraphicsContext_EndFrame(graphicsContext);
137+
LNWindow_Present(window);
138+
139+
frameCount++;
140+
}
141+
142+
// リソースの解放
143+
LNObject_Release(renderItem);
144+
LNObject_Release(renderItem2);
145+
LNObject_Release(material1);
146+
LNObject_Release(texture1);
147+
LNObject_Release(viewPoint);
148+
LNObject_Release(window);
149+
LNInstance_Terminate();
150+
return 0;
151+
}

packages/LuminoFFI/include/lumino.h

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,169 @@ extern LUMINO_API LNResult LNSceneRenderPass_DrawSprite(
161161
LNHandle sceneRenderPass,
162162
const LNDrawSpriteParams* params);
163163

164+
//==============================================================================
165+
// LNRenderItem (RenderingServer スタイルの描画アイテム)
166+
//==============================================================================
167+
168+
/**
169+
* 描画アイテムを作成します。
170+
*
171+
* 描画アイテムは、事前に描画内容を定義しておき、後で高速に描画するためのオブジェクトです。
172+
* Godot の RenderingServer のように、リソースを効率的に管理できます。
173+
*
174+
* @param[out] outRenderItem : 作成された描画アイテムのハンドル
175+
*/
176+
extern LUMINO_API LNResult LNRenderItem_Create(LNHandle* outRenderItem);
177+
178+
/**
179+
* テクスチャ矩形を描画アイテムに追加します。
180+
*
181+
* @param[in] renderItem : 描画アイテムのハンドル
182+
* @param[in] rect : 描画する矩形 (ローカル座標系)
183+
* @param[in] texture : 描画するテクスチャ
184+
* @param[in] uvRect : テクスチャのUV座標 (0.0~1.0)、NULL の場合は全体 (0,0,1,1)
185+
*/
186+
extern LUMINO_API LNResult LNRenderItem_AddTextureRect(
187+
LNHandle renderItem,
188+
const LNRect* rect,
189+
LNHandle texture,
190+
const LNRect* uvRect);
191+
192+
/**
193+
* スプライトを描画アイテムに追加します。
194+
*
195+
* @param[in] renderItem : 描画アイテムのハンドル
196+
* @param[in] size : スプライトのサイズ
197+
* @param[in] texture : 描画するテクスチャ
198+
* @param[in] uvRect : テクスチャのUV座標 (0.0~1.0)、NULL の場合は全体 (0,0,1,1)
199+
* @param[in] anchorRatio : アンカーポイント (0.0~1.0)、NULL の場合は中心 (0.5, 0.5)
200+
*/
201+
extern LUMINO_API LNResult LNRenderItem_AddSprite(
202+
LNHandle renderItem,
203+
const LNVector2* size,
204+
LNHandle texture,
205+
const LNRect* uvRect,
206+
const LNVector2* anchorRatio);
207+
208+
/**
209+
* 描画アイテムの位置を設定します。
210+
*
211+
* @param[in] renderItem : 描画アイテムのハンドル
212+
* @param[in] x : X座標
213+
* @param[in] y : Y座標
214+
* @param[in] z : Z座標
215+
*/
216+
extern LUMINO_API LNResult LNRenderItem_SetPosition(
217+
LNHandle renderItem,
218+
float x,
219+
float y,
220+
float z);
221+
222+
/**
223+
* 描画アイテムの回転を設定します (オイラー角、度数法)。
224+
*
225+
* @param[in] renderItem : 描画アイテムのハンドル
226+
* @param[in] x : X軸回転 (度)
227+
* @param[in] y : Y軸回転 (度)
228+
* @param[in] z : Z軸回転 (度)
229+
*/
230+
extern LUMINO_API LNResult LNRenderItem_SetRotation(
231+
LNHandle renderItem,
232+
float x,
233+
float y,
234+
float z);
235+
236+
/**
237+
* 描画アイテムのスケールを設定します。
238+
*
239+
* @param[in] renderItem : 描画アイテムのハンドル
240+
* @param[in] x : Xスケール
241+
* @param[in] y : Yスケール
242+
* @param[in] z : Zスケール
243+
*/
244+
extern LUMINO_API LNResult LNRenderItem_SetScale(
245+
LNHandle renderItem,
246+
float x,
247+
float y,
248+
float z);
249+
250+
/**
251+
* 描画アイテムのワールド変換行列を設定します。
252+
*
253+
* @param[in] renderItem : 描画アイテムのハンドル
254+
* @param[in] transform : 変換行列
255+
*/
256+
extern LUMINO_API LNResult LNRenderItem_SetTransform(
257+
LNHandle renderItem,
258+
const LNMatrix* transform);
259+
260+
/**
261+
* 描画アイテムの色を設定します。
262+
*
263+
* @param[in] renderItem : 描画アイテムのハンドル
264+
* @param[in] color : 色 (RGBA)
265+
*/
266+
extern LUMINO_API LNResult LNRenderItem_SetColor(
267+
LNHandle renderItem,
268+
const LNColor* color);
269+
270+
/**
271+
* 描画アイテムのマテリアルを設定します。
272+
*
273+
* @param[in] renderItem : 描画アイテムのハンドル
274+
* @param[in] material : マテリアル
275+
*/
276+
extern LUMINO_API LNResult LNRenderItem_SetMaterial(
277+
LNHandle renderItem,
278+
LNHandle material);
279+
280+
/**
281+
* 描画アイテムのビルボードタイプを設定します。
282+
*
283+
* @param[in] renderItem : 描画アイテムのハンドル
284+
* @param[in] billboardType : ビルボードタイプ
285+
*/
286+
extern LUMINO_API LNResult LNRenderItem_SetBillboardType(
287+
LNHandle renderItem,
288+
LNBillboardType billboardType);
289+
290+
/**
291+
* 描画アイテムの基準方向を設定します。
292+
*
293+
* @param[in] renderItem : 描画アイテムのハンドル
294+
* @param[in] baseDirection : 基準方向
295+
*/
296+
extern LUMINO_API LNResult LNRenderItem_SetBaseDirection(
297+
LNHandle renderItem,
298+
LNSpriteBaseDirection baseDirection);
299+
300+
/**
301+
* 描画アイテムの可視状態を設定します。
302+
*
303+
* @param[in] renderItem : 描画アイテムのハンドル
304+
* @param[in] visible : 可視かどうか
305+
*/
306+
extern LUMINO_API LNResult LNRenderItem_SetVisible(
307+
LNHandle renderItem,
308+
LNBool visible);
309+
310+
/**
311+
* 描画アイテムの内容をクリアします。
312+
*
313+
* @param[in] renderItem : 描画アイテムのハンドル
314+
*/
315+
extern LUMINO_API LNResult LNRenderItem_Clear(LNHandle renderItem);
316+
317+
/**
318+
* 描画アイテムを描画します。
319+
*
320+
* @param[in] sceneRenderPass : シーンレンダーパス
321+
* @param[in] renderItem : 描画アイテムのハンドル
322+
*/
323+
extern LUMINO_API LNResult LNSceneRenderPass_DrawRenderItem(
324+
LNHandle sceneRenderPass,
325+
LNHandle renderItem);
326+
164327
//==============================================================================
165328
// LNDebug
166329
//==============================================================================

scripts/build_engine.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import utils
22

3-
# slang が MD しか使えないようなので。
4-
#triplet = "x64-windows-static"
5-
triplet = "x64-windows"
3+
triplet = "x64-windows" # slang が MD しか使えないようなので、 Static Runtime (x64-windows-static) は使わない
64
generator = "Visual Studio 17 2022"
75
build_dir = f"{utils.root_dir}/build/buildtrees/{triplet}/lumino"
86
installDir = f"{utils.root_dir}/build/installed/{triplet}"

vcpkg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit acd5bba5aac8b6573b5f6f463dc0341ac0ee6fa4
1+
Subproject commit 9c147d5304087fe85104b776b019c45745fa9c11

vcpkg-configuration.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"default-registry": {
33
"kind": "git",
4-
"baseline": "b02e341c927f16d991edbd915d8ea43eac52096c",
4+
"baseline": "74e6536215718009aae747d86d84b78376bf9e09",
55
"repository": "https://github.com/microsoft/vcpkg"
66
},
77
"registries": [

0 commit comments

Comments
 (0)