Getting started

This guide will show you how to get started with the Apos.Shapes library.

Before you start, make sure that you have a valid MonoGame project. You can create a new project by following this other guide.

You can run this example directly in your browser here.

Install

Install using the following dotnet command:

dotnet add package Apos.Shapes

You can find other ways to install it on the NuGet page.

Linux / OSX warning

This library includes a shader that gets compiled along your other content. If you are building your project on Linux or OSX, make sure that you have set up Wine correctly or you will get a build error. MonoGame has guides on setting up Wine for both. Make sure to read them:

Setup

Import the library with:

using Apos.Shapes;

In your game’s constructor, set the GraphicsProfile to HiDef. (If you’re using this library with KNI, set it to FL10_0 instead.) This enables the features that the shader will use. By default, MonoGame uses the Reach profile.

public Game1() {
    _graphics = new GraphicsDeviceManager(this);

    _graphics.GraphicsProfile = GraphicsProfile.HiDef;
}

In your game’s LoadContent(), create a ShapeBatch instance:

protected override void LoadContent() {
    _sb = new ShapeBatch(GraphicsDevice, Content);
}

ShapeBatch _sb;

In your game’s draw loop, call Begin and End and do your drawing between those two calls:

protected override void Draw(GameTime gameTime) {
    GraphicsDevice.Clear(Color.Black);

    _sb.Begin();

    _sb.FillCircle(new Vector2(200, 100), 50, Color.White);

    _sb.End();

    base.Draw(gameTime);
}

Everything that is drawn within the Begin and End calls will be batched together.

Edit this page on GitHub