Skip to content

Commit f2ad1df

Browse files
authored
Merge pull request #23 from minigdx/full-shaders
Full shaders
2 parents 861c3f3 + 6aa23ec commit f2ad1df

File tree

201 files changed

+20805
-6308
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+20805
-6308
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ build/
44
!**/src/main/**/build/
55
!**/src/test/**/build/
66

7+
# Test screenshots (generated during test runs)
8+
.test/
9+
710
### IntelliJ IDEA ###
811
.idea/**
912
.idea/

.idea/gradle.xml

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CLAUDE.md

Lines changed: 78 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,17 @@ Tiny is a Kotlin Multiplatform game engine with Lua scripting support that compi
2828
```bash
2929
./gradlew build # Build all modules
3030
./gradlew test # Run all tests
31-
./gradlew publishToMavenLocal # Deploy to local maven
31+
./gradlew publishToMavenLocal # Deploy to local maven (also: make deploy)
32+
./gradlew clean # Clean build artifacts
33+
```
34+
35+
### Testing
36+
```bash
37+
./gradlew test # Run all tests
38+
./gradlew :tiny-engine:test # Run tests for specific module
39+
./gradlew :tiny-engine:commonTest # Run common multiplatform tests
40+
./gradlew :tiny-engine:jvmTest # Run JVM-specific tests
41+
./gradlew :tiny-engine:jsTest # Run JS-specific tests
3242
```
3343

3444
### Linting
@@ -37,22 +47,36 @@ make lint # or ./gradlew ktlintCheck
3747
make lintfix # or ./gradlew ktlintFormat
3848
```
3949

40-
### CLI Installation
50+
### CLI Development
4151
```bash
4252
make install # Build and install CLI to ~/.bin/tiny-cli
53+
./gradlew :tiny-cli:assembleDist # Build CLI distribution
54+
```
55+
56+
### Documentation Generation
57+
```bash
58+
make docs # Generate full documentation (requires CLI install)
59+
./gradlew asciidoctor # Generate docs only
4360
```
4461

45-
### Documentation
62+
### CLI Commands (after installation)
4663
```bash
47-
make docs # Generate documentation (requires CLI install)
64+
tiny-cli create <name> # Create new game project
65+
tiny-cli run # Run game in current directory
66+
tiny-cli debug # Run with debugger
67+
tiny-cli serve # Dev server with hot reload
68+
tiny-cli export # Export for web deployment
69+
tiny-cli sfx # Sound effect editor
70+
tiny-cli add # Add resources to project
71+
tiny-cli palette # Generate color palettes
4872
```
4973

5074
## Architecture Details
5175

5276
### Platform Abstraction
5377
The engine uses a Platform interface to abstract platform-specific functionality:
54-
- `GlfwPlatform` for desktop (LWJGL/GLFW)
55-
- `WebGlPlatform` for web (WebGL)
78+
- `GlfwPlatform` for desktop (LWJGL/GLFW). It uses OpenGL 3.
79+
- `WebGlPlatform` for web (WebGL). It uses WebGL 2.0.
5680

5781
### Resource Management
5882
Games are structured around:
@@ -69,22 +93,61 @@ The engine exposes functionality through organized Lua libraries:
6993
- `ctrl`: Input handling
7094
- `map`: Level/tilemap operations
7195

72-
### Build Artifacts
96+
### Open GL Organization
97+
The engine use 2 stages of rendering:
98+
- tiny-engine/src/commonMain/kotlin/com/github/minigdx/tiny/render/gl/SpriteBatchStage.kt : it renders everything in a framebuffer at a lower resolution.
99+
- tiny-engine/src/commonMain/kotlin/com/github/minigdx/tiny/render/gl/FrameBufferStage.kt : it renders the framebuffer from the previous stage at the screen resolution.
100+
- The OpenGL abstraction is managers by
101+
- tiny-engine/src/commonMain/kotlin/com/github/minigdx/tiny/render/shader/ShaderProgram.kt (manage shader program)
102+
- tiny-engine/src/commonMain/kotlin/com/github/minigdx/tiny/render/shader/ShaderParameter.kt (manager shader program parameters)
103+
- the shader program is created, alongside the shader program parameters. These parameters are created in Kotlin and added in the shader source code program.
104+
- The shader program parameters can be configured using the method `setup` to access the vertex and fragment shader.
105+
- before draw, the `blind` is called. `unbind` is called after.
106+
- fragColor is added automatically as out vec4 in FragmentShader (See tiny-engine/src/commonMain/kotlin/com/github/minigdx/tiny/render/shader/BaseShader.kt)
107+
- #version is added automatically in the shader program source code (See tiny-engine/src/commonMain/kotlin/com/github/minigdx/tiny/render/shader/BaseShader.kt)
108+
109+
### Build Artifacts & Tasks
73110
The build produces several specialized artifacts:
74111
- `tinyWebEngine`: JS engine for web deployment
75-
- `tinyApiAsciidoctor`: Generated API documentation
112+
- `tinyApiAsciidoctor`: Generated API documentation
76113
- `tinyApiLuaStub`: Lua API stubs
77114
- `tinyResources`: Packaged engine resources
78115

116+
Key Gradle tasks:
117+
- `tiny-web-editor:tinyWebEditor`: Builds web editor interface
118+
- `assembleDist`: Creates CLI distribution zip
119+
- `asciidoctor`: Generates documentation using generated content
120+
121+
## Performance Considerations
122+
123+
### Critical Performance Areas
124+
- **Input handling**: LWJGL input system can be slower than WebGL due to cursor position polling
125+
- **Lua wrapper creation**: Frequent `WrapperLuaTable` creation in SfxLib can impact performance
126+
- **Resource loading**: Hot-reload monitors file changes for rapid development iteration
127+
128+
### Platform-Specific Optimizations
129+
- **Desktop (LWJGL)**: Uses cursor position caching to avoid expensive `glfwGetCursorPos()` calls
130+
- **Web (WebGL)**: Generally more responsive for UI interactions due to different input handling
131+
79132
## Development Workflow
80133

81-
1. Engine changes go in `tiny-engine/src/commonMain/kotlin`
82-
2. CLI commands are in `tiny-cli/src/main/kotlin/com/github/minigdx/tiny/cli/command/`
83-
3. Lua API libraries are in `tiny-engine/src/commonMain/kotlin/com/github/minigdx/tiny/lua/`
84-
4. Tests follow the pattern `src/commonTest/kotlin` for shared tests
85-
5. Platform-specific code uses `src/jvmMain` and `src/jsMain` directories
134+
### Code Organization
135+
1. **Engine core**: `tiny-engine/src/commonMain/kotlin` - shared multiplatform logic
136+
2. **Platform specifics**: `src/jvmMain` (desktop/LWJGL) and `src/jsMain` (web/WebGL)
137+
3. **CLI commands**: `tiny-cli/src/main/kotlin/com/github/minigdx/tiny/cli/command/`
138+
4. **Lua API libraries**: `tiny-engine/src/commonMain/kotlin/com/github/minigdx/tiny/lua/`
139+
5. **Tests**: `src/commonTest/kotlin` for shared tests, platform-specific in `src/jvmTest` and `src/jsTest`
140+
141+
### Development Features
142+
- **Hot-reload**: Games update without engine restart for rapid iteration
143+
- **Multi-module build**: Independent module development and testing
144+
- **Documentation generation**: KSP-based API documentation from code annotations
86145

87-
The project uses hot-reload for rapid development - games can be updated without restarting the engine.
146+
### Module Dependencies
147+
- `tiny-engine` is the core with no dependencies on other modules
148+
- `tiny-cli` depends on `tiny-engine` for game execution
149+
- `tiny-web-editor` provides browser-based development interface
150+
- `tiny-doc` modules handle documentation generation pipeline
88151

89152
# AI Instructions
90153
## Role and Objective
@@ -95,6 +158,7 @@ You are Coding Copilot, configured to assist in a multi-language codebase (Kotli
95158
- If a task cannot be completed due to lack of information, respond with a comment indicating the missing context.
96159
- You MUST interpret the documentation with zero ambiguity — never make assumptions beyond what is explicitly provided.
97160
- Maintain consistency across languages (e.g., variable naming, file structure) as defined in the guidelines.
161+
- The code MUST be compatible with Open GL 3 and WebGL 2.0.
98162
## Instructions
99163
1. Read the code context and user intent.
100164
2. Refer to the documentation attached to this prompt for all formatting, naming, and architecture rules.

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ end
3434

3535
---
3636

37+
## ⌨️ CLI Commands
38+
39+
```bash
40+
tiny-cli create <name> # Create new game
41+
tiny-cli run # Run game
42+
tiny-cli debug # Run with debugger
43+
tiny-cli serve # Dev server with hot reload
44+
tiny-cli export # Export for web
45+
tiny-cli palette # Generate color palettes
46+
tiny-cli sfx # Sound effect editor
47+
tiny-cli add # Add resources to project
48+
```
49+
3750
## 📦 Download
3851

3952
Get the latest version from the [Releases Page](https://github.com/minigdx/tiny/releases).
@@ -72,6 +85,18 @@ Want to create games like these? Dive into the docs and start building:
7285

7386
---
7487

88+
## 🤝 Contributing
89+
90+
We welcome contributions!
91+
92+
1. Fork the repository
93+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
94+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
95+
4. Push to the branch (`git push origin feature/amazing-feature`)
96+
5. Open a Pull Request
97+
98+
---
99+
75100
## 📄 License
76101

77102
🧸 Tiny is open-source software licensed under the [MIT License](https://github.com/minigdx/tiny/blob/main/LICENSE).

gradle.properties

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ org.gradle.caching=true
33
org.gradle.configureondemand=true
44
org.gradle.jvmargs=-Xmx2048M
55
org.gradle.parallel=true
6-
# Configuration cache doesn't play well with application plugin and jvmArgs.
7-
# org.gradle.unsafe.configuration-cache=true
6+
org.gradle.unsafe.configuration-cache=false
87

98
# Test K2 (not working yet)
109
# minigdx.mpp.k2=true
1110

1211
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
13-
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
12+
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true

gradle/libs.versions.toml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
[versions]
2-
asciidoctorj = "3.3.2"
2+
asciidoctorj = "4.0.4"
33
clikt = "5.0.3"
44
gifencoder = "0.10.1"
55
jna = "5.14.0"
6-
kgl = "0.8.4"
6+
kgl = "0.9.0"
77
kotlin-coroutines = "1.10.2"
8-
kotlin-ksp = "2.1.20-1.0.32"
9-
kotlin-serialization = "2.1.20"
10-
kotlin-serialization-json = "1.8.1"
11-
ktor = "3.1.2"
12-
luak = "1.1.0"
8+
kotlin-ksp = "2.2.20-2.0.4"
9+
kotlin-serialization = "2.2.20"
10+
kotlin-serialization-json = "1.9.0"
11+
ktor = "3.3.1"
12+
luak = "1.2.0"
1313
lwjgl = "3.3.6"
14-
minigdx-developer = "1.4.2"
15-
mokkery = "2.7.2"
14+
minigdx-developer = "1.5.0"
15+
mokkery = "2.10.1"
1616
rsyntax = "3.6.0"
1717
slf4j = "2.0.7"
1818

@@ -23,6 +23,7 @@ jna = {module="net.java.dev.jna:jna-platform", version.ref = "jna"}
2323
rsyntax = {module="com.fifesoft:rsyntaxtextarea", version.ref = "rsyntax"}
2424

2525
kotlin-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlin-coroutines" }
26+
kotlin-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlin-coroutines" }
2627
kotlin-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlin-serialization-json" }
2728

2829
luak = { module = "com.github.minigdx:luak", version.ref = "luak" }

0 commit comments

Comments
 (0)