GL LAB · BROWSER PROGRAMMING WORKSPACE
C, C++ and OpenGL in your browser
GL Lab is an online C/C++ compiler and graphics workspace. Write a program, compile it on your device and see console messages or supported OpenGL graphics beside your code.
Open the compiler- Real C and C++ compilation
C11 and C++17 with Emscripten, running locally in your browser. - Graphics beside your code
Supported legacy OpenGL, GLUT and GLFW programs render through WebGL. - A workspace you can arrange
Resize or hide output and console panels, or use Focus code to expand the editor. - Your source stays on your device
Drafts save in this browser. Download source to keep a separate copy.
Run your first C++ program
- Open GL Lab and select C++17. Type your code or choose File → Open to import a source file.
- Press Run program, or Ctrl/⌘ + Enter. First use downloads about 25 MB of compiler tools, plus any needed graphics libraries.
- Read standard output and compiler messages in Console. Graphics appear in Output when your program draws them.
#include <iostream>
int main() {
std::cout << "Hello from GL Lab!" << std::endl;
return 0;
}
Use OpenGL, GLUT and GLFW
GL Lab uses GL4ES to translate supported legacy OpenGL calls to WebGL. The compiler selects the graphics compatibility libraries from your includes. This helps you try single-file graphics exercises without installing a desktop compiler.
Use browser-friendly callbacks for animation. Full desktop OpenGL, multiple native windows and arbitrary installed packages are outside the supported environment. Read the compatibility and limitations guide before adapting a larger program.
Input, output and editor space
For scanf or cin, open Input inside Console and enter values before Run. Input is supplied once per run; it is not an interactive terminal.
Use the Output and Console buttons to show or hide each pane. Drag the dividers to resize them, select Focus code for more editing space, or Reset layout to restore the default. On phones, switch between Editor, Output and Console using the tabs.
Does it work on a phone?
You can use GL Lab in a compatible phone browser with JavaScript, WebAssembly and WebGL. Compilation uses the device's memory and processing power, so larger programs may exceed mobile browser limits.
How do I save my work?
Use Download to save the C or C++ source file. Browser drafts belong to this browser and domain and can disappear if browser data is cleared. The compiler does not upload your source to a compilation server.
Keep a downloaded copy of important code before switching devices or clearing browser data.