Example #1
0
 /**
  * Constructor.
  *
  * @param gl the OpenGL interface
  * @param glResourceManager the resource manager
  * @param rect the position and size of the rectangle
  * @param color the colour of the rectangle
  */
 public FlatRenderer(
     @Nonnull GL2 gl,
     @Nonnull GlResourceManager glResourceManager,
     @Nonnull Rect rect,
     @Nonnull Color color) {
   program = glResourceManager.getShaderManager().getProgram(FlatProgram.class);
   vertexArrayObject = new VertexArrayObject(gl);
   this.color = color;
   float[] positions = createPositions(rect);
   positionsBuffer = vertexArrayObject.addBuffer(gl, FlatProgram.POSITION_LOCATION, positions, 2);
 }
Example #2
0
 /**
  * Set the position and size of the rectangle.
  *
  * @param gl the OpenGL interface
  * @param rect the rectangle
  */
 public void setRect(@Nonnull GL2 gl, @Nonnull Rect rect) {
   float[] positions = createPositions(rect);
   vertexArrayObject.updateBuffer(gl, positionsBuffer, positions);
 }
Example #3
0
 /**
  * Draw the rectangle.
  *
  * @param gl the OpenGL interface
  * @param pmvMatrix the PMV matrix
  */
 public void draw(@Nonnull GL2 gl, @Nonnull PmvMatrix pmvMatrix) {
   program.use(gl);
   program.setPmvMatrix(gl, pmvMatrix);
   program.setColor(gl, color);
   vertexArrayObject.draw(gl, GL2.GL_TRIANGLE_FAN, NUMBER_OF_VERTICES);
 }
Example #4
0
 /**
  * Remove the renderers VAO.
  *
  * @param gl the OpenGL interface
  */
 public void remove(@Nonnull GL2 gl) {
   vertexArrayObject.remove(gl);
 }