Getting Started

Create your first sketch with C++ Mode, from opening Processing to seeing something on screen.

Don't have Processing yet?

C++ Mode runs inside the Processing IDE. Install Processing itself first, then come back here.

What's Processing?

1. Install C++ Mode

Open Processing, click the mode dropdown in the top-right of the editor, choose Add Mode..., then search for C++ Mode in the Contribution Manager and click Install.

Full walkthrough with screenshots: see Looking for the C++ Mode? on the Downloads page.

2. Open a new sketch

1

Restart Processing, open the mode dropdown again, and select C++.

Mode dropdown with C++ selected
assets/screenshot7.png Mode dropdown with C++ selected
2

You'll see a blank editor, just like Java mode. This is where you'll write your sketch.

Blank C++ Mode editor
assets/screenshot8.png Blank C++ Mode editor

3. Write your first sketch

Every sketch has two functions: setup() runs once when the sketch starts, and draw() runs over and over, once per frame. Type this into the editor:

void setup() {
  size(640, 360);
}

void draw() {
  background(20);
  ellipse(mouseX, mouseY, 40, 40);
}

size() sets the window dimensions. background() clears the frame to a color each time it's drawn. ellipse() draws a circle that follows wherever the mouse is, using the built-in mouseX and mouseY variables.

4. Run it

1

Click the Run button (the play icon) in the top-left of the editor, or press Ctrl+R (Cmd+R on Mac).

Run button in the toolbar
assets/screenshot9.png Run button in the toolbar
2

A window opens with a dark gray background. Move your mouse over it and a circle follows the cursor.

The sketch running, circle following the cursor
assets/screenshot10.png The sketch running, circle following the cursor

That's a complete sketch. Under the hood it's compiling to real C++ and running natively, but everything about writing it looks and feels like any other Processing mode.