|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecthmi.graphics.opengl.GLShaderProgram
public class GLShaderProgram
A GLSL shader program wrapper, in the form of a GLRenderObject. A GLShaderProgram encapsulates a GLSL shader program, but it does not handle particular settings for its uniform variables. The latter aspect is delegated to the GLShader class. GLShaderProgram does contain a few utility methods for obtaining uniform locations, and for extracting uniform declarations from shader code. Basically, GLShaderProgram deals with the shader *texts*, up to and including compilation and linking, and unform declarations within these shader texts.
| Field Summary | |
|---|---|
(package private) static Pattern |
declPattern
|
private String |
fstext
|
private int |
shaderId
|
private String |
shaderName
|
(package private) static Pattern |
uniformLinePattern
|
(package private) static Pattern |
varPattern
|
private String |
vstext
|
| Constructor Summary | |
|---|---|
GLShaderProgram()
Default constructor |
|
GLShaderProgram(String shaderName,
String vstext,
String fstext)
Creates a new GLShaderProgram, with specified vertex shader and fragment shader texts, and specified uniform names |
|
| Method Summary | |
|---|---|
private int |
compileShader(GLRenderContext gl,
String shaderText,
int shaderType)
Compiles a shader program text, and returns the shader handle. |
private int |
createShaderProgram(GLRenderContext gl,
String vertexShaderText,
String fragmentShaderText)
Compiles vertex/frament program texts, allocates a shader program, attaches the compiles vertex and fragment shaders of the program, and links the program. |
int |
getProgramId()
Returns the OpenGL id for the shader program. |
int |
getShaderUniforms(List<String> types,
List<String> names)
|
static List<String> |
getUniformLines(String shader)
Detects lines with uniform declarations in shader text Returns a List of Strings, where each String contains the text after the uniform specified, up to (not including) the ; at the end Eaxh of these has the form: type var-0, var-1, ... var-n where each var has optionally an array postfix of the form [nn] |
int[] |
getUniformLocations(GLRenderContext gl,
String... uniformNames)
Returns the array with OpenGL uniform locations |
static int |
getUniforms(List<String> decls,
List<String> types,
List<String> names)
Parses a list of declarations decls. |
void |
glInit(GLRenderContext gl)
OpenGL initialization: an OpenGL id is created for this shader program, The shader is compiled and linked, and finally, OpenGL uniform locations are obtained. |
void |
glRender(GLRenderContext gl)
Activates thsi shader program as the current shader |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private String vstext
private String fstext
private int shaderId
private String shaderName
static Pattern uniformLinePattern
static Pattern declPattern
static Pattern varPattern
| Constructor Detail |
|---|
public GLShaderProgram()
public GLShaderProgram(String shaderName,
String vstext,
String fstext)
| Method Detail |
|---|
public int getProgramId()
public int[] getUniformLocations(GLRenderContext gl,
String... uniformNames)
public void glInit(GLRenderContext gl)
glInit in interface GLRenderObjectpublic final void glRender(GLRenderContext gl)
glRender in interface GLRenderObject
private int createShaderProgram(GLRenderContext gl,
String vertexShaderText,
String fragmentShaderText)
private int compileShader(GLRenderContext gl,
String shaderText,
int shaderType)
public int getShaderUniforms(List<String> types,
List<String> names)
public static List<String> getUniformLines(String shader)
public static int getUniforms(List<String> decls,
List<String> types,
List<String> names)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||