Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat: Add stats overlay and improve RenderPipeline

esenginebba9ce654a7a
diff --git a/assets/.esengine/assets.db b/assets/.esengine/assets.db
index 1af9460ab..d01a8c13b 100644
--- a/assets/.esengine/assets.db
+++ b/assets/.esengine/assets.db
@@ -2,59 +2,50 @@
"version": "1.0",
"assets": [
{
- "guid": "bbb48cfb-31bf-8e65-6d26-fa4156d4b29c",
- "path": "F:\\microes\\assets\\shaders\\grid.esshader",
- "name": "grid.esshader",
- "type": 0,
- "fileSize": 318,
- "lastModified": 1769701529,
- "isDirectory": false
- },
- {
- "guid": "73405f12-7a43-8434-140c-748f9448be34",
- "path": "F:\\microes\\assets\\shaders\\axis.esshader",
- "name": "axis.esshader",
- "type": 0,
- "fileSize": 392,
- "lastModified": 1769701535,
+ "guid": "2402078f-7772-c860-8bce-dfdb1fc37788",
+ "path": "F:\\microes\\assets\\audio\\bgm_main.mp3",
+ "name": "bgm_main.mp3",
+ "type": 3,
+ "fileSize": 0,
+ "lastModified": 1769503001,
"isDirectory": false
},
{
- "guid": "4b48ff38-aeb0-7a1b-38ec-03ad938736e9",
- "path": "F:\\microes\\assets\\shaders\\sprite.glsl",
+ "guid": "fb6e1999-a210-5293-9dc9-f648e6e8fc1f",
+ "path": "assets\\shaders\\sprite.glsl",
"name": "sprite.glsl",
"type": 5,
"fileSize": 0,
- "lastModified": 1769503001,
+ "lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "32dd883f-81c7-59a9-8229-5920e8152da1",
- "path": "assets\\prefabs",
- "name": "prefabs",
- "type": 1,
- "fileSize": 0,
- "lastModified": 1769503001,
- "isDirectory": true
- },
- {
- "guid": "a424334b-4399-6ab1-440c-7da10d865e15",
- "path": "assets\\scripts\\UIManager.js",
- "name": "UIManager.js",
- "type": 4,
+ "guid": "539c3218-76fb-bed8-1442-3c43ae5be464",
+ "path": "F:\\microes\\assets\\textures\\tileset.png",
+ "name": "tileset.png",
+ "type": 2,
"fileSize": 0,
- "lastModified": 1769503001,
+ "lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "83dd6048-d8fa-b62a-47d1-6f17771c459f",
- "path": "F:\\microes\\assets\\scripts",
- "name": "scripts",
+ "guid": "99c227eb-f8d3-d0e8-843b-ceb126687e8b",
+ "path": "F:\\microes\\assets\\audio",
+ "name": "audio",
"type": 1,
"fileSize": 0,
"lastModified": 1769503002,
"isDirectory": true
},
+ {
+ "guid": "1c90475d-0d57-c627-f004-15d52bee4319",
+ "path": "F:\\microes\\assets\\shaders\\water.glsl",
+ "name": "water.glsl",
+ "type": 5,
+ "fileSize": 0,
+ "lastModified": 1769503002,
+ "isDirectory": false
+ },
{
"guid": "86ed9e0d-442c-a047-9b51-09011c881685",
"path": "assets\\audio",
@@ -74,59 +65,41 @@
"isDirectory": false
},
{
- "guid": "fb6e1999-a210-5293-9dc9-f648e6e8fc1f",
- "path": "assets\\shaders\\sprite.glsl",
- "name": "sprite.glsl",
- "type": 5,
- "fileSize": 0,
- "lastModified": 1769503002,
+ "guid": "73405f12-7a43-8434-140c-748f9448be34",
+ "path": "F:\\microes\\assets\\shaders\\axis.esshader",
+ "name": "axis.esshader",
+ "type": 0,
+ "fileSize": 392,
+ "lastModified": 1769701535,
"isDirectory": false
},
{
- "guid": "539c3218-76fb-bed8-1442-3c43ae5be464",
- "path": "F:\\microes\\assets\\textures\\tileset.png",
- "name": "tileset.png",
+ "guid": "c771ea16-ad7f-3333-df52-9426cff8a384",
+ "path": "assets\\textures\\ui_button.png",
+ "name": "ui_button.png",
"type": 2,
"fileSize": 0,
- "lastModified": 1769503001,
- "isDirectory": false
- },
- {
- "guid": "49fa3441-7d74-bf79-c116-717b849b78ce",
- "path": "F:\\microes\\assets\\prefabs\\Player.prefab",
- "name": "Player.prefab",
- "type": 7,
- "fileSize": 0,
"lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "d3d9a556-8861-fbc2-504a-151ef73f41de",
- "path": "F:\\microes\\assets\\textures\\player.png",
- "name": "player.png",
- "type": 2,
- "fileSize": 0,
- "lastModified": 1769503002,
+ "guid": "a19bf5bf-7a78-8cbd-00c8-8f38cf141628",
+ "path": "F:\\microes\\assets\\fonts\\msyh.ttc",
+ "name": "msyh.ttc",
+ "type": 0,
+ "fileSize": 19704352,
+ "lastModified": 1769511857,
"isDirectory": false
},
{
- "guid": "f29a2ee0-016a-f018-436a-9c11731f251a",
- "path": "F:\\microes\\assets\\scripts\\Inventory.js",
- "name": "Inventory.js",
- "type": 4,
+ "guid": "ca89cb26-11ee-a95a-940a-4d952d33b936",
+ "path": "F:\\microes\\assets\\scenes\\MainMenu.scene",
+ "name": "MainMenu.scene",
+ "type": 6,
"fileSize": 0,
- "lastModified": 1769503001,
+ "lastModified": 1769503002,
"isDirectory": false
},
- {
- "guid": "e0220f45-6261-175f-883b-ba80783788f2",
- "path": "assets\\textures",
- "name": "textures",
- "type": 1,
- "fileSize": 0,
- "lastModified": 1769503001,
- "isDirectory": true
- },
{
"guid": "602e5d05-e6b5-3cbe-a3a4-857b4290f255",
"path": "assets\\scripts\\CameraFollow.js",
@@ -137,62 +110,44 @@
"isDirectory": false
},
{
- "guid": "ca89cb26-11ee-a95a-940a-4d952d33b936",
- "path": "F:\\microes\\assets\\scenes\\MainMenu.scene",
- "name": "MainMenu.scene",
- "type": 6,
- "fileSize": 0,
- "lastModified": 1769503001,
+ "guid": "44aa95ad-d460-37e0-041f-c6a4449f8b17",
+ "path": "assets\\textures\\test.png",
+ "name": "test.png",
+ "type": 2,
+ "fileSize": 6,
+ "lastModified": 1769488063,
"isDirectory": false
},
{
- "guid": "83d5664f-9f0b-4687-73b2-b854c5e6d5cf",
- "path": "assets\\fonts",
- "name": "fonts",
- "type": 1,
- "fileSize": 0,
- "lastModified": 1769501795,
- "isDirectory": true
- },
- {
- "guid": "d0e72f1c-981f-5995-dade-848b8b18813e",
- "path": "assets\\textures\\background.png",
- "name": "background.png",
- "type": 2,
+ "guid": "b9c53311-d99a-e00b-9ba2-358e123efa4e",
+ "path": "assets\\scripts\\GameManager.js",
+ "name": "GameManager.js",
+ "type": 4,
"fileSize": 0,
"lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "458ea613-0ce1-0325-3f9c-9f6937eafacf",
- "path": "assets\\prefabs\\Player.prefab",
- "name": "Player.prefab",
- "type": 7,
+ "guid": "4f4e6a0b-08fb-1c62-5a27-830f643cacff",
+ "path": "F:\\microes\\assets\\prefabs",
+ "name": "prefabs",
+ "type": 1,
"fileSize": 0,
- "lastModified": 1769503001,
- "isDirectory": false
- },
- {
- "guid": "a9993ed8-9802-fb1c-f5e4-15864011fa2c",
- "path": "F:\\microes\\assets\\textures\\test.png",
- "name": "test.png",
- "type": 2,
- "fileSize": 6,
- "lastModified": 1769488062,
- "isDirectory": false
+ "lastModified": 1769503002,
+ "isDirectory": true
},
{
- "guid": "6837963f-192a-0bcb-80e2-1cb45a8e35e7",
- "path": "assets\\scripts\\PlayerController.js",
- "name": "PlayerController.js",
- "type": 4,
+ "guid": "f543cca8-b481-a8be-8507-770c03c75eab",
+ "path": "assets\\scenes",
+ "name": "scenes",
+ "type": 1,
"fileSize": 0,
"lastModified": 1769503002,
- "isDirectory": false
+ "isDirectory": true
},
{
- "guid": "3750f28c-b12f-4245-2036-9c552be15aea",
- "path": "F:\\microes\\assets\\fonts\\lucide.ttf",
+ "guid": "06d02285-6f13-7665-e142-87cc08b9f6b8",
+ "path": "assets\\fonts\\lucide.ttf",
"name": "lucide.ttf",
"type": 8,
"fileSize": 793848,
@@ -200,49 +155,40 @@
"isDirectory": false
},
{
- "guid": "02f1f294-5a7f-d28b-7095-a04518207f9c",
- "path": "F:\\microes\\assets\\scripts\\GameManager.js",
- "name": "GameManager.js",
- "type": 4,
+ "guid": "7fe2a865-bb30-1847-62e3-d289b5616a3a",
+ "path": "F:\\microes\\assets\\scenes\\BossRoom.scene",
+ "name": "BossRoom.scene",
+ "type": 6,
"fileSize": 0,
"lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "3cc64ba4-5416-2768-7eff-dbba531179c4",
- "path": "assets\\textures\\particle.png",
- "name": "particle.png",
+ "guid": "d0e72f1c-981f-5995-dade-848b8b18813e",
+ "path": "assets\\textures\\background.png",
+ "name": "background.png",
"type": 2,
"fileSize": 0,
- "lastModified": 1769503001,
+ "lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "9d4aa6d5-4f32-3634-e6fa-2c79467a2a9c",
- "path": "F:\\microes\\assets\\shaders",
- "name": "shaders",
+ "guid": "83d5664f-9f0b-4687-73b2-b854c5e6d5cf",
+ "path": "assets\\fonts",
+ "name": "fonts",
"type": 1,
"fileSize": 0,
- "lastModified": 1769701536,
+ "lastModified": 1769501795,
"isDirectory": true
},
{
- "guid": "88f4512c-08fc-7521-0720-aa75e35defbc",
- "path": "assets\\audio\\bgm_main.mp3",
- "name": "bgm_main.mp3",
- "type": 3,
+ "guid": "e0220f45-6261-175f-883b-ba80783788f2",
+ "path": "assets\\textures",
+ "name": "textures",
+ "type": 1,
"fileSize": 0,
"lastModified": 1769503001,
- "isDirectory": false
- },
- {
- "guid": "6f4b1d08-8b77-b7eb-629d-c2ea4efba441",
- "path": "F:\\microes\\assets\\prefabs\\Coin.prefab",
- "name": "Coin.prefab",
- "type": 7,
- "fileSize": 0,
- "lastModified": 1769503002,
- "isDirectory": false
+ "isDirectory": true
},
{
"guid": "9db35f84-665c-e687-86b1-cc78a3934216",
@@ -254,82 +200,91 @@
"isDirectory": false
},
{
- "guid": "abf642da-9512-d0bd-e306-e1bce616320c",
- "path": "F:\\microes\\assets\\scenes\\Level2.scene",
- "name": "Level2.scene",
+ "guid": "02f457d5-e200-7f62-6850-7612ed829a63",
+ "path": "assets\\scenes\\BossRoom.scene",
+ "name": "BossRoom.scene",
"type": 6,
"fileSize": 0,
"lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "1c90475d-0d57-c627-f004-15d52bee4319",
- "path": "F:\\microes\\assets\\shaders\\water.glsl",
- "name": "water.glsl",
- "type": 5,
+ "guid": "b162bd84-eee3-1b79-807c-c64d2c64cb2b",
+ "path": "F:\\microes\\assets\\scripts\\PlayerController.js",
+ "name": "PlayerController.js",
+ "type": 4,
"fileSize": 0,
- "lastModified": 1769503001,
+ "lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "99c227eb-f8d3-d0e8-843b-ceb126687e8b",
- "path": "F:\\microes\\assets\\audio",
- "name": "audio",
- "type": 1,
+ "guid": "38633421-fb34-4766-58e7-b4ba7c8b5ee3",
+ "path": "assets\\audio\\sfx_explosion.wav",
+ "name": "sfx_explosion.wav",
+ "type": 3,
"fileSize": 0,
"lastModified": 1769503002,
- "isDirectory": true
+ "isDirectory": false
},
{
- "guid": "8af759e0-a053-8e8c-1e34-48843f734d2f",
- "path": "assets\\textures\\enemy.png",
- "name": "enemy.png",
+ "guid": "d44064b6-5cd8-29c4-8dc3-e6f0b71c6ad1",
+ "path": "F:\\microes\\assets\\textures\\ui_panel.png",
+ "name": "ui_panel.png",
"type": 2,
"fileSize": 0,
"lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "08964537-6809-2c47-8997-7bbf1c75029f",
- "path": "assets\\scripts",
- "name": "scripts",
- "type": 1,
+ "guid": "6650f3d3-a906-b4a9-1873-b75759499bf8",
+ "path": "F:\\microes\\assets\\audio\\sfx_jump.wav",
+ "name": "sfx_jump.wav",
+ "type": 3,
"fileSize": 0,
"lastModified": 1769503002,
- "isDirectory": true
+ "isDirectory": false
},
{
- "guid": "ed1cf9a5-9d96-50d7-e385-82c605f70a63",
- "path": "F:\\microes\\assets\\prefabs\\Explosion.prefab",
- "name": "Explosion.prefab",
- "type": 7,
+ "guid": "3cc64ba4-5416-2768-7eff-dbba531179c4",
+ "path": "assets\\textures\\particle.png",
+ "name": "particle.png",
+ "type": 2,
"fileSize": 0,
- "lastModified": 1769503002,
+ "lastModified": 1769503001,
"isDirectory": false
},
{
- "guid": "44626f54-604d-ae12-0f2e-2087f068acbf",
- "path": "F:\\microes\\assets\\prefabs\\Enemy.prefab",
- "name": "Enemy.prefab",
- "type": 7,
+ "guid": "02f1f294-5a7f-d28b-7095-a04518207f9c",
+ "path": "F:\\microes\\assets\\scripts\\GameManager.js",
+ "name": "GameManager.js",
+ "type": 4,
"fileSize": 0,
- "lastModified": 1769503002,
+ "lastModified": 1769503001,
"isDirectory": false
},
{
- "guid": "986b148c-b4ea-cf89-2e04-37dc26624976",
- "path": "F:\\microes\\assets\\textures\\particle.png",
- "name": "particle.png",
+ "guid": "3750f28c-b12f-4245-2036-9c552be15aea",
+ "path": "F:\\microes\\assets\\fonts\\lucide.ttf",
+ "name": "lucide.ttf",
+ "type": 8,
+ "fileSize": 793848,
+ "lastModified": 1769501795,
+ "isDirectory": false
+ },
+ {
+ "guid": "7d86b8df-60d3-330a-ae99-ae597a929a9b",
+ "path": "assets\\textures\\player.png",
+ "name": "player.png",
"type": 2,
"fileSize": 0,
"lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "234c30b6-359c-51c1-a526-a970984ad90a",
- "path": "F:\\microes\\assets\\textures\\enemy.png",
- "name": "enemy.png",
- "type": 2,
+ "guid": "ca417dff-fe94-4361-ec9b-16504f048514",
+ "path": "F:\\microes\\assets\\prefabs\\Bullet.prefab",
+ "name": "Bullet.prefab",
+ "type": 7,
"fileSize": 0,
"lastModified": 1769503002,
"isDirectory": false
@@ -362,183 +317,165 @@
"isDirectory": false
},
{
- "guid": "2402078f-7772-c860-8bce-dfdb1fc37788",
- "path": "F:\\microes\\assets\\audio\\bgm_main.mp3",
- "name": "bgm_main.mp3",
- "type": 3,
+ "guid": "83dd6048-d8fa-b62a-47d1-6f17771c459f",
+ "path": "F:\\microes\\assets\\scripts",
+ "name": "scripts",
+ "type": 1,
"fileSize": 0,
- "lastModified": 1769503002,
- "isDirectory": false
+ "lastModified": 1769503001,
+ "isDirectory": true
},
{
- "guid": "090ed68c-0dbe-382c-e163-5ad3bc22abad",
- "path": "F:\\microes\\assets\\scenes\\Level1.scene",
- "name": "Level1.scene",
- "type": 6,
+ "guid": "08719359-3487-beb2-0d62-f54a2a8634c4",
+ "path": "assets\\shaders",
+ "name": "shaders",
+ "type": 1,
"fileSize": 0,
"lastModified": 1769503002,
- "isDirectory": false
+ "isDirectory": true
},
{
- "guid": "22bdfe10-0ff6-620f-56ec-26a8142aec33",
- "path": "assets\\textures\\skybox.png",
- "name": "skybox.png",
- "type": 2,
+ "guid": "bca66dcd-f892-9c43-f176-62ac939c4de4",
+ "path": "F:\\microes\\assets\\audio\\sfx_attack.wav",
+ "name": "sfx_attack.wav",
+ "type": 3,
"fileSize": 0,
- "lastModified": 1769503001,
+ "lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "ff5ba3b5-d524-f202-72ae-a40add555353",
- "path": "assets\\scenes\\Level2.scene",
- "name": "Level2.scene",
- "type": 6,
+ "guid": "57c85655-8b7d-e5b6-d5a6-80eb2b0b49d3",
+ "path": "assets\\scripts\\Inventory.js",
+ "name": "Inventory.js",
+ "type": 4,
"fileSize": 0,
"lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "0926ee8f-8eef-58fa-8d75-0ac49a8bf2b1",
- "path": "F:\\microes\\assets\\scenes",
- "name": "scenes",
- "type": 1,
- "fileSize": 0,
- "lastModified": 1769503002,
- "isDirectory": true
+ "guid": "bbb48cfb-31bf-8e65-6d26-fa4156d4b29c",
+ "path": "F:\\microes\\assets\\shaders\\grid.esshader",
+ "name": "grid.esshader",
+ "type": 0,
+ "fileSize": 318,
+ "lastModified": 1769701529,
+ "isDirectory": false
},
{
- "guid": "bbbdbf23-cecf-5053-0ebe-f3daf5b9e103",
- "path": "assets\\prefabs\\Explosion.prefab",
- "name": "Explosion.prefab",
+ "guid": "c71b2168-6faf-8d98-2ce8-4175ecfc98f2",
+ "path": "assets\\prefabs\\Bullet.prefab",
+ "name": "Bullet.prefab",
"type": 7,
"fileSize": 0,
"lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "ab8960b7-4b05-8029-7577-571c44b9c394",
- "path": "F:\\microes\\assets\\fonts",
- "name": "fonts",
- "type": 1,
- "fileSize": 0,
- "lastModified": 1769653160,
- "isDirectory": true
+ "guid": "6a7bd38a-6b72-be37-a497-9628dafb35e1",
+ "path": "F:\\microes\\assets\\.esengine\\assets.db",
+ "name": "assets.db",
+ "type": 0,
+ "fileSize": 24088,
+ "lastModified": 1769737335,
+ "isDirectory": false
},
{
- "guid": "0f5a7d56-b021-7cfe-9ffd-b6deba57b565",
- "path": "assets\\textures\\ui_panel.png",
- "name": "ui_panel.png",
- "type": 2,
+ "guid": "49fa3441-7d74-bf79-c116-717b849b78ce",
+ "path": "F:\\microes\\assets\\prefabs\\Player.prefab",
+ "name": "Player.prefab",
+ "type": 7,
"fileSize": 0,
- "lastModified": 1769503001,
+ "lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "f928d327-1c23-3d66-2009-d4d3daea8e31",
- "path": "F:\\microes\\assets\\textures\\skybox.png",
- "name": "skybox.png",
+ "guid": "d3d9a556-8861-fbc2-504a-151ef73f41de",
+ "path": "F:\\microes\\assets\\textures\\player.png",
+ "name": "player.png",
"type": 2,
"fileSize": 0,
- "lastModified": 1769503002,
+ "lastModified": 1769503001,
"isDirectory": false
},
{
- "guid": "30c0a678-ec31-5c3c-f60c-2b982d208861",
- "path": "F:\\microes\\assets\\textures\\background.png",
- "name": "background.png",
- "type": 2,
+ "guid": "f29a2ee0-016a-f018-436a-9c11731f251a",
+ "path": "F:\\microes\\assets\\scripts\\Inventory.js",
+ "name": "Inventory.js",
+ "type": 4,
"fileSize": 0,
"lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "182aa6a4-c774-8473-5238-49e1d28f1c5d",
- "path": "assets\\prefabs\\Enemy.prefab",
- "name": "Enemy.prefab",
+ "guid": "458ea613-0ce1-0325-3f9c-9f6937eafacf",
+ "path": "assets\\prefabs\\Player.prefab",
+ "name": "Player.prefab",
"type": 7,
"fileSize": 0,
- "lastModified": 1769503002,
+ "lastModified": 1769503001,
"isDirectory": false
},
{
- "guid": "7fe2a865-bb30-1847-62e3-d289b5616a3a",
- "path": "F:\\microes\\assets\\scenes\\BossRoom.scene",
- "name": "BossRoom.scene",
- "type": 6,
- "fileSize": 0,
- "lastModified": 1769503001,
+ "guid": "a9993ed8-9802-fb1c-f5e4-15864011fa2c",
+ "path": "F:\\microes\\assets\\textures\\test.png",
+ "name": "test.png",
+ "type": 2,
+ "fileSize": 6,
+ "lastModified": 1769488063,
"isDirectory": false
},
{
- "guid": "d6dbbbb3-87ce-a096-8027-f7b9d7129e6f",
- "path": "assets\\scripts\\EnemyAI.js",
- "name": "EnemyAI.js",
+ "guid": "6837963f-192a-0bcb-80e2-1cb45a8e35e7",
+ "path": "assets\\scripts\\PlayerController.js",
+ "name": "PlayerController.js",
"type": 4,
"fileSize": 0,
- "lastModified": 1769503001,
+ "lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "04f5ced8-9d11-fa20-d612-06f12e563341",
- "path": "assets\\prefabs\\Coin.prefab",
- "name": "Coin.prefab",
+ "guid": "44626f54-604d-ae12-0f2e-2087f068acbf",
+ "path": "F:\\microes\\assets\\prefabs\\Enemy.prefab",
+ "name": "Enemy.prefab",
"type": 7,
"fileSize": 0,
"lastModified": 1769503001,
"isDirectory": false
},
{
- "guid": "8283ad01-d8a2-48ae-c4e7-c1f8f0de7955",
- "path": "F:\\microes\\assets\\scripts\\UIManager.js",
- "name": "UIManager.js",
- "type": 4,
- "fileSize": 0,
- "lastModified": 1769503002,
- "isDirectory": false
- },
- {
- "guid": "b55ead52-b974-950b-26a3-a227e2ac41e9",
- "path": "assets\\audio\\sfx_coin.wav",
- "name": "sfx_coin.wav",
- "type": 3,
+ "guid": "ce69c963-c0ea-0fb2-c96c-bf1afc0e0802",
+ "path": "assets\\shaders\\postprocess.glsl",
+ "name": "postprocess.glsl",
+ "type": 5,
"fileSize": 0,
"lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "c6113f63-03d0-811d-550a-8f26f331233d",
- "path": "assets\\textures\\tileset.png",
- "name": "tileset.png",
- "type": 2,
+ "guid": "78390dfc-f548-9908-8279-6b3064ea26b3",
+ "path": "F:\\microes\\assets\\textures",
+ "name": "textures",
+ "type": 1,
"fileSize": 0,
"lastModified": 1769503002,
- "isDirectory": false
+ "isDirectory": true
},
{
- "guid": "90db01ce-eadb-5131-35ee-a55e9f60bb4d",
- "path": "assets\\shaders\\water.glsl",
- "name": "water.glsl",
+ "guid": "e704f3d4-170b-fecb-d4f9-4534e5056d78",
+ "path": "assets\\shaders\\particle.glsl",
+ "name": "particle.glsl",
"type": 5,
"fileSize": 0,
"lastModified": 1769503001,
"isDirectory": false
},
- {
- "guid": "6e88b347-db2d-b526-87c6-301569094b15",
- "path": "F:\\microes\\assets\\audio\\sfx_explosion.wav",
- "name": "sfx_explosion.wav",
- "type": 3,
- "fileSize": 0,
- "lastModified": 1769503002,
- "isDirectory": false
- },
{
"guid": "9d69bbdf-276b-8f14-cc66-10e8dfcdb283",
"path": "F:\\microes\\assets\\scripts\\CameraFollow.js",
"name": "CameraFollow.js",
"type": 4,
"fileSize": 0,
- "lastModified": 1769503001,
+ "lastModified": 1769503002,
"isDirectory": false
},
{
@@ -560,292 +497,355 @@
"isDirectory": false
},
{
- "guid": "a6dd418b-dd75-0249-f26e-bb1b4cc294c8",
- "path": "F:\\microes\\assets\\shaders\\postprocess.glsl",
- "name": "postprocess.glsl",
- "type": 5,
+ "guid": "88f4512c-08fc-7521-0720-aa75e35defbc",
+ "path": "assets\\audio\\bgm_main.mp3",
+ "name": "bgm_main.mp3",
+ "type": 3,
"fileSize": 0,
- "lastModified": 1769503002,
+ "lastModified": 1769503001,
"isDirectory": false
},
{
- "guid": "835ed25e-a75f-3a42-0953-d9af26b1cc87",
- "path": "F:\\microes\\assets\\test.txt",
- "name": "test.txt",
- "type": 0,
- "fileSize": 5,
- "lastModified": 1769488062,
- "isDirectory": false
+ "guid": "9d4aa6d5-4f32-3634-e6fa-2c79467a2a9c",
+ "path": "F:\\microes\\assets\\shaders",
+ "name": "shaders",
+ "type": 1,
+ "fileSize": 0,
+ "lastModified": 1769703321,
+ "isDirectory": true
},
{
- "guid": "e704f3d4-170b-fecb-d4f9-4534e5056d78",
- "path": "assets\\shaders\\particle.glsl",
- "name": "particle.glsl",
- "type": 5,
+ "guid": "6f4b1d08-8b77-b7eb-629d-c2ea4efba441",
+ "path": "F:\\microes\\assets\\prefabs\\Coin.prefab",
+ "name": "Coin.prefab",
+ "type": 7,
"fileSize": 0,
"lastModified": 1769503001,
"isDirectory": false
},
{
- "guid": "78390dfc-f548-9908-8279-6b3064ea26b3",
- "path": "F:\\microes\\assets\\textures",
- "name": "textures",
- "type": 1,
+ "guid": "90db01ce-eadb-5131-35ee-a55e9f60bb4d",
+ "path": "assets\\shaders\\water.glsl",
+ "name": "water.glsl",
+ "type": 5,
"fileSize": 0,
- "lastModified": 1769503002,
- "isDirectory": true
+ "lastModified": 1769503001,
+ "isDirectory": false
},
{
- "guid": "ce792685-9959-2c9f-d909-597cab98305a",
- "path": "F:\\microes\\assets\\fonts\\lucide_new.ttf",
- "name": "lucide_new.ttf",
- "type": 8,
- "fileSize": 793848,
- "lastModified": 1769653162,
+ "guid": "6e88b347-db2d-b526-87c6-301569094b15",
+ "path": "F:\\microes\\assets\\audio\\sfx_explosion.wav",
+ "name": "sfx_explosion.wav",
+ "type": 3,
+ "fileSize": 0,
+ "lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "08719359-3487-beb2-0d62-f54a2a8634c4",
- "path": "assets\\shaders",
- "name": "shaders",
- "type": 1,
+ "guid": "b55ead52-b974-950b-26a3-a227e2ac41e9",
+ "path": "assets\\audio\\sfx_coin.wav",
+ "name": "sfx_coin.wav",
+ "type": 3,
"fileSize": 0,
"lastModified": 1769503002,
- "isDirectory": true
+ "isDirectory": false
},
{
- "guid": "d44064b6-5cd8-29c4-8dc3-e6f0b71c6ad1",
- "path": "F:\\microes\\assets\\textures\\ui_panel.png",
- "name": "ui_panel.png",
+ "guid": "c6113f63-03d0-811d-550a-8f26f331233d",
+ "path": "assets\\textures\\tileset.png",
+ "name": "tileset.png",
"type": 2,
"fileSize": 0,
- "lastModified": 1769503001,
+ "lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "d11c2d62-5870-5040-3e1a-bf5bc046b98a",
- "path": "F:\\microes\\assets\\textures\\ui_button.png",
- "name": "ui_button.png",
- "type": 2,
+ "guid": "53cf7de5-ae26-2632-e022-e9108f6bbc2c",
+ "path": "F:\\microes\\assets\\audio\\sfx_coin.wav",
+ "name": "sfx_coin.wav",
+ "type": 3,
"fileSize": 0,
"lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "c6908b3b-7d16-8e81-5c2d-c65c46fee0d4",
- "path": "assets\\audio\\bgm_battle.mp3",
- "name": "bgm_battle.mp3",
- "type": 3,
+ "guid": "e1d87090-38ce-2d60-5bdd-1f928fdaf88a",
+ "path": "assets\\scenes\\Level1.scene",
+ "name": "Level1.scene",
+ "type": 6,
"fileSize": 0,
"lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "0b354ef8-0528-35e8-b628-bed14b4960db",
- "path": "F:\\microes\\assets\\audio\\bgm_battle.mp3",
- "name": "bgm_battle.mp3",
- "type": 3,
+ "guid": "182aa6a4-c774-8473-5238-49e1d28f1c5d",
+ "path": "assets\\prefabs\\Enemy.prefab",
+ "name": "Enemy.prefab",
+ "type": 7,
"fileSize": 0,
"lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "6650f3d3-a906-b4a9-1873-b75759499bf8",
- "path": "F:\\microes\\assets\\audio\\sfx_jump.wav",
- "name": "sfx_jump.wav",
- "type": 3,
+ "guid": "30c0a678-ec31-5c3c-f60c-2b982d208861",
+ "path": "F:\\microes\\assets\\textures\\background.png",
+ "name": "background.png",
+ "type": 2,
"fileSize": 0,
"lastModified": 1769503001,
"isDirectory": false
},
{
- "guid": "a19bf5bf-7a78-8cbd-00c8-8f38cf141628",
- "path": "F:\\microes\\assets\\fonts\\msyh.ttc",
- "name": "msyh.ttc",
- "type": 0,
- "fileSize": 19704352,
- "lastModified": 1769511858,
+ "guid": "f928d327-1c23-3d66-2009-d4d3daea8e31",
+ "path": "F:\\microes\\assets\\textures\\skybox.png",
+ "name": "skybox.png",
+ "type": 2,
+ "fileSize": 0,
+ "lastModified": 1769503001,
"isDirectory": false
},
{
- "guid": "c771ea16-ad7f-3333-df52-9426cff8a384",
- "path": "assets\\textures\\ui_button.png",
- "name": "ui_button.png",
- "type": 2,
+ "guid": "ce792685-9959-2c9f-d909-597cab98305a",
+ "path": "F:\\microes\\assets\\fonts\\lucide_new.ttf",
+ "name": "lucide_new.ttf",
+ "type": 8,
+ "fileSize": 793848,
+ "lastModified": 1769653162,
+ "isDirectory": false
+ },
+ {
+ "guid": "e11483d8-2203-6eff-1b7e-0932b819f1c9",
+ "path": "assets\\audio\\sfx_attack.wav",
+ "name": "sfx_attack.wav",
+ "type": 3,
"fileSize": 0,
- "lastModified": 1769503002,
+ "lastModified": 1769503001,
"isDirectory": false
},
{
- "guid": "7d86b8df-60d3-330a-ae99-ae597a929a9b",
- "path": "assets\\textures\\player.png",
- "name": "player.png",
- "type": 2,
+ "guid": "0e48ebc1-25c8-2588-29aa-fb40564e2355",
+ "path": "assets\\scenes\\MainMenu.scene",
+ "name": "MainMenu.scene",
+ "type": 6,
"fileSize": 0,
"lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "ca417dff-fe94-4361-ec9b-16504f048514",
- "path": "F:\\microes\\assets\\prefabs\\Bullet.prefab",
- "name": "Bullet.prefab",
+ "guid": "d6dbbbb3-87ce-a096-8027-f7b9d7129e6f",
+ "path": "assets\\scripts\\EnemyAI.js",
+ "name": "EnemyAI.js",
+ "type": 4,
+ "fileSize": 0,
+ "lastModified": 1769503001,
+ "isDirectory": false
+ },
+ {
+ "guid": "04f5ced8-9d11-fa20-d612-06f12e563341",
+ "path": "assets\\prefabs\\Coin.prefab",
+ "name": "Coin.prefab",
"type": 7,
"fileSize": 0,
"lastModified": 1769503001,
"isDirectory": false
},
{
- "guid": "e1d87090-38ce-2d60-5bdd-1f928fdaf88a",
- "path": "assets\\scenes\\Level1.scene",
- "name": "Level1.scene",
- "type": 6,
+ "guid": "8283ad01-d8a2-48ae-c4e7-c1f8f0de7955",
+ "path": "F:\\microes\\assets\\scripts\\UIManager.js",
+ "name": "UIManager.js",
+ "type": 4,
"fileSize": 0,
- "lastModified": 1769503002,
+ "lastModified": 1769503001,
"isDirectory": false
},
{
- "guid": "53cf7de5-ae26-2632-e022-e9108f6bbc2c",
- "path": "F:\\microes\\assets\\audio\\sfx_coin.wav",
- "name": "sfx_coin.wav",
+ "guid": "0b354ef8-0528-35e8-b628-bed14b4960db",
+ "path": "F:\\microes\\assets\\audio\\bgm_battle.mp3",
+ "name": "bgm_battle.mp3",
"type": 3,
"fileSize": 0,
- "lastModified": 1769503002,
+ "lastModified": 1769503001,
"isDirectory": false
},
{
- "guid": "38633421-fb34-4766-58e7-b4ba7c8b5ee3",
- "path": "assets\\audio\\sfx_explosion.wav",
- "name": "sfx_explosion.wav",
- "type": 3,
+ "guid": "d11c2d62-5870-5040-3e1a-bf5bc046b98a",
+ "path": "F:\\microes\\assets\\textures\\ui_button.png",
+ "name": "ui_button.png",
+ "type": 2,
"fileSize": 0,
"lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "b162bd84-eee3-1b79-807c-c64d2c64cb2b",
- "path": "F:\\microes\\assets\\scripts\\PlayerController.js",
- "name": "PlayerController.js",
- "type": 4,
+ "guid": "c6908b3b-7d16-8e81-5c2d-c65c46fee0d4",
+ "path": "assets\\audio\\bgm_battle.mp3",
+ "name": "bgm_battle.mp3",
+ "type": 3,
"fileSize": 0,
"lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "02f457d5-e200-7f62-6850-7612ed829a63",
- "path": "assets\\scenes\\BossRoom.scene",
- "name": "BossRoom.scene",
- "type": 6,
+ "guid": "ed1cf9a5-9d96-50d7-e385-82c605f70a63",
+ "path": "F:\\microes\\assets\\prefabs\\Explosion.prefab",
+ "name": "Explosion.prefab",
+ "type": 7,
"fileSize": 0,
"lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "bca66dcd-f892-9c43-f176-62ac939c4de4",
- "path": "F:\\microes\\assets\\audio\\sfx_attack.wav",
- "name": "sfx_attack.wav",
- "type": 3,
+ "guid": "8af759e0-a053-8e8c-1e34-48843f734d2f",
+ "path": "assets\\textures\\enemy.png",
+ "name": "enemy.png",
+ "type": 2,
"fileSize": 0,
"lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "57c85655-8b7d-e5b6-d5a6-80eb2b0b49d3",
- "path": "assets\\scripts\\Inventory.js",
- "name": "Inventory.js",
- "type": 4,
+ "guid": "08964537-6809-2c47-8997-7bbf1c75029f",
+ "path": "assets\\scripts",
+ "name": "scripts",
+ "type": 1,
"fileSize": 0,
"lastModified": 1769503002,
- "isDirectory": false
+ "isDirectory": true
},
{
- "guid": "6a7bd38a-6b72-be37-a497-9628dafb35e1",
- "path": "F:\\microes\\assets\\.esengine\\assets.db",
- "name": "assets.db",
- "type": 0,
- "fileSize": 23550,
- "lastModified": 1769692416,
+ "guid": "ff5ba3b5-d524-f202-72ae-a40add555353",
+ "path": "assets\\scenes\\Level2.scene",
+ "name": "Level2.scene",
+ "type": 6,
+ "fileSize": 0,
+ "lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "c71b2168-6faf-8d98-2ce8-4175ecfc98f2",
- "path": "assets\\prefabs\\Bullet.prefab",
- "name": "Bullet.prefab",
+ "guid": "bbbdbf23-cecf-5053-0ebe-f3daf5b9e103",
+ "path": "assets\\prefabs\\Explosion.prefab",
+ "name": "Explosion.prefab",
"type": 7,
"fileSize": 0,
"lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "44aa95ad-d460-37e0-041f-c6a4449f8b17",
- "path": "assets\\textures\\test.png",
- "name": "test.png",
+ "guid": "0f5a7d56-b021-7cfe-9ffd-b6deba57b565",
+ "path": "assets\\textures\\ui_panel.png",
+ "name": "ui_panel.png",
"type": 2,
- "fileSize": 6,
- "lastModified": 1769488063,
+ "fileSize": 0,
+ "lastModified": 1769503001,
"isDirectory": false
},
{
- "guid": "4f4e6a0b-08fb-1c62-5a27-830f643cacff",
- "path": "F:\\microes\\assets\\prefabs",
- "name": "prefabs",
+ "guid": "0926ee8f-8eef-58fa-8d75-0ac49a8bf2b1",
+ "path": "F:\\microes\\assets\\scenes",
+ "name": "scenes",
"type": 1,
"fileSize": 0,
"lastModified": 1769503001,
"isDirectory": true
},
{
- "guid": "b9c53311-d99a-e00b-9ba2-358e123efa4e",
- "path": "assets\\scripts\\GameManager.js",
- "name": "GameManager.js",
- "type": 4,
+ "guid": "ab8960b7-4b05-8029-7577-571c44b9c394",
+ "path": "F:\\microes\\assets\\fonts",
+ "name": "fonts",
+ "type": 1,
+ "fileSize": 0,
+ "lastModified": 1769653160,
+ "isDirectory": true
+ },
+ {
+ "guid": "a6dd418b-dd75-0249-f26e-bb1b4cc294c8",
+ "path": "F:\\microes\\assets\\shaders\\postprocess.glsl",
+ "name": "postprocess.glsl",
+ "type": 5,
"fileSize": 0,
"lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "e11483d8-2203-6eff-1b7e-0932b819f1c9",
- "path": "assets\\audio\\sfx_attack.wav",
- "name": "sfx_attack.wav",
- "type": 3,
+ "guid": "835ed25e-a75f-3a42-0953-d9af26b1cc87",
+ "path": "F:\\microes\\assets\\test.txt",
+ "name": "test.txt",
+ "type": 0,
+ "fileSize": 5,
+ "lastModified": 1769488062,
+ "isDirectory": false
+ },
+ {
+ "guid": "abf642da-9512-d0bd-e306-e1bce616320c",
+ "path": "F:\\microes\\assets\\scenes\\Level2.scene",
+ "name": "Level2.scene",
+ "type": 6,
"fileSize": 0,
- "lastModified": 1769503001,
+ "lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "0e48ebc1-25c8-2588-29aa-fb40564e2355",
- "path": "assets\\scenes\\MainMenu.scene",
- "name": "MainMenu.scene",
+ "guid": "090ed68c-0dbe-382c-e163-5ad3bc22abad",
+ "path": "F:\\microes\\assets\\scenes\\Level1.scene",
+ "name": "Level1.scene",
"type": 6,
"fileSize": 0,
"lastModified": 1769503002,
"isDirectory": false
},
{
- "guid": "06d02285-6f13-7665-e142-87cc08b9f6b8",
- "path": "assets\\fonts\\lucide.ttf",
- "name": "lucide.ttf",
- "type": 8,
- "fileSize": 793848,
- "lastModified": 1769501796,
+ "guid": "22bdfe10-0ff6-620f-56ec-26a8142aec33",
+ "path": "assets\\textures\\skybox.png",
+ "name": "skybox.png",
+ "type": 2,
+ "fileSize": 0,
+ "lastModified": 1769503001,
"isDirectory": false
},
{
- "guid": "ce69c963-c0ea-0fb2-c96c-bf1afc0e0802",
- "path": "assets\\shaders\\postprocess.glsl",
- "name": "postprocess.glsl",
- "type": 5,
+ "guid": "a424334b-4399-6ab1-440c-7da10d865e15",
+ "path": "assets\\scripts\\UIManager.js",
+ "name": "UIManager.js",
+ "type": 4,
"fileSize": 0,
- "lastModified": 1769503002,
+ "lastModified": 1769503001,
"isDirectory": false
},
{
- "guid": "f543cca8-b481-a8be-8507-770c03c75eab",
- "path": "assets\\scenes",
- "name": "scenes",
+ "guid": "32dd883f-81c7-59a9-8229-5920e8152da1",
+ "path": "assets\\prefabs",
+ "name": "prefabs",
"type": 1,
"fileSize": 0,
- "lastModified": 1769503002,
+ "lastModified": 1769503001,
"isDirectory": true
+ },
+ {
+ "guid": "4b48ff38-aeb0-7a1b-38ec-03ad938736e9",
+ "path": "F:\\microes\\assets\\shaders\\sprite.glsl",
+ "name": "sprite.glsl",
+ "type": 5,
+ "fileSize": 0,
+ "lastModified": 1769503001,
+ "isDirectory": false
+ },
+ {
+ "guid": "986b148c-b4ea-cf89-2e04-37dc26624976",
+ "path": "F:\\microes\\assets\\textures\\particle.png",
+ "name": "particle.png",
+ "type": 2,
+ "fileSize": 0,
+ "lastModified": 1769503001,
+ "isDirectory": false
+ },
+ {
+ "guid": "234c30b6-359c-51c1-a526-a970984ad90a",
+ "path": "F:\\microes\\assets\\textures\\enemy.png",
+ "name": "enemy.png",
+ "type": 2,
+ "fileSize": 0,
+ "lastModified": 1769503001,
+ "isDirectory": false
}
]
}
diff --git a/data/shaders/batch.esshader b/data/shaders/batch.esshader
index 6da808df8..8029dba9e 100644
--- a/data/shaders/batch.esshader
+++ b/data/shaders/batch.esshader
@@ -1,32 +1,47 @@
#pragma shader "Batch"
#pragma vertex
-attribute vec2 a_position;
-attribute vec2 a_texCoord;
+attribute vec3 a_position;
attribute vec4 a_color;
+attribute vec2 a_texCoord;
+attribute float a_texIndex;
uniform mat4 u_projection;
-varying vec2 v_texCoord;
varying vec4 v_color;
+varying vec2 v_texCoord;
+varying float v_texIndex;
void main() {
- gl_Position = u_projection * vec4(a_position, 0.0, 1.0);
- v_texCoord = a_texCoord;
+ gl_Position = u_projection * vec4(a_position, 1.0);
v_color = a_color;
+ v_texCoord = a_texCoord;
+ v_texIndex = a_texIndex;
}
#pragma end
#pragma fragment
precision mediump float;
-uniform sampler2D u_texture;
-
-varying vec2 v_texCoord;
varying vec4 v_color;
+varying vec2 v_texCoord;
+varying float v_texIndex;
+
+uniform sampler2D u_textures[8];
void main() {
- vec4 texColor = texture2D(u_texture, v_texCoord);
+ int index = int(v_texIndex);
+ vec4 texColor = vec4(1.0);
+
+ if (index == 0) texColor = texture2D(u_textures[0], v_texCoord);
+ else if (index == 1) texColor = texture2D(u_textures[1], v_texCoord);
+ else if (index == 2) texColor = texture2D(u_textures[2], v_texCoord);
+ else if (index == 3) texColor = texture2D(u_textures[3], v_texCoord);
+ else if (index == 4) texColor = texture2D(u_textures[4], v_texCoord);
+ else if (index == 5) texColor = texture2D(u_textures[5], v_texCoord);
+ else if (index == 6) texColor = texture2D(u_textures[6], v_texCoord);
+ else if (index == 7) texColor = texture2D(u_textures[7], v_texCoord);
+
gl_FragColor = texColor * v_color;
}
#pragma end
diff --git a/src/esengine/editor/panels/GameViewPanel.cpp b/src/esengine/editor/panels/GameViewPanel.cpp
index cbedf17c4..a5b7661c4 100644
--- a/src/esengine/editor/panels/GameViewPanel.cpp
+++ b/src/esengine/editor/panels/GameViewPanel.cpp
@@ -38,8 +38,8 @@ GameViewPanel::GameViewPanel(ecs::Registry& registry, resource::ResourceManager&
resourceManager_(resourceManager) {
FramebufferSpec spec;
- spec.width = viewportWidth_;
- spec.height = viewportHeight_;
+ spec.width = viewport_width_;
+ spec.height = viewport_height_;
spec.depthStencil = true;
framebuffer_ = Framebuffer::create(spec);
@@ -51,13 +51,13 @@ GameViewPanel::GameViewPanel(ecs::Registry& registry, resource::ResourceManager&
// =============================================================================
void GameViewPanel::setViewportSize(u32 width, u32 height) {
- if (width == viewportWidth_ && height == viewportHeight_) {
+ if (width == viewport_width_ && height == viewport_height_) {
return;
}
- viewportWidth_ = width;
- viewportHeight_ = height;
- framebufferNeedsResize_ = true;
+ viewport_width_ = width;
+ viewport_height_ = height;
+ framebuffer_needs_resize_ = true;
}
// =============================================================================
@@ -70,11 +70,11 @@ void GameViewPanel::render(ui::UIBatchRenderer& renderer) {
u32 newWidth = static_cast<u32>(bounds.width);
u32 newHeight = static_cast<u32>(bounds.height);
- if (newWidth != viewportWidth_ || newHeight != viewportHeight_) {
+ if (newWidth != viewport_width_ || newHeight != viewport_height_) {
setViewportSize(newWidth, newHeight);
}
- if (framebufferNeedsResize_) {
+ if (framebuffer_needs_resize_) {
updateFramebufferSize();
}
@@ -101,7 +101,7 @@ void GameViewPanel::renderGameToTexture() {
framebuffer_->bind();
- RenderCommand::setViewport(0, 0, viewportWidth_, viewportHeight_);
+ RenderCommand::setViewport(0, 0, viewport_width_, viewport_height_);
Entity canvasEntity = findCanvas();
ecs::Canvas* canvas = canvasEntity != INVALID_ENTITY
@@ -123,7 +123,7 @@ void GameViewPanel::renderGameToTexture() {
glm::mat4_cast(transform->rotation)
);
- f32 viewportAspect = static_cast<f32>(viewportWidth_) / static_cast<f32>(viewportHeight_);
+ f32 viewportAspect = static_cast<f32>(viewport_width_) / static_cast<f32>(viewport_height_);
glm::mat4 proj;
if (camera->projectionType == ecs::ProjectionType::Perspective) {
@@ -197,53 +197,24 @@ void GameViewPanel::renderSceneContent(const glm::mat4& viewProj) {
if (!ctx) return;
RenderContext& renderCtx = ctx->getRenderContext();
- Shader* shader = renderCtx.getTextureShader();
- VertexArray* quadVAO = renderCtx.getQuadVAO();
- if (!shader || !quadVAO) return;
-
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- auto spriteView = registry_.view<ecs::LocalTransform, ecs::Sprite>();
-
- for (auto entity : spriteView) {
- const auto& transform = spriteView.get<ecs::LocalTransform>(entity);
- const auto& sprite = spriteView.get<ecs::Sprite>(entity);
-
- glm::mat4 model = glm::mat4(1.0f);
- model = glm::translate(model, transform.position);
- model *= glm::mat4_cast(transform.rotation);
- model = glm::scale(model, glm::vec3(sprite.size * transform.scale.x, 1.0f));
-
- shader->bind();
- shader->setUniform("u_projection", viewProj);
- shader->setUniform("u_model", model);
- shader->setUniform("u_color", sprite.color);
-
- glActiveTexture(GL_TEXTURE0);
- u32 textureId = renderCtx.getWhiteTextureId();
- if (sprite.texture.isValid()) {
- Texture* tex = resourceManager_.getTexture(sprite.texture);
- if (tex) {
- textureId = tex->getId();
- }
- }
- glBindTexture(GL_TEXTURE_2D, textureId);
- shader->setUniform("u_texture", 0);
-
- RenderCommand::drawIndexed(*quadVAO);
+ if (!render_pipeline_) {
+ render_pipeline_ = makeUnique<RenderPipeline>(renderCtx, resourceManager_);
}
+
+ render_pipeline_->begin(viewProj);
+ render_pipeline_->submit(registry_);
+ render_pipeline_->end();
}
void GameViewPanel::updateFramebufferSize() {
- if (viewportWidth_ == 0 || viewportHeight_ == 0) {
+ if (viewport_width_ == 0 || viewport_height_ == 0) {
return;
}
if (framebuffer_) {
- framebuffer_->resize(viewportWidth_, viewportHeight_);
- framebufferNeedsResize_ = false;
+ framebuffer_->resize(viewport_width_, viewport_height_);
+ framebuffer_needs_resize_ = false;
}
}
diff --git a/src/esengine/editor/panels/GameViewPanel.hpp b/src/esengine/editor/panels/GameViewPanel.hpp
index a9e95b4f8..fbdb38928 100644
--- a/src/esengine/editor/panels/GameViewPanel.hpp
+++ b/src/esengine/editor/panels/GameViewPanel.hpp
@@ -16,6 +16,7 @@
#include "../../ui/docking/DockPanel.hpp"
#include "../../renderer/Framebuffer.hpp"
+#include "../../renderer/RenderPipeline.hpp"
#include "../../ecs/Registry.hpp"
#include "../../resource/ResourceManager.hpp"
@@ -51,10 +52,11 @@ private:
ecs::Registry& registry_;
resource::ResourceManager& resourceManager_;
Unique<Framebuffer> framebuffer_;
+ Unique<RenderPipeline> render_pipeline_;
- u32 viewportWidth_ = 1280;
- u32 viewportHeight_ = 720;
- bool framebufferNeedsResize_ = false;
+ u32 viewport_width_ = 1280;
+ u32 viewport_height_ = 720;
+ bool framebuffer_needs_resize_ = false;
};
} // namespace esengine::editor
diff --git a/src/esengine/editor/panels/SceneViewPanel.cpp b/src/esengine/editor/panels/SceneViewPanel.cpp
index dacff3d20..88ef38fba 100644
--- a/src/esengine/editor/panels/SceneViewPanel.cpp
+++ b/src/esengine/editor/panels/SceneViewPanel.cpp
@@ -19,7 +19,13 @@
#include "../../ecs/components/Canvas.hpp"
#include "../../core/Log.hpp"
#include "../command/TransformCommand.hpp"
+
+#if ES_FEATURE_SDF_FONT
+#include "../../ui/font/MSDFFont.hpp"
+#endif
+
#include <glad/glad.h>
+#include <cstdio>
#include <vector>
#include <chrono>
@@ -71,6 +77,10 @@ SceneViewPanel::SceneViewPanel(ecs::Registry& registry, EntitySelection& selecti
transformGizmo_->setMode(mode);
}));
+ connections_.add(sink(toolbar_->onStatsVisibilityChanged).connect([this](bool visible) {
+ stats_visible_ = visible;
+ }));
+
setMinSize(glm::vec2(200.0f, 200.0f));
}
@@ -96,8 +106,9 @@ void SceneViewPanel::render(ui::UIBatchRenderer& renderer) {
using Clock = std::chrono::steady_clock;
static auto startTime = Clock::now();
f64 currentTime = std::chrono::duration<f64>(Clock::now() - startTime).count();
- f32 deltaTime = static_cast<f32>(currentTime - lastFrameTime_);
- lastFrameTime_ = currentTime;
+ f32 deltaTime = static_cast<f32>(currentTime - last_frame_time_);
+ prev_frame_time_ = last_frame_time_;
+ last_frame_time_ = currentTime;
if (deltaTime > 0.0f && deltaTime < 1.0f) {
camera_.update(deltaTime);
@@ -143,6 +154,10 @@ void SceneViewPanel::render(ui::UIBatchRenderer& renderer) {
renderAxisGizmo2D();
}
}
+
+ if (stats_visible_) {
+ renderStats(renderer);
+ }
}
if (toolbar_) {
@@ -994,6 +1009,86 @@ void SceneViewPanel::renderCanvasGizmo(const glm::mat4& viewProj) {
glDrawArrays(GL_LINES, 0, 8);
}
+void SceneViewPanel::renderStats(ui::UIBatchRenderer& renderer) {
+ ui::UIContext* ctx = getContext();
+ if (!ctx) return;
+
+#if ES_FEATURE_SDF_FONT
+ ui::MSDFFont* font = ctx->getDefaultMSDFFont();
+ if (!font) return;
+
+ RenderPipeline::Stats stats{};
+ if (renderPipeline_) {
+ stats = renderPipeline_->getStats();
+ }
+
+ f64 frameDelta = last_frame_time_ - prev_frame_time_;
+ f32 fps = (frameDelta > 0.001) ? 1.0f / static_cast<f32>(frameDelta) : 0.0f;
+ f32 frameMs = static_cast<f32>(frameDelta * 1000.0);
+
+ constexpr f32 padding = 10.0f;
+ constexpr f32 lineHeight = 16.0f;
+ constexpr f32 fontSize = 11.0f;
+ constexpr f32 panelWidth = 160.0f;
+ constexpr f32 panelHeight = 180.0f;
+ constexpr f32 sectionGap = 6.0f;
+
+ ui::Rect panelBounds = {
+ viewportBounds_.x + padding,
+ viewportBounds_.y + viewportBounds_.height - panelHeight - padding,
+ panelWidth,
+ panelHeight
+ };
+
+ constexpr glm::vec4 bgColor{0.08f, 0.08f, 0.10f, 0.92f};
+ constexpr glm::vec4 headerColor{0.4f, 0.7f, 1.0f, 1.0f};
+ constexpr glm::vec4 valueColor{0.9f, 0.9f, 0.9f, 1.0f};
+ constexpr glm::vec4 labelColor{0.6f, 0.6f, 0.6f, 1.0f};
+
+ renderer.drawRoundedRect(panelBounds, bgColor, ui::CornerRadii::all(6.0f));
+
+ f32 y = panelBounds.y + padding;
+ f32 x = panelBounds.x + padding;
+ char buffer[64];
+
+ renderer.drawText("Rendering", glm::vec2(x, y), *font, fontSize, headerColor);
+ y += lineHeight;
+
+ snprintf(buffer, sizeof(buffer), "FPS: %.1f (%.2fms)", fps, frameMs);
+ renderer.drawText(buffer, glm::vec2(x, y), *font, fontSize, valueColor);
+ y += lineHeight;
+
+ snprintf(buffer, sizeof(buffer), "Draw Calls: %u", stats.draw_calls);
+ renderer.drawText(buffer, glm::vec2(x, y), *font, fontSize, valueColor);
+ y += lineHeight;
+
+ snprintf(buffer, sizeof(buffer), "Tris: %u Verts: %u", stats.triangles, stats.vertices);
+ renderer.drawText(buffer, glm::vec2(x, y), *font, fontSize, valueColor);
+ y += lineHeight + sectionGap;
+
+ renderer.drawText("Batching", glm::vec2(x, y), *font, fontSize, headerColor);
+ y += lineHeight;
+
+ snprintf(buffer, sizeof(buffer), "Batches: %u", stats.batch_count);
+ renderer.drawText(buffer, glm::vec2(x, y), *font, fontSize, valueColor);
+ y += lineHeight;
+
+ snprintf(buffer, sizeof(buffer), "Tex Switches: %u", stats.texture_switches);
+ renderer.drawText(buffer, glm::vec2(x, y), *font, fontSize, labelColor);
+ y += lineHeight + sectionGap;
+
+ renderer.drawText("Scene", glm::vec2(x, y), *font, fontSize, headerColor);
+ y += lineHeight;
+
+ snprintf(buffer, sizeof(buffer), "Sprites: %u", stats.total_items);
+ renderer.drawText(buffer, glm::vec2(x, y), *font, fontSize, valueColor);
+ y += lineHeight;
+
+ snprintf(buffer, sizeof(buffer), "Visible: %u Culled: %u", stats.visible_items, stats.culled_items);
+ renderer.drawText(buffer, glm::vec2(x, y), *font, fontSize, labelColor);
+#endif
+}
+
// =============================================================================
// Ray Picking
// =============================================================================
diff --git a/src/esengine/editor/panels/SceneViewPanel.hpp b/src/esengine/editor/panels/SceneViewPanel.hpp
index 0b66fcdfc..f2ee0fad3 100644
--- a/src/esengine/editor/panels/SceneViewPanel.hpp
+++ b/src/esengine/editor/panels/SceneViewPanel.hpp
@@ -117,6 +117,7 @@ private:
void renderSprites(const glm::mat4& viewProj);
void renderCanvasGizmo(const glm::mat4& viewProj);
void renderSelectionBox(const glm::mat4& viewProj);
+ void renderStats(ui::UIBatchRenderer& renderer);
void initGrid2DData();
void initCanvasGizmoData();
void renderAxisGizmo();
@@ -161,7 +162,8 @@ private:
u32 viewportHeight_ = 720;
bool framebufferNeedsResize_ = false;
- f64 lastFrameTime_ = 0.0;
+ f64 last_frame_time_ = 0.0;
+ f64 prev_frame_time_ = 0.0;
ViewMode viewMode_ = ViewMode::Mode3D;
Unique<VertexArray> axis2DVAO_;
@@ -176,6 +178,7 @@ private:
Unique<RenderPipeline> renderPipeline_;
bool gridVisible_ = true;
bool gizmosVisible_ = true;
+ bool stats_visible_ = false;
ui::Rect viewportBounds_;
CommandHistory* commandHistory_ = nullptr;
diff --git a/src/esengine/editor/widgets/SceneToolbar.cpp b/src/esengine/editor/widgets/SceneToolbar.cpp
index bda07e095..e58382d00 100644
--- a/src/esengine/editor/widgets/SceneToolbar.cpp
+++ b/src/esengine/editor/widgets/SceneToolbar.cpp
@@ -63,6 +63,13 @@ void SceneToolbar::setGizmoMode(GizmoMode mode) {
}
}
+void SceneToolbar::setStatsVisible(bool visible) {
+ if (stats_visible_ != visible) {
+ stats_visible_ = visible;
+ onStatsVisibilityChanged.publish(visible);
+ }
+}
+
// =============================================================================
// Rendering
// =============================================================================
@@ -110,6 +117,8 @@ void SceneToolbar::render(ui::UIBatchRenderer& renderer) {
drawButton(translateButtonBounds_, icons::Move, gizmoMode_ == GizmoMode::Translate, hoveredButton_ == 4);
drawButton(rotateButtonBounds_, icons::Rotate3d, gizmoMode_ == GizmoMode::Rotate, hoveredButton_ == 5);
drawButton(scaleButtonBounds_, icons::Scale3d, gizmoMode_ == GizmoMode::Scale, hoveredButton_ == 6);
+
+ drawButton(stats_button_bounds_, icons::Info, stats_visible_, hoveredButton_ == 7);
#endif
}
@@ -133,6 +142,7 @@ bool SceneToolbar::onMouseDown(const ui::MouseButtonEvent& event) {
case 4: setGizmoMode(GizmoMode::Translate); return true;
case 5: setGizmoMode(GizmoMode::Rotate); return true;
case 6: setGizmoMode(GizmoMode::Scale); return true;
+ case 7: setStatsVisible(!stats_visible_); return true;
}
return false;
@@ -173,6 +183,8 @@ void SceneToolbar::updateButtonBounds() {
rotateButtonBounds_ = {x, y, btnSize, btnSize};
x += btnSize + 2.0f;
scaleButtonBounds_ = {x, y, btnSize, btnSize};
+
+ stats_button_bounds_ = {bounds.x + bounds.width - btnSize - padding, y, btnSize, btnSize};
}
i32 SceneToolbar::getHoveredButton(f32 x, f32 y) const {
@@ -183,6 +195,7 @@ i32 SceneToolbar::getHoveredButton(f32 x, f32 y) const {
if (translateButtonBounds_.contains(x, y)) return 4;
if (rotateButtonBounds_.contains(x, y)) return 5;
if (scaleButtonBounds_.contains(x, y)) return 6;
+ if (stats_button_bounds_.contains(x, y)) return 7;
return -1;
}
diff --git a/src/esengine/editor/widgets/SceneToolbar.hpp b/src/esengine/editor/widgets/SceneToolbar.hpp
index 876bc30b7..9c64bf699 100644
--- a/src/esengine/editor/widgets/SceneToolbar.hpp
+++ b/src/esengine/editor/widgets/SceneToolbar.hpp
@@ -51,6 +51,9 @@ public:
GizmoMode getGizmoMode() const { return gizmoMode_; }
void setGizmoMode(GizmoMode mode);
+ bool isStatsVisible() const { return stats_visible_; }
+ void setStatsVisible(bool visible);
+
// =========================================================================
// Signals
// =========================================================================
@@ -59,6 +62,7 @@ public:
Signal<void(bool)> onGridVisibilityChanged;
Signal<void(bool)> onGizmosVisibilityChanged;
Signal<void(GizmoMode)> onGizmoModeChanged;
+ Signal<void(bool)> onStatsVisibilityChanged;
// =========================================================================
// Widget Interface
@@ -75,6 +79,7 @@ private:
ViewMode viewMode_ = ViewMode::Mode3D;
bool gridVisible_ = true;
bool gizmosVisible_ = true;
+ bool stats_visible_ = false;
GizmoMode gizmoMode_ = GizmoMode::Translate;
ui::Rect viewMode2DButtonBounds_;
@@ -84,6 +89,7 @@ private:
ui::Rect translateButtonBounds_;
ui::Rect rotateButtonBounds_;
ui::Rect scaleButtonBounds_;
+ ui::Rect stats_button_bounds_;
i32 hoveredButton_ = -1;
};
diff --git a/src/esengine/renderer/RenderPipeline.cpp b/src/esengine/renderer/RenderPipeline.cpp
index 9b9e0d801..a0958825a 100644
--- a/src/esengine/renderer/RenderPipeline.cpp
+++ b/src/esengine/renderer/RenderPipeline.cpp
@@ -24,6 +24,7 @@
#endif
#include <algorithm>
+#include <unordered_set>
namespace esengine {
@@ -60,7 +61,7 @@ RenderPipeline::RenderPipeline(RenderContext& context,
, resource_manager_(resource_manager)
, view_bounds_(0.0f) {
- batcher_ = makeUnique<BatchRenderer2D>(context_);
+ batcher_ = makeUnique<BatchRenderer2D>(context_, resource_manager_);
batcher_->init();
items_.reserve(1024);
@@ -110,15 +111,11 @@ void RenderPipeline::end() {
sortItems();
buildBatches();
-#ifdef ES_PLATFORM_WEB
if (batching_enabled_) {
executeBatches();
} else {
executeNonBatched();
}
-#else
- executeNonBatched();
-#endif
}
// =============================================================================
@@ -201,14 +198,20 @@ void RenderPipeline::buildBatches() {
return;
}
+ std::unordered_set<u32> uniqueTextures;
+ u32 textureSwitch = 0;
+
u32 currentTexture = items_[0].texture_id;
u32 batchStart = 0;
+ uniqueTextures.insert(currentTexture);
for (u32 i = 1; i < items_.size(); ++i) {
+ uniqueTextures.insert(items_[i].texture_id);
if (items_[i].texture_id != currentTexture) {
batches_.push_back({currentTexture, batchStart, i - batchStart});
currentTexture = items_[i].texture_id;
batchStart = i;
+ textureSwitch++;
}
}
@@ -216,10 +219,14 @@ void RenderPipeline::buildBatches() {
static_cast<u32>(items_.size()) - batchStart});
stats_.batch_count = static_cast<u32>(batches_.size());
+ stats_.unique_textures = static_cast<u32>(uniqueTextures.size());
+ stats_.texture_switches = textureSwitch;
+
+ stats_.triangles = stats_.visible_items * 2;
+ stats_.vertices = stats_.visible_items * 4;
}
void RenderPipeline::executeBatches() {
-#ifdef ES_PLATFORM_WEB
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -255,7 +262,6 @@ void RenderPipeline::executeBatches() {
batcher_->endBatch();
stats_.draw_calls = batcher_->getDrawCallCount();
-#endif
}
void RenderPipeline::executeNonBatched() {
diff --git a/src/esengine/renderer/RenderPipeline.hpp b/src/esengine/renderer/RenderPipeline.hpp
index cb5fb50e9..41188993d 100644
--- a/src/esengine/renderer/RenderPipeline.hpp
+++ b/src/esengine/renderer/RenderPipeline.hpp
@@ -104,11 +104,20 @@ public:
* @brief Pipeline statistics
*/
struct Stats {
- u32 total_items = 0; ///< Total items submitted
- u32 culled_items = 0; ///< Items culled by frustum
- u32 visible_items = 0; ///< Items actually rendered
- u32 batch_count = 0; ///< Number of batches
- u32 draw_calls = 0; ///< Number of draw calls
+ // Rendering
+ u32 draw_calls = 0; ///< Number of draw calls
+ u32 batch_count = 0; ///< Number of batches
+ u32 triangles = 0; ///< Total triangles rendered
+ u32 vertices = 0; ///< Total vertices rendered
+
+ // Objects
+ u32 total_items = 0; ///< Total items submitted
+ u32 visible_items = 0; ///< Items actually rendered
+ u32 culled_items = 0; ///< Items culled by frustum
+
+ // Textures
+ u32 unique_textures = 0; ///< Unique textures used
+ u32 texture_switches = 0; ///< Texture bind changes
};
// =========================================================================
diff --git a/src/esengine/renderer/Renderer.cpp b/src/esengine/renderer/Renderer.cpp
index 3707ee97b..1f79bfa0b 100644
--- a/src/esengine/renderer/Renderer.cpp
+++ b/src/esengine/renderer/Renderer.cpp
@@ -265,77 +265,31 @@ constexpr glm::vec2 QUAD_TEX_COORDS[4] = {
{ 0.0f, 1.0f }
};
-// Batch shader sources
-const char* BATCH_VERTEX_SHADER = R"(
- attribute vec3 a_position;
- attribute vec4 a_color;
- attribute vec2 a_texCoord;
- attribute float a_texIndex;
-
- uniform mat4 u_projection;
-
- varying vec4 v_color;
- varying vec2 v_texCoord;
- varying float v_texIndex;
-
- void main() {
- gl_Position = u_projection * vec4(a_position, 1.0);
- v_color = a_color;
- v_texCoord = a_texCoord;
- v_texIndex = a_texIndex;
- }
-)";
-
-const char* BATCH_FRAGMENT_SHADER = R"(
- precision mediump float;
-
- varying vec4 v_color;
- varying vec2 v_texCoord;
- varying float v_texIndex;
-
- uniform sampler2D u_textures[8];
-
- void main() {
- int index = int(v_texIndex);
- vec4 texColor = vec4(1.0);
-
- // WebGL 1.0 doesn't support dynamic array indexing
- if (index == 0) texColor = texture2D(u_textures[0], v_texCoord);
- else if (index == 1) texColor = texture2D(u_textures[1], v_texCoord);
- else if (index == 2) texColor = texture2D(u_textures[2], v_texCoord);
- else if (index == 3) texColor = texture2D(u_textures[3], v_texCoord);
- else if (index == 4) texColor = texture2D(u_textures[4], v_texCoord);
- else if (index == 5) texColor = texture2D(u_textures[5], v_texCoord);
- else if (index == 6) texColor = texture2D(u_textures[6], v_texCoord);
- else if (index == 7) texColor = texture2D(u_textures[7], v_texCoord);
-
- gl_FragColor = texColor * v_color;
- }
-)";
-
// BatchRenderer2D internal data
struct BatchRenderer2D::BatchData {
Unique<VertexArray> vao;
Shared<VertexBuffer> vbo;
- Unique<Shader> shader;
+ resource::ShaderHandle shader_handle;
std::vector<BatchVertex> vertices;
u32 indexCount = 0;
std::array<u32, MAX_TEXTURE_SLOTS> textureSlots;
- u32 textureSlotIndex = 1; // 0 = white texture
+ u32 textureSlotIndex = 1;
glm::mat4 projection{1.0f};
- // Statistics
u32 drawCallCount = 0;
u32 quadCount = 0;
bool initialized = false;
};
-BatchRenderer2D::BatchRenderer2D(RenderContext& context)
- : data_(makeUnique<BatchData>()), context_(context) {
+BatchRenderer2D::BatchRenderer2D(RenderContext& context,
+ resource::ResourceManager& resource_manager)
+ : data_(makeUnique<BatchData>())
+ , context_(context)
+ , resource_manager_(resource_manager) {
}
BatchRenderer2D::~BatchRenderer2D() {
@@ -347,11 +301,8 @@ BatchRenderer2D::~BatchRenderer2D() {
void BatchRenderer2D::init() {
data_->vertices.reserve(MAX_VERTICES);
-#ifdef ES_PLATFORM_WEB
- // Create VAO
data_->vao = VertexArray::create();
- // Create dynamic vertex buffer
data_->vbo = makeShared<VertexBuffer>();
*data_->vbo = std::move(*VertexBuffer::create(MAX_VERTICES * sizeof(BatchVertex)));
data_->vbo->setLayout({
@@ -363,7 +314,6 @@ void BatchRenderer2D::init() {
data_->vao->addVertexBuffer(data_->vbo);
- // Create index buffer (pre-computed pattern for quads)
std::vector<u32> indices(MAX_INDICES);
u32 offset = 0;
for (u32 i = 0; i < MAX_INDICES; i += 6) {
@@ -378,15 +328,12 @@ void BatchRenderer2D::init() {
auto ibo = IndexBuffer::create(indices.data(), MAX_INDICES);
data_->vao->setIndexBuffer(Shared<IndexBuffer>(std::move(ibo)));
- // Create batch shader
- data_->shader = Shader::create(BATCH_VERTEX_SHADER, BATCH_FRAGMENT_SHADER);
+ data_->shader_handle = resource_manager_.loadEngineShader("batch");
- // Initialize texture slots (slot 0 = white texture from context)
data_->textureSlots[0] = context_.getWhiteTextureId();
for (u32 i = 1; i < MAX_TEXTURE_SLOTS; ++i) {
data_->textureSlots[i] = 0;
}
-#endif
data_->initialized = true;
ES_LOG_INFO("BatchRenderer2D initialized (max {} quads per batch)", MAX_QUADS);
@@ -397,7 +344,6 @@ void BatchRenderer2D::shutdown() {
data_->vao.reset();
data_->vbo.reset();
- data_->shader.reset();
data_->initialized = false;
ES_LOG_INFO("BatchRenderer2D shutdown");
@@ -407,6 +353,8 @@ void BatchRenderer2D::beginBatch() {
data_->vertices.clear();
data_->indexCount = 0;
data_->textureSlotIndex = 1;
+ data_->drawCallCount = 0;
+ data_->quadCount = 0;
}
void BatchRenderer2D::endBatch() {
@@ -416,34 +364,30 @@ void BatchRenderer2D::endBatch() {
void BatchRenderer2D::flush() {
if (data_->vertices.empty()) return;
-#ifdef ES_PLATFORM_WEB
- // Upload vertex data
+ Shader* shader = resource_manager_.getShader(data_->shader_handle);
+ if (!shader) return;
+
data_->vbo->setDataRaw(
data_->vertices.data(),
static_cast<u32>(data_->vertices.size() * sizeof(BatchVertex))
);
- // Bind textures
for (u32 i = 0; i < data_->textureSlotIndex; ++i) {
glActiveTexture(GL_TEXTURE0 + i);
glBindTexture(GL_TEXTURE_2D, data_->textureSlots[i]);
}
- // Set uniforms and draw
- data_->shader->bind();
- data_->shader->setUniform("u_projection", data_->projection);
+ shader->bind();
+ shader->setUniform("u_projection", data_->projection);
- // Set texture uniform array
i32 samplers[MAX_TEXTURE_SLOTS] = { 0, 1, 2, 3, 4, 5, 6, 7 };
- glUniform1iv(glGetUniformLocation(data_->shader->getProgramId(), "u_textures"),
+ glUniform1iv(glGetUniformLocation(shader->getProgramId(), "u_textures"),
MAX_TEXTURE_SLOTS, samplers);
RenderCommand::drawIndexed(*data_->vao, data_->indexCount);
data_->drawCallCount++;
-#endif
- // Reset batch
data_->vertices.clear();
data_->indexCount = 0;
data_->textureSlotIndex = 1;
diff --git a/src/esengine/renderer/Renderer.hpp b/src/esengine/renderer/Renderer.hpp
index 3e8470e2d..db5e9f2ee 100644
--- a/src/esengine/renderer/Renderer.hpp
+++ b/src/esengine/renderer/Renderer.hpp
@@ -245,10 +245,11 @@ private:
class BatchRenderer2D {
public:
/**
- * @brief Constructs a batch renderer with the given context
- * @param context Reference to the rendering context
+ * @brief Constructs a batch renderer
+ * @param context Render context for shared resources
+ * @param resource_manager Resource manager for shader loading
*/
- explicit BatchRenderer2D(RenderContext& context);
+ BatchRenderer2D(RenderContext& context, resource::ResourceManager& resource_manager);
~BatchRenderer2D();
@@ -366,6 +367,7 @@ private:
struct BatchData;
Unique<BatchData> data_;
RenderContext& context_;
+ resource::ResourceManager& resource_manager_;
};
} // namespace esengine