Package limn.render3d

Class Graphics3D

java.lang.Object
limn.render3d.Graphics3D

public final class Graphics3D extends Object
Facade + install-at-startup SPI for the 3D backend, the same inversion pattern as Images/Sounds: a neutral entry point here, the GL implementation installed by the backend on startup. All calls must happen on the UI thread inside a frame (the owning window's GL context must be current), because they create/render GPU resources.

Nothing here has an asynchronous form, and nothing here can: the GL context is current on one thread inside one frame, so an upload moved to a worker would have no context to upload into. The work that can leave the frame is whatever produces the MeshData and TextureData (reading the file, decoding the image, building the vertices), and that is where an application should put a background job. By the time a call reaches this class, the remaining cost is the driver's.

For this milestone the provider also ships one built-in demo scene (a spinning, depth-tested cube) via renderDemoScene(limn.render3d.RenderTarget, double). Later phases add the real mesh/material/pass API on top of the same RenderTarget seam.

  • Method Details

    • install

      public static void install(Graphics3D.Provider newProvider)
      Installs the backend's 3D provider. Called once at startup, before any viewport renders.
    • uninstall

      public static void uninstall(Graphics3D.Provider expected)
      Removes the provider if it is still expected, so a late teardown cannot clear a newer one.
    • isAvailable

      public static boolean isAvailable()
      Whether a backend provider is installed (false when running headless).
    • createTarget

      public static RenderTarget createTarget(int widthPx, int heightPx, int samples)
      Creates a target with samples× MSAA (clamped to what the GPU supports).
    • upload

      public static GpuMesh upload(MeshData mesh)
      Uploads geometry to the GPU (call once; reuse the handle across frames).
    • upload

      public static GpuMesh upload(MeshData mesh, MeshUsage usage)
      Uploads geometry that will be rewritten through GpuMesh.update(limn.render3d.MeshData) (MeshUsage.DYNAMIC) or statically, as upload(MeshData).
    • uploadTexture

      public static GpuTexture uploadTexture(TextureData texture, Sampler sampler)
      Uploads a texture with the given sampler state (call once; reuse the handle).
    • render

      public static void render(RenderTarget target, Camera camera, Consumer<RenderPass> body)
      Renders into target with camera: binds the target (depth on), then invokes body with a RenderPass to clear and draw. Resolves MSAA and restores GL state afterwards. Must run inside a frame (context current).
    • renderDemoScene

      public static void renderDemoScene(RenderTarget target, double timeSeconds)
      Draws a built-in scene, so a backend can be verified without any application content.