-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
Luke edited this page Jun 16, 2023
·
1 revision
If you have a solution or project that includes TwinspireCS as a reference, we can start building an application with Twinspire.
Depending on how you format your .NET 6 project, you will need to either add using TwinspireCS; in your top-level statements or add at the top of Program.cs, as well as using Raylib_cs;.
In Program.cs, assuming you are using the default class for your main entry point, we need to create an application.
Let's use the following code as an example:
static void Main(string[] args)
{
var app = Application.CreateApp("Simple Test", 1600, 900);
app.TargetFPS = 60;
app.InitAll();
while (app.IsOpen())
{
Raylib.BeginDrawing();
Raylib.ClearBackground(Color.RAYWHITE);
Raylib.EndDrawing();
}
app.Close();
}- We create an application using
Application.CreateApp, specifying the title for the window and its size in width and height. - We must set
TargetFPSbefore initialisation the window, just like you would in Raylib. If you have never used Raylib before,TargetFPSis used to determine how fast the application should render, assuming hardware resources allow. - Next, we
InitAll(). Using this method initialises all Raylib parameters and any Twinspire-specific initialisation, including UI components and a basic theme. - This is our initialisation, so we can now start our render loop. We use
IsOpen()to determine if our app still runs. - Then we switch over to Raylib to perform some basic drawing. Typically, we would use our scene management facilities but as this is purely for testing purposes, we just need to see that the code runs.
- We use
BeginDrawingandEndDrawingto tell Raylib when to start and end drawing. We also addClearBackground(Color.RAYWHITE)so we get a slightly faint grey colour when the application is launched. - Finally, we
Close()the application outside the loop. This is required in order to ensure any resources are unloaded correctly. Since Twinspire has its own resource management, and assuming you are managing your resources purely in Twinspire, this method will free all resources for you. It will also close any Raylib-specific functions.
Build and debug your application to get up a simple window.