1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
package be.yildiz.client.graphic.engine.ogre;
import lombok.Getter;
import be.yildiz.client.graphic.engine.Shader;
import be.yildiz.common.Native;
import be.yildiz.common.NativePointer;
/**
* Ogre implementation for a shader.
* @author Van den Borre Grégory
* @version 1.0(07/04/2013)
* @since 0.10
*/
public final class OgreShader extends Shader implements Native {
/**
* Native pointer.
*/
@Getter
private final NativePointer pointer;
/**
* Full constructor.
* @param name
* Shader name.
* @param path
* Shader file path.
* @param entry
* Main function name.
* @param type
* Shader type.
* @param profile
* Profile to set.
*/
public OgreShader(final String name, final String path, final String entry,
final ShaderType type, final ShaderProfile profile) {
super(name, type);
this.pointer = NativePointer.newPointer(this.createShader(name, path,
type.getValue()));
this.setParameter(this.pointer.address, "entry_point", entry);
this.setParameter(this.pointer.address, "profiles", profile.getName());
}
/**
* Create the shader in native code.
* @param name
* Shader name.
* @param path
* Path to the file.
* @param type
* Shader type.
* @return The pointer address of the created object.
*/
private native long createShader(final String name, final String path,
final int type);
/**
* Set parameter to pass to the shader, those parameters are meant to
* specify to the graphic engine how to load the shader(entry point,
* profile...), those are not meant to be used as shader function
* parameter..
* @param pointer
* Native object pointer address.
* @param name
* Parameter name.
* @param value
* Parameter value.
*/
private native void setParameter(final long pointer, final String name,
final String value);
} |
Partager