Skip to content

C++ Mode v0.2.0

Choose a tag to compare

@pepc84 pepc84 released this 21 Jun 20:44

What's new

Guided install wizard for missing dependencies (Windows, macOS, Linux)

  • Detects exactly what's missing (g++, GLFW, GLEW) on each OS and shows a clear "Missing: ..." dialog before doing anything
  • Click Install and the wizard runs with live progress, so you're not left guessing whether it's actually doing something
  • Windows: downloads and installs MSYS2 if needed, then installs g++, GLFW, and GLEW through pacman
  • macOS: opens Xcode Command Line Tools if g++ is missing and waits for it to finish, then installs GLFW/GLEW through Homebrew if it's available
  • Linux: detects your package manager (apt, apt-get, pacman, dnf, yum, zypper, emerge, nix-env) and runs the install in a real terminal with sudo, since none of this can be safely auto-elevated
  • If your OS isn't recognized, it just tells you what's missing instead of guessing at how to install it
  • Cancel actually cancels now instead of falling through to the old install dialogs

Fixed: native macOS builds were broken

  • The build was linking with -lGL -lGLU, which don't exist on macOS, so every local macOS build failed at the link step no matter what was installed
  • Now links against -framework OpenGL (plus Cocoa, IOKit, and CoreVideo), and correctly finds Homebrew's GLFW/GLEW on both Apple Silicon (/opt/homebrew) and Intel (/usr/local)
  • Dropped -march=native on macOS since Apple's clang doesn't reliably support it
  • macOS builds now use their own object file cache instead of sharing Linux's

Engine fixes

  • Fixed a GLSL shader bug that broke lighting (lights(), directionalLight(), pointLight(), spotLight()) in every 3D sketch. A stray PApplet:: had ended up inside the actual shader source, which isn't valid in GLSL at all
  • Fixed rect()'s stroke so it's centered on the shape's edge like real Processing, instead of drawn entirely outside it. Also fixed messy corners at higher stroke weights
  • PGraphics buffers now have their own independent fill, stroke, and text style instead of sharing the main canvas's, so drawing into a buffer no longer picks up or messes with whatever style the main canvas had set
  • Added antialiasing to PGraphics buffers so they match the main canvas's visual quality, and added a level option to smooth()
  • Fixed a bug where calling beginDraw() twice without a matching endDraw() could corrupt the canvas
  • Fixed createGraphics() losing its settings when assigned into an existing PGraphics variable
  • Fixed ellipseMode() defaulting wrong inside PGraphics buffers, which shifted every default ellipse off center
  • Fixed endDraw() using the wrong coordinates when restoring the main canvas, which distorted things on HiDPI/Retina displays
  • Fixed a linker error in PGraphics::endDraw() caused by a reference to a variable that never actually existed
  • Fixed SIGHUP not being declared on Windows

New: real C++ versions of Java's collection types

  • String is now a real class instead of a plain rename to std::string, with the methods you'd expect: length(), charAt(), equals(), equalsIgnoreCase(), substring(), indexOf(), lastIndexOf(), toLowerCase(), toUpperCase(), trim(), contains(), startsWith(), endsWith(), replace(), concat(), compareTo()
  • ArrayList<T> is now a real generic class with Java's method names (add, get, set, remove, size, isEmpty, contains). It correctly stores objects by reference, the same way Java does, so calling a method on something you got from .get() actually changes what's stored in the list
  • IntList, FloatList, and StringList got a few more methods to better match Processing's actual API

Code generation fixes

  • Fixed several bugs where a comment containing code-shaped text (like // example: int x = 5;) could get mistaken for real code by the translator
  • Fixed global arrays losing their automatic zero-initialization, and fixed cases where a const/constexpr size and the array using it ended up in the wrong order
  • Fixed a C++ parsing quirk where writing MyClass obj(1, 2, 3); could get misread as a function declaration instead of creating an object
  • Fixed a multi-line comment at the top of a sketch sometimes swallowing the line right after it
  • Removed an old, unreliable rewrite that turned . into -> for pointer variables with no real understanding of scope. You'll need to write -> yourself for pointer variables now, the same way you would in any other C++ code

Other additions

  • Added a dev setup script (setup-dev-symlinks.sh) for working on CppMode's Java source alongside a processing4 checkout
  • Added a bug report link in the editor footer

Known limitations

  • Using ArrayList<YourClass> and similar collections inside a function body (rather than as a sketch-level variable) currently needs pointer-aware code written by hand (new, ->, Type*)

Requirements

Windows: MSYS2 with g++, GLFW, and GLEW. The wizard installs all of this for you
macOS: Xcode Command Line Tools (the wizard installs this) plus Homebrew with glfw/glew (the wizard installs this too if Homebrew is already there)
Linux: g++, libglfw3-dev, libglew-dev. The wizard detects your package manager and installs these for you