Mercurial > games > semicongine
annotate README.md @ 1367:0f3f2017b054
add: some reminders what we would like to do
author | sam <sam@basx.dev> |
---|---|
date | Sat, 23 Nov 2024 10:34:28 +0700 |
parents | 4f1c3994009d |
children |
rev | line source |
---|---|
922 | 1 Note: If you are reading this on Github, please not that this is only a mirror |
1266 | 2 repository and the newest code is hosted on my mercurial repository at |
3 https://hg.basx.dev/games/semicongine/. | |
922 | 4 |
289 | 5 # Semicongine |
41 | 6 |
926
f8974736e446
did: smile, just for the sake of testing mercurial hooks :)
sam <sam@basx.dev>
parents:
925
diff
changeset
|
7 Hi there |
8 | 8 |
213
b5d9410a8184
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
202
diff
changeset
|
9 This is a little game engine, mainly trying to wrap around vulkan and the |
b5d9410a8184
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
202
diff
changeset
|
10 operating system's windowing, input and audio system. I am using the last |
b5d9410a8184
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
202
diff
changeset
|
11 programming language you will ever need, [Nim](https://nim-lang.org/) |
41 | 12 |
1301 | 13 The (incomplete, autogenerated) API documentation is hosted at <https://semicongine.diademgames.com/>. |
14 | |
1266 | 15 ## Features |
16 | |
17 The engine currently features the following: | |
18 | |
19 - No dependencies outside of this repo (except zip/unzip on Linux). All | |
1275 | 20 dependencies are included (`libs` for library dependencies, `tools` for |
21 binaries/scripts, `semicongine/thirdparty` for code dependencies) | |
1266 | 22 - Low-level, Vulkan-base rendering system |
1275 | 23 - All vertex/uniform/descriptors/shader-formats can and must be defined |
24 "freely". The only restriction that we currently have, is that vertex data is | |
25 non-interleaved. | |
1266 | 26 - A ton of compiletime checks to ensure the defined mesh-data and shaders are |
27 compatible for rendering | |
28 - Simple audio mixer, should suffice for most things | |
29 - Simple input-system, no controller support at this time | |
1275 | 30 - Resource packaging of images, audio and 3D files as either folders, zip files or embedded in the executable |
1267 | 31 - Simple font and text rendering |
1266 | 32 - A few additional utils like a simple storage API, a few algorithms for |
33 collision detection, noise generation and texture packing, and a simple | |
34 settings API with hot-reloading | |
35 | |
1367
0f3f2017b054
add: some reminders what we would like to do
sam <sam@basx.dev>
parents:
1302
diff
changeset
|
36 ## Wishlist |
0f3f2017b054
add: some reminders what we would like to do
sam <sam@basx.dev>
parents:
1302
diff
changeset
|
37 |
0f3f2017b054
add: some reminders what we would like to do
sam <sam@basx.dev>
parents:
1302
diff
changeset
|
38 [ ] Macro-based internal DSL to convert Nim code into GLSL/slang at compile time |
0f3f2017b054
add: some reminders what we would like to do
sam <sam@basx.dev>
parents:
1302
diff
changeset
|
39 [ ] Better memory management |
0f3f2017b054
add: some reminders what we would like to do
sam <sam@basx.dev>
parents:
1302
diff
changeset
|
40 - Simple buffer resizing |
0f3f2017b054
add: some reminders what we would like to do
sam <sam@basx.dev>
parents:
1302
diff
changeset
|
41 - Mechanism to mark unused buffers |
0f3f2017b054
add: some reminders what we would like to do
sam <sam@basx.dev>
parents:
1302
diff
changeset
|
42 - Use mapped GPU buffers without copying (implement seq with pointers to GPU memory) |
0f3f2017b054
add: some reminders what we would like to do
sam <sam@basx.dev>
parents:
1302
diff
changeset
|
43 - Do not keep copy of content for un-mapped buffers around (only pass data on creating or update) |
0f3f2017b054
add: some reminders what we would like to do
sam <sam@basx.dev>
parents:
1302
diff
changeset
|
44 |
1266 | 45 ## Hello world example |
46 | |
47 Attention, this project is not optimized for "hello world"-scenarios, so you | |
1302 | 48 have to write quite a few lines to get something to display: |
1266 | 49 |
1269 | 50 ```nim |
1266 | 51 |
52 import semicongine | |
53 | |
54 # required | |
55 InitVulkan() | |
56 | |
57 # set up a simple render pass to render the displayed frame | |
58 var renderpass = CreateDirectPresentationRenderPass(depthBuffer = false, samples = VK_SAMPLE_COUNT_1_BIT) | |
59 | |
60 # the swapchain, needs to be attached to the main renderpass | |
61 SetupSwapchain(renderpass = renderpass) | |
62 | |
63 # render data is used for memory management on the GPU | |
64 var renderdata = InitRenderData() | |
65 | |
66 type | |
67 # define a push constant, to have something moving | |
68 PushConstant = object | |
69 scale: float32 | |
70 # This is how we define shaders: the interface needs to be "typed" | |
71 # but the shader code itself can freely be written in glsl | |
72 Shader = object | |
73 position {.VertexAttribute.}: Vec3f | |
74 color {.VertexAttribute.}: Vec3f | |
75 pushConstant {.PushConstantAttribute.}: PushConstant | |
76 fragmentColor {.Pass.}: Vec3f | |
77 outColor {.ShaderOutput.}: Vec4f | |
78 # code | |
79 vertexCode: string = """void main() { | |
80 fragmentColor = color; | |
81 gl_Position = vec4(position * pushConstant.scale, 1);}""" | |
82 fragmentCode: string = """void main() { | |
83 outColor = vec4(fragmentColor, 1);}""" | |
84 # And we also need to define our Mesh, which does describe the vertex layout | |
85 TriangleMesh = object | |
86 position: GPUArray[Vec3f, VertexBuffer] | |
87 color: GPUArray[Vec3f, VertexBuffer] | |
88 | |
89 # instantiate the mesh and fill with data | |
90 var mesh = TriangleMesh( | |
91 position: asGPUArray([NewVec3f(-0.5, -0.5), NewVec3f(0, 0.5), NewVec3f(0.5, -0.5)], VertexBuffer), | |
92 color: asGPUArray([NewVec3f(0, 0, 1), NewVec3f(0, 1, 0), NewVec3f(1, 0, 0)], VertexBuffer), | |
93 ) | |
94 | |
95 # this allocates GPU data, uploads the data to the GPU and flushes any thing that is host-cached | |
96 # this is a shortcut version, more fine-grained control is possible | |
97 AssignBuffers(renderdata, mesh) | |
98 renderdata.FlushAllMemory() | |
99 | |
100 # Now we need to instantiate the shader as a pipeline object that is attached to a renderpass | |
101 var pipeline = CreatePipeline[Shader](renderPass = vulkan.swapchain.renderPass) | |
102 | |
103 # the main render-loop will exit if we get a kill-signal from the OS | |
104 while UpdateInputs(): | |
105 | |
106 # starts the drawing for the next frame and provides us necesseary framebuffer and commandbuffer objects in this scope | |
107 WithNextFrame(framebuffer, commandbuffer): | |
108 | |
109 # start the main (and only) renderpass we have, needs to know the target framebuffer and a commandbuffer | |
110 WithRenderPass(vulkan.swapchain.renderPass, framebuffer, commandbuffer, vulkan.swapchain.width, vulkan.swapchain.height, NewVec4f(0, 0, 0, 0)): | |
111 | |
112 # now activate our shader-pipeline | |
113 WithPipeline(commandbuffer, pipeline): | |
114 | |
115 # and finally, draw the mesh and set a single parameter | |
116 # more complicated setups with descriptors/uniforms are of course possible | |
117 RenderWithPushConstant(commandbuffer = commandbuffer, pipeline = pipeline, mesh = mesh, pushConstant = PushConstant(scale: 0.3)) | |
118 | |
119 # cleanup | |
120 checkVkResult vkDeviceWaitIdle(vulkan.device) | |
121 DestroyPipeline(pipeline) | |
122 DestroyRenderData(renderdata) | |
123 vkDestroyRenderPass(vulkan.device, renderpass.vk, nil) | |
124 DestroyVulkan() | |
125 | |
126 ``` | |
127 | |
1275 | 128 ## Future development |
41 | 129 |
1266 | 130 For now all features that I need are implemented. I will gradually add more |
131 stuff that I need, based on the games that I am developing. Here are a few | |
132 things that I consider integrating at a later point, once I have gather some | |
133 more experience what can/should be used across different projects: | |
194
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
187
diff
changeset
|
134 |
1269 | 135 - [ ] More support for glTF format (JPEG textures, animations, morphing) |
1275 | 136 - [ ] Some often used utils like camera-controllers, offscreen-rendering, shadow-map rendering, etc. |
137 - [ ] Some UI-stuff | |
1269 | 138 - [ ] Controller support |