/** * @param type * @return * @see com.jogamp.opengl.GL2ES2#glCreateShader(int) */ public int glCreateShader(int type) { try{ return delegate.glCreateShader(type);} catch(GLException e){glException(e); throw e;} } /**
GLShader(GPU gpu) { this.gpu = gpu; shaderID = gpu.getGl().glCreateShader(getShaderType()); if (shaderID < 0) throw new RuntimeException( "Invalid shader ID " + shaderID + ". Something went wrong somewhere in putting the shader together."); }//end constructor
@Override public int glCreateShader(int type) { return GLContext.getCurrentGL().getGL3().glCreateShader(type); }
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); }
final int vs = g.glCreateShader(GL2ES2.GL_VERTEX_SHADER); g.glShaderSource(vs, vertex_source.size(), vertex_lines, vertex_lengths); g.glCompileShader(vs);
final int fs = g.glCreateShader(GL2ES2.GL_FRAGMENT_SHADER); g.glShaderSource( fs,
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); } }