org.lwjgl.opengl.ARBShaderObjects Java Examples

The following examples show how to use org.lwjgl.opengl.ARBShaderObjects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Renderer.java    From FEMultiplayer with GNU General Public License v3.0 6 votes vote down vote up
private static int createShader(String filename, int shaderType) throws Exception {
	int shader = 0;
	try {
     shader = ARBShaderObjects.glCreateShaderObjectARB(shaderType);
     
     if(shader == 0)
     	return 0;
     
     ARBShaderObjects.glShaderSourceARB(shader, readFileAsString(filename));
     ARBShaderObjects.glCompileShaderARB(shader);
     
     if (ARBShaderObjects.glGetObjectParameteriARB(shader, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL_FALSE)
         throw new RuntimeException("Error creating shader: " + getLogInfo(shader));
     
     return shader;
	}
	catch(Exception exc) {
		ARBShaderObjects.glDeleteObjectARB(shader);
		throw exc;
	}
}
 
Example #2
Source File: ShaderUtil.java    From Cyberware with MIT License 5 votes vote down vote up
private static int createShader(String filename, int shaderType)
{
	int shader = 0;
	try
	{
		shader = ARBShaderObjects.glCreateShaderObjectARB(shaderType);

		if(shader == 0)
		{
			return 0;
		}

		ARBShaderObjects.glShaderSourceARB(shader, readFileAsString(filename));
		ARBShaderObjects.glCompileShaderARB(shader);

		if (ARBShaderObjects.glGetObjectParameteriARB(shader, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE)
			throw new RuntimeException("Error creating shader: " + getLogInfo(shader));

		return shader;
	}
	catch(Exception e)
	{
		ARBShaderObjects.glDeleteObjectARB(shader);
		e.printStackTrace();
		return -1;
	}
}
 
Example #3
Source File: Renderer.java    From FEMultiPlayer-V2 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates the shader.
 *
 * @param filename the filename
 * @param shaderType the shader type
 * @return the int
 * @throws Exception the exception
 */
/*
* With the exception of syntax, setting up vertex and fragment shaders
* is the same.
* @param the name and path to the vertex shader
*/
private static int createShader(String filename, int shaderType) throws Exception {
	int shader = 0;
	try {
     shader = ARBShaderObjects.glCreateShaderObjectARB(shaderType);
     
     if(shader == 0)
     	return 0;
     
     ARBShaderObjects.glShaderSourceARB(shader, readFileAsString(filename));
     ARBShaderObjects.glCompileShaderARB(shader);
     
     if (ARBShaderObjects.glGetObjectParameteriARB(shader, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL_FALSE)
         throw new RuntimeException("Error creating shader: " + getLogInfo(shader));
     
     return shader;
	}
	catch(Exception exc) {
		ARBShaderObjects.glDeleteObjectARB(shader);
		throw exc;
	}
}
 
Example #4
Source File: ShaderHelper.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void glCompileShader(int shader) {
	ARBShaderObjects.glCompileShaderARB(shader);
}
 
Example #5
Source File: ShaderHelper.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void glDeleteProgram(int program) {
	ARBShaderObjects.glDeleteObjectARB(program);
}
 
Example #6
Source File: ShaderHelper.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void glDeleteShader(int shader) {
	ARBShaderObjects.glDeleteObjectARB(shader);
}
 
Example #7
Source File: ShaderHelper.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public int glGetProgrami(int program, int parameter) {
	return ARBShaderObjects.glGetObjectParameteriARB(program, parameter);
}
 
Example #8
Source File: ShaderHelper.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public int glGetShaderi(int shader, int parameter) {
	return ARBShaderObjects.glGetObjectParameteriARB(shader, parameter);
}
 
Example #9
Source File: ShaderHelper.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public String getProgramLogInfo(int program) {
	return ARBShaderObjects.glGetInfoLogARB(program, glGetProgrami(program, GL20.GL_INFO_LOG_LENGTH));
}
 
Example #10
Source File: ShaderHelper.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public String getShaderLogInfo(int shader) {
	return ARBShaderObjects.glGetInfoLogARB(shader, glGetShaderi(shader, GL20.GL_INFO_LOG_LENGTH));
}
 
Example #11
Source File: ShaderHelper.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void glUseProgram(int program) {
	ARBShaderObjects.glUseProgramObjectARB(program);
}
 
Example #12
Source File: ShaderHelper.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void glShaderSource(int shader, String shaderSource) {
	ARBShaderObjects.glShaderSourceARB(shader, shaderSource);
}
 
Example #13
Source File: ShaderHelper.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void glLinkProgram(int program) {
	ARBShaderObjects.glLinkProgramARB(program);
}
 
Example #14
Source File: ShaderHelper.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public int glGetUniformLocation(int program, String uniform) {
	return ARBShaderObjects.glGetUniformLocationARB(program, uniform);
}
 
Example #15
Source File: ShaderHelper.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void glUniform1i(int loc, int val) {
	ARBShaderObjects.glUniform1iARB(loc, val);
}
 
Example #16
Source File: ShaderHelper.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void glUniform1f(int loc, float val) {
	ARBShaderObjects.glUniform1fARB(loc, val);
}
 
Example #17
Source File: ShaderHelper.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void glUniform3f(int loc, float x, float y, float z) {
	ARBShaderObjects.glUniform3fARB(loc, x, y, z);
}
 
Example #18
Source File: ShaderHelper.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void glValidateProgram(int program) {
	ARBShaderObjects.glValidateProgramARB(program);
}
 
Example #19
Source File: ShaderUtil.java    From Cyberware with MIT License 4 votes vote down vote up
public static void alpha(float av)
{
	ARBShaderObjects.glUseProgramObjectARB(alpha);
	int a = ARBShaderObjects.glGetUniformLocationARB(alpha, "alpha");
	ARBShaderObjects.glUniform1fARB(a, av);
}
 
Example #20
Source File: ShaderHelper.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void glDetachShader(int program, int shader) {
	ARBShaderObjects.glDetachObjectARB(program, shader);
}
 
Example #21
Source File: ShaderHelper.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void glAttachShader(int program, int shader) {
	ARBShaderObjects.glAttachObjectARB(program, shader);
}
 
Example #22
Source File: ShaderHelper.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public int glCreateShader(int type) {
	return ARBShaderObjects.glCreateShaderObjectARB(type);
}
 
Example #23
Source File: ShaderHelper.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public int glCreateProgram() {
	return ARBShaderObjects.glCreateProgramObjectARB();
}
 
Example #24
Source File: ShaderProgram.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void uniformTexture(String name, int textureIndex)
{
    ARBShaderObjects.glUniform1iARB(getUniformLoc(name), textureIndex);
}
 
Example #25
Source File: ShaderProgram.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
public int getUniformLoc(String name)
{
    return ARBShaderObjects.glGetUniformLocationARB(programID, name);
}
 
Example #26
Source File: Renderer.java    From FEMultiplayer with GNU General Public License v3.0 4 votes vote down vote up
private static String getLogInfo(int obj) {
    return ARBShaderObjects.glGetInfoLogARB(obj, 
    		ARBShaderObjects.glGetObjectParameteriARB(obj,
    				ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB));
}
 
Example #27
Source File: ShaderUtil.java    From Cyberware with MIT License 4 votes vote down vote up
private static String getLogInfo(int obj)
{
	return ARBShaderObjects.glGetInfoLogARB(obj, ARBShaderObjects.glGetObjectParameteriARB(obj, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB));
}
 
Example #28
Source File: ShaderUtil.java    From Cyberware with MIT License 4 votes vote down vote up
private static int createShader(String vert, String frag)
{
	int fragid = 0;
	int vertid = 0;
	
	if (frag != null)
	{
		fragid = createShader(frag, FRAG);
	}
	if (vert != null)
	{
		vertid = createShader(vert, VERT);
	}
	
	int program = ARBShaderObjects.glCreateProgramObjectARB();
	if (program == 0)
	{
		return 0;
	}
	
	if (frag != null)
	{
		ARBShaderObjects.glAttachObjectARB(program, fragid);
	}
	
	if (vert != null)
	{
		ARBShaderObjects.glAttachObjectARB(program, vertid);
	}
	
	ARBShaderObjects.glLinkProgramARB(program);
	if(ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE)
	{
		System.out.println("BAD: " + getLogInfo(program));
		return 0;
	}
	
	if (ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_VALIDATE_STATUS_ARB) == GL11.GL_FALSE)
	{
		System.out.println("BAD: " + getLogInfo(program));
		return 0;
	}
	
	return program;
}
 
Example #29
Source File: ShaderUtil.java    From Cyberware with MIT License 4 votes vote down vote up
public static void releaseShader()
{
	ARBShaderObjects.glUseProgramObjectARB(0);
}
 
Example #30
Source File: Renderer.java    From FEMultiPlayer-V2 with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Gets the log info.
 *
 * @param obj the obj
 * @return the log info
 */
private static String getLogInfo(int obj) {
       return ARBShaderObjects.glGetInfoLogARB(obj, 
       		ARBShaderObjects.glGetObjectParameteriARB(obj,
       				ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB));
   }