Gjsify LogoGjsify Logo

Hierarchy

  • Material

Index

Constructors

Properties

name: string

Methods

  • Retrieves the current ambient color for material

    Parameters

    • ambient: Cogl.Color

      The location to store the ambient color

    Returns void

  • Retrieves the current diffuse color for material

    Parameters

    • diffuse: Cogl.Color

      The location to store the diffuse color

    Returns void

  • Retrieves the materials current emission color.

    Parameters

    • emission: Cogl.Color

      The location to store the emission color

    Returns void

  • getLayerPointSpriteCoordsEnabled(layerIndex: number): number
  • Gets whether point sprite coordinate generation is enabled for this texture layer.

    Parameters

    • layerIndex: number

      the layer number to check.

    Returns number

  • Returns the wrap mode for the 'p' coordinate of texture lookups on this layer.

    Parameters

    • layerIndex: number

      the layer number to change.

    Returns Cogl.MaterialWrapMode

  • Returns the wrap mode for the 's' coordinate of texture lookups on this layer.

    Parameters

    • layerIndex: number

      the layer number to change.

    Returns Cogl.MaterialWrapMode

  • Returns the wrap mode for the 't' coordinate of texture lookups on this layer.

    Parameters

    • layerIndex: number

      the layer number to change.

    Returns Cogl.MaterialWrapMode

  • This function lets you access a material's internal list of layers for iteration.

    You should avoid using this API if possible since it was only made public by mistake and will be deprecated when we have suitable alternative.

    It's important to understand that the list returned may not remain valid if you modify the material or any of the layers in any way and so you would have to re-get the list in that situation.

    Returns MaterialLayer[]

  • getNLayers(): number
  • Retrieves the number of layers defined for the given material

    Returns number

  • getPointSize(): number
  • Get the size of points drawn when %COGL_VERTICES_MODE_POINTS is used with the vertex buffer API.

    Returns number

  • getShininess(): number
  • Retrieves the materials current emission color.

    Returns number

  • Retrieves the materials current specular color.

    Parameters

    • specular: Cogl.Color

      The location to store the specular color

    Returns void

  • getUserProgram(): object
  • Queries what user program has been associated with the given material using cogl_material_set_user_program().

    Returns object

  • removeLayer(layerIndex: number): void
  • This function removes a layer from your material

    Parameters

    • layerIndex: number

      Specifies the layer you want to remove

    Returns void

  • Before a primitive is blended with the framebuffer, it goes through an alpha test stage which lets you discard fragments based on the current alpha value. This function lets you change the function used to evaluate the alpha channel, and thus determine which fragments are discarded and which continue on to the blending stage.

    The default is %COGL_MATERIAL_ALPHA_FUNC_ALWAYS

    Parameters

    • alphaFunc: Cogl.MaterialAlphaFunc

      A CoglMaterialAlphaFunc constant

    • alphaReference: number

      A reference point that the chosen alpha function uses to compare incoming fragments to.

    Returns void

  • Sets the material's ambient color, in the standard OpenGL lighting model. The ambient color affects the overall color of the object.

    Since the diffuse color will be intense when the light hits the surface directly, the ambient will be most apparent where the light hits at a slant.

    The default value is (0.2, 0.2, 0.2, 1.0)

    Parameters

    • ambient: Cogl.Color

      The components of the desired ambient color

    Returns void

  • setAmbientAndDiffuse(color: Cogl.Color): void
  • Conveniently sets the diffuse and ambient color of material at the same time. See cogl_material_set_ambient() and cogl_material_set_diffuse().

    The default ambient color is (0.2, 0.2, 0.2, 1.0)

    The default diffuse color is (0.8, 0.8, 0.8, 1.0)

    Parameters

    • color: Cogl.Color

      The components of the desired ambient and diffuse colors

    Returns void

  • setBlend(blendString: string): number
  • If not already familiar; please refer here for an overview of what blend strings are, and their syntax.

    Blending occurs after the alpha test function, and combines fragments with the framebuffer.

    Currently the only blend function Cogl exposes is ADD(). So any valid blend statements will be of the form:

    |[ <channel-mask>=ADD(SRC_COLOR*(<factor>), DST_COLOR*(<factor>))



    <warning>The brackets around blend factors are currently not
    optional!</warning>

    This is the list of source-names usable as blend factors:
    <itemizedlist>
    <listitem><para>SRC_COLOR: The color of the in comming fragment</para></listitem>
    <listitem><para>DST_COLOR: The color of the framebuffer</para></listitem>
    <listitem><para>CONSTANT: The constant set via cogl_material_set_blend_constant()</para></listitem>
    </itemizedlist>

    The source names can be used according to the
    <link linkend="cogl-Blend-String-syntax">color-source and factor syntax</link>,
    so for example "(1-SRC_COLOR[A])" would be a valid factor, as would
    "(CONSTANT[RGB])"

    These can also be used as factors:
    <itemizedlist>
    <listitem>0: (0, 0, 0, 0)</listitem>
    <listitem>1: (1, 1, 1, 1)</listitem>
    <listitem>SRC_ALPHA_SATURATE_FACTOR: (f,f,f,1) where f = MIN(SRC_COLOR[A],1-DST_COLOR[A])</listitem>
    </itemizedlist>

    <note>Remember; all color components are normalized to the range [0, 1]
    before computing the result of blending.</note>

    <example id="cogl-Blend-Strings-blend-unpremul">
    <title>Blend Strings/1</title>
    <para>Blend a non-premultiplied source over a destination with
    premultiplied alpha:</para>
    <programlisting>
    "RGB = ADD(SRC_COLOR*(SRC_COLOR[A]), DST_COLOR*(1-SRC_COLOR[A]))"
    "A = ADD(SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A]))"
    </programlisting>
    </example>

    <example id="cogl-Blend-Strings-blend-premul">
    <title>Blend Strings/2</title>
    <para>Blend a premultiplied source over a destination with
    premultiplied alpha</para>
    <programlisting>
    "RGBA = ADD(SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A]))"
    </programlisting>
    </example>

    The default blend string is:
    |[
    RGBA = ADD (SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A]))

    That gives normal alpha-blending when the calculated color for the material is in premultiplied form.

    Parameters

    • blendString: string

      A Cogl blend string describing the desired blend function.

    Returns number

  • setBlendConstant(constantColor: Cogl.Color): void
  • When blending is setup to reference a CONSTANT blend factor then blending will depend on the constant set with this function.

    Parameters

    • constantColor: Cogl.Color

      The constant color you want

    Returns void

  • Sets the basic color of the material, used when no lighting is enabled.

    Note that if you don't add any layers to the material then the color will be blended unmodified with the destination; the default blend expects premultiplied colors: for example, use (0.5, 0.0, 0.0, 0.5) for semi-transparent red. See cogl_color_premultiply().

    The default value is (1.0, 1.0, 1.0, 1.0)

    Parameters

    • color: Cogl.Color

      The components of the color

    Returns void

  • setColor4f(red: number, green: number, blue: number, alpha: number): void
  • Sets the basic color of the material, used when no lighting is enabled.

    The default value is (1.0, 1.0, 1.0, 1.0)

    Parameters

    • red: number

      The red component

    • green: number

      The green component

    • blue: number

      The blue component

    • alpha: number

      The alpha component

    Returns void

  • setColor4ub(red: number, green: number, blue: number, alpha: number): void
  • Sets the basic color of the material, used when no lighting is enabled.

    The default value is (0xff, 0xff, 0xff, 0xff)

    Parameters

    • red: number

      The red component

    • green: number

      The green component

    • blue: number

      The blue component

    • alpha: number

      The alpha component

    Returns void

  • Sets the material's diffuse color, in the standard OpenGL lighting model. The diffuse color is most intense where the light hits the surface directly - perpendicular to the surface.

    The default value is (0.8, 0.8, 0.8, 1.0)

    Parameters

    • diffuse: Cogl.Color

      The components of the desired diffuse color

    Returns void

  • Sets the material's emissive color, in the standard OpenGL lighting model. It will look like the surface is a light source emitting this color.

    The default value is (0.0, 0.0, 0.0, 1.0)

    Parameters

    • emission: Cogl.Color

      The components of the desired emissive color

    Returns void

  • setLayer(layerIndex: number, texture: object): void
  • In addition to the standard OpenGL lighting model a Cogl material may have one or more layers comprised of textures that can be blended together in order, with a number of different texture combine modes. This function defines a new texture layer.

    The index values of multiple layers do not have to be consecutive; it is only their relative order that is important.

    In the future, we may define other types of material layers, such as purely GLSL based layers.

    Parameters

    • layerIndex: number

      the index of the layer

    • texture: object

      a #CoglHandle for the layer object

    Returns void

  • setLayerCombine(layerIndex: number, blendString: string): number
  • If not already familiar; you can refer

    here for an overview of what blend strings are and there syntax.

    These are all the functions available for texture combining: REPLACE(arg0) = arg0 MODULATE(arg0, arg1) = arg0 x arg1 ADD(arg0, arg1) = arg0 + arg1 ADD_SIGNED(arg0, arg1) = arg0 + arg1 - 0.5 INTERPOLATE(arg0, arg1, arg2) = arg0 x arg2 + arg1 x (1 - arg2) SUBTRACT(arg0, arg1) = arg0 - arg1 DOT3_RGB(arg0, arg1) = 4 x ((arg0[R] - 0.5)) * (arg1[R] - 0.5) + (arg0[G] - 0.5)) * (arg1[G] - 0.5) + (arg0[B] - 0.5)) * (arg1[B] - 0.5)) DOT3_RGBA(arg0, arg1) = 4 x ((arg0[R] - 0.5)) * (arg1[R] - 0.5) + (arg0[G] - 0.5)) * (arg1[G] - 0.5) + (arg0[B] - 0.5)) * (arg1[B] - 0.5))

    Refer to the

    color-source syntax for describing the arguments. The valid source names for texture combining are: TEXTURE Use the color from the current texture layer TEXTURE_0, TEXTURE_1, etc Use the color from the specified texture layer CONSTANT Use the color from the constant given with cogl_material_set_layer_constant() PRIMARY Use the color of the material as set with cogl_material_set_color() PREVIOUS Either use the texture color from the previous layer, or if this is layer 0, use the color of the material as set with cogl_material_set_color() Layer Combine Examples This is effectively what the default blending is: RGBA = MODULATE (PREVIOUS, TEXTURE) This could be used to cross-fade between two images, using the alpha component of a constant as the interpolator. The constant color is given by calling cogl_material_set_layer_constant. RGBA = INTERPOLATE (PREVIOUS, TEXTURE, CONSTANT[A])

    You can't give a multiplication factor for arguments as you can with blending.

    Parameters

    • layerIndex: number

      Specifies the layer you want define a combine function for

    • blendString: string

      A Cogl blend string describing the desired texture combine function.

    Returns number

  • setLayerCombineConstant(layerIndex: number, constant: Cogl.Color): void
  • When you are using the 'CONSTANT' color source in a layer combine description then you can use this function to define its value.

    Parameters

    • layerIndex: number

      Specifies the layer you want to specify a constant used for texture combining

    • constant: Cogl.Color

      The constant color you want

    Returns void

  • Changes the decimation and interpolation filters used when a texture is drawn at other scales than 100%.

    Parameters

    • layerIndex: number

      the layer number to change.

    • minFilter: Cogl.MaterialFilter

      the filter used when scaling a texture down.

    • magFilter: Cogl.MaterialFilter

      the filter used when magnifying a texture.

    Returns void

  • setLayerMatrix(layerIndex: number, matrix: Cogl.Matrix): void
  • This function lets you set a matrix that can be used to e.g. translate and rotate a single layer of a material used to fill your geometry.

    Parameters

    • layerIndex: number

      the index for the layer inside material

    • matrix: Cogl.Matrix

      the transformation matrix for the layer

    Returns void

  • setLayerPointSpriteCoordsEnabled(layerIndex: number, enable: number): number
  • When rendering points, if enable is %TRUE then the texture coordinates for this layer will be replaced with coordinates that vary from 0.0 to 1.0 across the primitive. The top left of the point will have the coordinates 0.0,0.0 and the bottom right will have 1.0,1.0. If enable is %FALSE then the coordinates will be fixed for the entire point.

    This function will only work if %COGL_FEATURE_POINT_SPRITE is available. If the feature is not available then the function will return %FALSE and set error.

    Parameters

    • layerIndex: number

      the layer number to change.

    • enable: number

      whether to enable point sprite coord generation.

    Returns number

  • Sets the wrap mode for all three coordinates of texture lookups on this layer. This is equivalent to calling cogl_material_set_layer_wrap_mode_s(), cogl_material_set_layer_wrap_mode_t() and cogl_material_set_layer_wrap_mode_p() separately.

    Parameters

    Returns void

  • Sets the wrap mode for the 'p' coordinate of texture lookups on this layer. 'p' is the third coordinate.

    Parameters

    Returns void

  • Sets the wrap mode for the 's' coordinate of texture lookups on this layer.

    Parameters

    Returns void

  • Sets the wrap mode for the 't' coordinate of texture lookups on this layer.

    Parameters

    Returns void

  • setPointSize(pointSize: number): void
  • Changes the size of points drawn when %COGL_VERTICES_MODE_POINTS is used with the vertex buffer API. Note that typically the GPU will only support a limited minimum and maximum range of point sizes. If the chosen point size is outside that range then the nearest value within that range will be used instead. The size of a point is in screen space so it will be the same regardless of any transformations. The default point size is 1.0.

    Parameters

    • pointSize: number

      the new point size.

    Returns void

  • setShininess(shininess: number): void
  • Sets the shininess of the material, in the standard OpenGL lighting model, which determines the size of the specular highlights. A higher shininess will produce smaller highlights which makes the object appear more shiny.

    The default value is 0.0

    Parameters

    • shininess: number

      The desired shininess; must be >= 0.0

    Returns void

  • Sets the material's specular color, in the standard OpenGL lighting model. The intensity of the specular color depends on the viewport position, and is brightest along the lines of reflection.

    The default value is (0.0, 0.0, 0.0, 1.0)

    Parameters

    • specular: Cogl.Color

      The components of the desired specular color

    Returns void

  • setUserProgram(program: object): void
  • Associates a linked CoglProgram with the given material so that the program can take full control of vertex and/or fragment processing.

    This is an example of how it can be used to associate an ARBfp program with a #CoglMaterial: |[ CoglHandle shader; CoglHandle program; CoglMaterial *material;

    shader = cogl_create_shader (COGL_SHADER_TYPE_FRAGMENT); cogl_shader_source (shader, "!!ARBfp1.0\n" "MOV result.color,fragment.color;\n" "END\n"); cogl_shader_compile (shader);

    program = cogl_create_program (); cogl_program_attach_shader (program, shader); cogl_program_link (program);

    material = cogl_material_new (); cogl_material_set_user_program (material, program);

    cogl_set_source_color4ub (0xff, 0x00, 0x00, 0xff); cogl_rectangle (0, 0, 100, 100);



    It is possibly worth keeping in mind that this API is not part of
    the long term design for how we want to expose shaders to Cogl
    developers (We are planning on deprecating the cogl_program and
    cogl_shader APIs in favour of a "snippet" framework) but in the
    meantime we hope this will handle most practical GLSL and ARBfp
    requirements.

    Also remember you need to check for either the
    %COGL_FEATURE_SHADERS_GLSL or %COGL_FEATURE_SHADERS_ARBFP before
    using the cogl_program or cogl_shader API.
    @param program A #CoglHandle to a linked CoglProgram

    Parameters

    • program: object

    Returns void

  • ref(material: object): object
  • Increment the reference count for a #CoglMaterial.

    Parameters

    • material: object

      a #CoglMaterial object.

    Returns object

  • unref(material: object): void
  • Decrement the reference count for a #CoglMaterial.

    Parameters

    • material: object

      a #CoglMaterial object.

    Returns void

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method