java.lang.Object
nl.colorize.multimedialib.renderer.webgl.WebGL
All Implemented Interfaces:
TeaGraphics, StageVisitor

public class WebGL extends Object implements TeaGraphics
Graphics using WebGL. This class is limited to WebGL 1, since that is supported by all modern browsers. For operations that are not supported natively by WebGL, most importantly text rendering, a <canvas> overlay is used. This does mean that the overlay's contents are always drawn "on top" of the WebGL graphics, but specifically for text rendering this is usually not an issue.
  • Constructor Details

  • Method Details

    • getGraphicsMode

      public GraphicsMode getGraphicsMode()
      Specified by:
      getGraphicsMode in interface TeaGraphics
    • getDisplayWidth

      public int getDisplayWidth()
      Specified by:
      getDisplayWidth in interface TeaGraphics
    • getDisplayHeight

      public int getDisplayHeight()
      Specified by:
      getDisplayHeight in interface TeaGraphics
    • init

      public void init(TeaMediaLoader mediaLoader)
      Specified by:
      init in interface TeaGraphics
    • prepareStage

      public void prepareStage(Stage stage)
      Description copied from interface: StageVisitor
      Prepares visiting the stage. This method is called before any of the stage's graphics are visited. It can be used to add initialization logic that should be performed before any graphics can be drawn.
      Specified by:
      prepareStage in interface StageVisitor
    • shouldVisitAllGraphics

      public boolean shouldVisitAllGraphics()
      Description copied from interface: StageVisitor
      Indicates whether this visitor should visit all graphics, or only graphics that are currently visible.
      Specified by:
      shouldVisitAllGraphics in interface StageVisitor
    • visitContainer

      public void visitContainer(Container container)
      Description copied from interface: StageVisitor
      Visits a container. This method does not actually need to draw the container's graphics, since the corresponding drawX methods will be called for all the container's children. This method will be called before the container's children are visited. It can be used to handle logic related to the container itself, for example to process children that were added or removed since the last frame update.
      Specified by:
      visitContainer in interface StageVisitor
    • drawBackground

      public void drawBackground(ColorRGB color)
      Specified by:
      drawBackground in interface StageVisitor
    • drawSprite

      public void drawSprite(Sprite sprite)
      Specified by:
      drawSprite in interface StageVisitor
    • drawLine

      public void drawLine(Primitive graphic, Line line)
      Specified by:
      drawLine in interface StageVisitor
    • drawSegmentedLine

      public void drawSegmentedLine(Primitive graphic, SegmentedLine line)
      Specified by:
      drawSegmentedLine in interface StageVisitor
    • drawRect

      public void drawRect(Primitive graphic, Rect rect)
      Specified by:
      drawRect in interface StageVisitor
    • drawCircle

      public void drawCircle(Primitive graphic, Circle circle)
      Specified by:
      drawCircle in interface StageVisitor
    • drawPolygon

      public void drawPolygon(Primitive graphic, Polygon polygon)
      Specified by:
      drawPolygon in interface StageVisitor
    • drawText

      public void drawText(Text text)
      Specified by:
      drawText in interface StageVisitor
    • toGLX

      protected float toGLX(float canvasX)
    • toGLY

      protected float toGLY(float canvasY)