com.neovisionaries.android.opengl
Class Sampler

java.lang.Object
  extended by com.neovisionaries.android.opengl.Sampler

public class Sampler
extends Object

A class to manipulate a uniform sampler variable in OpenGL Shader Language.

 // E X A M P L E

 // Get a program from somewhere.
 Program program = ...;

 // Get an accessor to a uniform sampler variable.
 Sampler s_texture = program.getSampler("s_texture");

 // Get a texture from somewhere.
 Texture<?> texture = ...;

 // Set the texture to the uniform sampler variable.
 s_texture.set(texture);
 

Author:
Takahiko Kawasaki

Constructor Summary
Sampler(Program program, String name)
          A constructor.
 
Method Summary
 int getLocation()
          Get the location of this uniform sampler variable.
 Sampler set(Texture<?> texture)
          Set a texture to this uniform sampler variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sampler

public Sampler(Program program,
               String name)
        throws GLESException
A constructor.

Parameters:
program -
name -
Throws:
IllegalArgumentException - Either or both of the arguments are null.
GLESException - There is no such a uniform variable having the specified name.
See Also:
glGetUniformLocation, Program.getSampler(String)
Method Detail

getLocation

public int getLocation()
Get the location of this uniform sampler variable.

Returns:
The location of this uniform sampler variable
See Also:
glGetUniformLocation

set

public Sampler set(Texture<?> texture)
Set a texture to this uniform sampler variable.

This method does the same thing as glUniformli(getLocation(), texture.getUnit()).

Parameters:
texture - A texture to set to this uniform sampler variable.
Returns:
This Sampler object.
Throws:
IllegalArgumentException - The argumenet is null.
See Also:
glUniform1i