/** * @param shader * @param count * @param string * @param length * @see com.jogamp.opengl.GL2ES2#glShaderSource(int, int, java.lang.String[], java.nio.IntBuffer) */ public void glShaderSource(int shader, int count, String[] string, IntBuffer length) { try{delegate.glShaderSource(shader, count, string, length);} catch(GLException e){glException(e); throw e;} } /**
/** * @param shader * @param count * @param string * @param length * @param length_offset * @see com.jogamp.opengl.GL2ES2#glShaderSource(int, int, java.lang.String[], int[], int) */ public void glShaderSource(int shader, int count, String[] string, int[] length, int length_offset) { try{delegate.glShaderSource(shader, count, string, length, length_offset);} catch(GLException e){glException(e); throw e;} } /**
@Override public void glShaderSource(int shader, String string) { String[] sources = new String[]{string}; int[] sourceLengths = new int[]{sources[0].length()}; GLContext.getCurrentGL().getGL3().glShaderSource(shader, sources.length, sources, sourceLengths, 0); }
public void setSource(String source) { GL3 gl = gpu.getGl(); gl.glShaderSource(shaderID, 1, new String[] { source }, (IntBuffer) null); gl.glCompileShader(shaderID); printStatusInfo(gl, shaderID); }// end setSource
public GLShader(final GL pGL, final Class<?> pRootClass, final String pResourceName, final GLShaderType pShaderType) throws IOException { super(); mGL = pGL; final InputStream lResourceAsStream = pRootClass.getResourceAsStream(pResourceName); mShaderSource = new Scanner(lResourceAsStream, "UTF-8").useDelimiter("\\A").next(); mShaderType = pShaderType; mShaderSourcePath = pResourceName; mShaderSourceRootClass = pRootClass; mParameters = new HashMap<>(); Path p = getPath(pRootClass.getResource(pResourceName)); mShaderBasePath = p.getParent(); // preprocess shader final String shaderSourceProcessed = preprocessShader(mShaderSource); mShaderId = pGL.getGL3().glCreateShader(glShaderTypeMapping.get(pShaderType)); mGL.getGL3().glShaderSource(mShaderId, 1, new String[]{shaderSourceProcessed}, null); mGL.getGL3().glCompileShader(mShaderId); }
public GLShader(final GL pGL, final Class<?> pRootClass, final String pResourceName, final GLShaderType pShaderType, final HashMap<String, String> params) throws IOException { super(); mGL = pGL; final InputStream lResourceAsStream = pRootClass.getResourceAsStream(pResourceName); mShaderSource = new Scanner(lResourceAsStream, "UTF-8").useDelimiter("\\A").next(); mShaderType = pShaderType; mShaderSourcePath = pResourceName; mShaderSourceRootClass = pRootClass; mParameters = params; Path p = getPath(pRootClass.getResource(pResourceName)); mShaderBasePath = p.getParent(); // preprocess shader final String shaderSourceProcessed = preprocessShader(mShaderSource); mShaderId = pGL.getGL3().glCreateShader(glShaderTypeMapping.get(pShaderType)); mGL.getGL3().glShaderSource(mShaderId, 1, new String[]{shaderSourceProcessed}, null); mGL.getGL3().glCompileShader(mShaderId); }
g.glShaderSource(vs, vertex_source.size(), vertex_lines, vertex_lengths); g.glCompileShader(vs); g.glGetShaderiv(vs, GL2ES2.GL_COMPILE_STATUS, status);
g.glShaderSource( fs, fragment_source.size(),
public GLShader(final GL pGL, final String pShaderSourceAsString, final GLShaderType pShaderType) throws IOException { super(); mGL = pGL; mShaderSource = pShaderSourceAsString; mShaderType = pShaderType; mShaderSourceRootClass = null; mShaderSourcePath = null; mParameters = new HashMap<>(); mShaderBasePath = null; // preprocess shader final String shaderSourceProcessed = preprocessShader(mShaderSource); mShaderId = pGL.getGL3().glCreateShader(glShaderTypeMapping.get(pShaderType)); mGL.getGL3().glShaderSource(mShaderId, 1, new String[]{shaderSourceProcessed}, null); mGL.getGL3().glCompileShader(mShaderId); }
public void recompile(final GL pGL) { close(); // preprocess shader final String shaderSourceProcessed = preprocessShader(mShaderSource); mShaderId = pGL.getGL3().glCreateShader(glShaderTypeMapping.get(mShaderType)); mGL.getGL3().glShaderSource(mShaderId, 1, new String[]{shaderSourceProcessed}, null); mGL.getGL3().glCompileShader(mShaderId); }
/** * Implementation for {@link #createGlShader(int, String)}. * * @param shaderType The shader type * @param shaderSource The shader source code * @return The GL shader, or <code>null</code> if it cannot be compiled */ private Integer createGlShaderImpl(int shaderType, String shaderSource) { int glShader = gl.glCreateShader(shaderType); gl.glShaderSource( glShader, 1, new String[]{shaderSource}, null); gl.glCompileShader(glShader); int compileStatus[] = { 0 }; gl.glGetShaderiv(glShader, GL_COMPILE_STATUS, compileStatus, 0); if (compileStatus[0] != GL_TRUE) { printShaderLogInfo(glShader); return null; } return glShader; }
/** * Creates a new shader object. * @param gl gl object * @param code shader code * @param type shader type */ private Shader(final GL3 gl, final String code, final Type type) { this.gl = gl; this.shaderHandle = gl.glCreateShader(type.getGlShaderType()); this.code = code; this.type = type; gl.glShaderSource(this.shaderHandle, 1, new String[]{this.code}, (int[]) null, 0); gl.glCompileShader(this.shaderHandle); String info = getShaderInfoLog(gl, this.shaderHandle); if (!isShaderValid(gl, this.shaderHandle)) { gl.glDeleteShader(this.shaderHandle); this.shaderHandle = 0; throw new RuntimeException(info); } }