# Class GlslShaderGenerator

java.lang.Object
com.codename1.gpu.GlslShaderGenerator

public final class GlslShaderGenerator extends Object

Generates portable GLSL ES 1.00 vertex and fragment shader source for a given `Material` and `VertexFormat`. This is the "engine-managed shader" code path shared by every OpenGL ES class backend (Android OpenGL ES and the browser's WebGL, which share the same shading language). Applications never call this directly; it exists so the platform backends do not each reimplement shader emission. The iOS backend has an equivalent Metal generator.

The generated programs use a fixed naming contract that backends rely on when binding attributes and uniforms:

- attributes: `a_position` (vec3), `a_normal` (vec3), `a_texcoord` (vec2)
- uniforms: `u_mvp`, `u_model`, `u_normalMatrix` (mat4); `u_color` (vec4); `u_texture` (sampler2D); `u_lightDir`, `u_lightColor`, `u_ambient`, `u_eye` (vec3); `u_shininess` (float)

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `A_NORMAL`
  The attribute name bound to vertex normals.
  `static final String`
  `A_POSITION`
  The attribute name bound to vertex positions.
  `static final String`
  `A_TEXCOORD`
  The attribute name bound to vertex texture coordinates.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GlslShaderGenerator(Material material, VertexFormat format)`
  Generates the shader pair for a material and vertex layout.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getFragmentSource()`
  Returns the generated fragment shader source.
  `String`
  `getVertexSource()`
  Returns the generated vertex shader source.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### A_POSITION

    public static final String A_POSITION
    The attribute name bound to vertex positions.
    See Also:
      - Constant Field Values

  - ### A_NORMAL

    public static final String A_NORMAL
    The attribute name bound to vertex normals.
    See Also:
      - Constant Field Values

  - ### A_TEXCOORD

    public static final String A_TEXCOORD
    The attribute name bound to vertex texture coordinates.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### GlslShaderGenerator

    public GlslShaderGenerator(Material material, VertexFormat format)

    Generates the shader pair for a material and vertex layout.

    ###### Parameters

    - `material`: the material describing the lighting model and inputs

    - `format`: the mesh vertex layout

- ## Method Details

  - ### getVertexSource

    public String getVertexSource()
    Returns the generated vertex shader source.

  - ### getFragmentSource

    public String getFragmentSource()
    Returns the generated fragment shader source.