.. _GraphicsAPIs: Graphics APIs ============= You should be aware that there are many `graphics APIs `_. For someone working in CAS, you need to know there are different levels: * Low Level: OpenGL, WebGL, Vulkan, Metal * High Level: VTK, Java3D * Games Engines: Unity, Unreal Low Level - OpenGL ------------------ The low level ones, let you explicitly control the graphics card. You have complete control over every single triangle drawn, or ray cast, but at the cost of massively increased complexity. Look at `this `_ code to draw one triangle!!! High Level - VTK ---------------- High level APIs encapsulate the low level detail, and provide a more easily accessible interface. In addition, they are often wrapped in a much nicer scripting language (e.g. Python for VTK). In CAS, lots of research systems use VTK, and so do we in these notes. VTK Examples ------------ Recently, `Kitware `_ have provided VTK.js, a Javascript re-write of VTK. Here we show some `VTK.js examples `_, as they can be demonstrated in the browser!! (Thank you Kitware!) The code is fairly similar to the `VTK Python or C++ Examples `_, and the same principles apply throughout. So, here we can play or experiment with a high-level API (VTK), provided in the web browser via javascript, and ignore the fact that at the lowest level, VTK.js is using WebGL to render using the graphics card GPU. Cone Example ------------ This VTK.js example gives you the opportunity to interact and experiment with some common rendering settings, just to see the immediate effects on a drawing of a simple cone. It demonstrates: * Fast rendering, browser uses WebGL, and hence hardware acceleration. * In surface rendering, everything is typically composed of triangles, points or lines. More complex shapes are made up of lots of triangles. * OpenGL will render arbitrary polygons, but all polygons can be converted to triangles, and hence the hardware is optimised for triangles, so most people convert all polygons to only triangles. .. raw:: html