@@ -123,6 +123,85 @@ find_package(vrhi REQUIRED)
123123target_link_libraries(your_app vrhi::vrhi)
124124```
125125
126+ ## Quick Start
127+
128+ ### Initialisation
129+
130+ ``` cpp
131+ #include < vrhi.h>
132+
133+ g_vhInit.appName = " MyApp" ;
134+ g_vhInit.resolution = glm::ivec2( 1280 , 720 );
135+ g_vhInit.headless = true ; // No window, compute-only
136+ vhInit ();
137+ ```
138+
139+ ### Draw a Triangle
140+
141+ ``` cpp
142+ // Create resources
143+ vhTexture rt = vhAllocTexture();
144+ vhCreateTexture2D ( rt, glm::ivec2( 64, 64 ), 1, nvrhi::Format::RGBA8_UNORM, VRHI_TEXTURE_RT );
145+
146+ vhBuffer vb = vhAllocBuffer();
147+ vhMem* vertData = vhAllocMem( sizeof( verts ) );
148+ memcpy( vertData->data(), verts, sizeof( verts ) );
149+ vhCreateVertexBuffer( vb, "VB", vertData, "float3 float4" ); // pos + colour
150+
151+ vhShader vs = vhAllocShader(), ps = vhAllocShader();
152+ // ... compile shaders with vhCompileShader, then vhCreateShader
153+
154+ // Set state and draw
155+ vhState state;
156+ state.SetColourAttachment( 0, rt )
157+ .SetViewRect( glm::vec4( 0, 0, 64, 64 ) )
158+ .SetViewClear( VRHI_CLEAR_COLOR, glm::vec4( 0, 0, 0, 1 ) )
159+ .SetStateFlags( VRHI_STATE_WRITE_MASK )
160+ .SetVertexBuffer( vb, 0 )
161+ .SetProgram( vhCreateGfxProgram( vs, ps ) );
162+
163+ vhStateId sid = 1;
164+ vhSetState( sid, state );
165+ vhClear( sid, VRHI_CLEAR_COLOR );
166+ vhDraw( sid, 3 );
167+ vhFinish();
168+
169+ // Reusing state for another draw? Call DirtyAll():
170+ state.SetVertexBuffer( otherVB, 0 );
171+ vhSetState( sid, state.DirtyAll() );
172+ vhDraw( sid, 3 );
173+ ```
174+
175+ ### Compute Dispatch
176+
177+ ```cpp
178+ vhShader cs = vhAllocShader();
179+ // ... compile with VRHI_SHADER_STAGE_COMPUTE
180+
181+ vhBuffer output = vhAllocBuffer();
182+ vhCreateStorageBuffer( output, "Out", nullptr, 1024, VRHI_BUFFER_COMPUTE_READ_WRITE );
183+
184+ vhState state;
185+ state.SetProgram( vhCreateComputeProgram( cs ) )
186+ .SetBuffer( 0, { .slot = 0, .buffer = output, .computeUAV = true } );
187+
188+ vhStateId sid = 100;
189+ vhSetState( sid, state );
190+ vhDispatch( sid, glm::uvec3( 16, 1, 1 ) );
191+ vhFinish();
192+ ```
193+
194+ ### Cleanup
195+
196+ ``` cpp
197+ vhDestroyBuffer ( vb );
198+ vhDestroyTexture( rt );
199+ vhDestroyShader( vs );
200+ vhDestroyShader( ps );
201+ vhFlush();
202+ vhShutdown();
203+ ```
204+
126205## FAQ
127206
128207### Is Vrhi written by AI?
0 commit comments