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 Project: FEMultiplayer   Author: chudooder   File: Renderer.java    License: 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 Project: Cyberware   Author: Flaxbeard   File: ShaderUtil.java    License: 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 Project: FEMultiPlayer-V2   Author: eliatlarge   File: Renderer.java    License: 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 Project: Cyberware   Author: Flaxbeard   File: ShaderUtil.java    License: 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 #5
Source Project: Cyberware   Author: Flaxbeard   File: ShaderUtil.java    License: MIT License 4 votes vote down vote up
public static void releaseShader()
{
	ARBShaderObjects.glUseProgramObjectARB(0);
}
 
Example #6
Source Project: Cyberware   Author: Flaxbeard   File: ShaderUtil.java    License: 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 #7
Source Project: Cyberware   Author: Flaxbeard   File: ShaderUtil.java    License: 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 #8
Source Project: FEMultiplayer   Author: chudooder   File: Renderer.java    License: 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 #9
Source Project: CodeChickenLib   Author: Chicken-Bones   File: ShaderProgram.java    License: GNU Lesser General Public License v2.1 4 votes vote down vote up
public int getUniformLoc(String name)
{
    return ARBShaderObjects.glGetUniformLocationARB(programID, name);
}
 
Example #10
Source Project: CodeChickenLib   Author: Chicken-Bones   File: ShaderProgram.java    License: 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 #11
Source Project: OpenModsLib   Author: OpenMods   File: ShaderHelper.java    License: MIT License 4 votes vote down vote up
@Override
public int glCreateProgram() {
	return ARBShaderObjects.glCreateProgramObjectARB();
}
 
Example #12
Source Project: OpenModsLib   Author: OpenMods   File: ShaderHelper.java    License: MIT License 4 votes vote down vote up
@Override
public int glCreateShader(int type) {
	return ARBShaderObjects.glCreateShaderObjectARB(type);
}
 
Example #13
Source Project: OpenModsLib   Author: OpenMods   File: ShaderHelper.java    License: MIT License 4 votes vote down vote up
@Override
public void glAttachShader(int program, int shader) {
	ARBShaderObjects.glAttachObjectARB(program, shader);
}
 
Example #14
Source Project: OpenModsLib   Author: OpenMods   File: ShaderHelper.java    License: MIT License 4 votes vote down vote up
@Override
public void glDetachShader(int program, int shader) {
	ARBShaderObjects.glDetachObjectARB(program, shader);
}
 
Example #15
Source Project: OpenModsLib   Author: OpenMods   File: ShaderHelper.java    License: MIT License 4 votes vote down vote up
@Override
public void glLinkProgram(int program) {
	ARBShaderObjects.glLinkProgramARB(program);
}
 
Example #16
Source Project: OpenModsLib   Author: OpenMods   File: ShaderHelper.java    License: MIT License 4 votes vote down vote up
@Override
public void glValidateProgram(int program) {
	ARBShaderObjects.glValidateProgramARB(program);
}
 
Example #17
Source Project: OpenModsLib   Author: OpenMods   File: ShaderHelper.java    License: MIT License 4 votes vote down vote up
@Override
public void glDeleteProgram(int program) {
	ARBShaderObjects.glDeleteObjectARB(program);
}
 
Example #18
Source Project: OpenModsLib   Author: OpenMods   File: ShaderHelper.java    License: MIT License 4 votes vote down vote up
@Override
public void glDeleteShader(int shader) {
	ARBShaderObjects.glDeleteObjectARB(shader);
}
 
Example #19
Source Project: OpenModsLib   Author: OpenMods   File: ShaderHelper.java    License: MIT License 4 votes vote down vote up
@Override
public int glGetProgrami(int program, int parameter) {
	return ARBShaderObjects.glGetObjectParameteriARB(program, parameter);
}
 
Example #20
Source Project: OpenModsLib   Author: OpenMods   File: ShaderHelper.java    License: MIT License 4 votes vote down vote up
@Override
public int glGetShaderi(int shader, int parameter) {
	return ARBShaderObjects.glGetObjectParameteriARB(shader, parameter);
}
 
Example #21
Source Project: OpenModsLib   Author: OpenMods   File: ShaderHelper.java    License: 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 #22
Source Project: OpenModsLib   Author: OpenMods   File: ShaderHelper.java    License: 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 #23
Source Project: OpenModsLib   Author: OpenMods   File: ShaderHelper.java    License: MIT License 4 votes vote down vote up
@Override
public void glUseProgram(int program) {
	ARBShaderObjects.glUseProgramObjectARB(program);
}
 
Example #24
Source Project: OpenModsLib   Author: OpenMods   File: ShaderHelper.java    License: MIT License 4 votes vote down vote up
@Override
public void glShaderSource(int shader, String shaderSource) {
	ARBShaderObjects.glShaderSourceARB(shader, shaderSource);
}
 
Example #25
Source Project: OpenModsLib   Author: OpenMods   File: ShaderHelper.java    License: MIT License 4 votes vote down vote up
@Override
public void glCompileShader(int shader) {
	ARBShaderObjects.glCompileShaderARB(shader);
}
 
Example #26
Source Project: OpenModsLib   Author: OpenMods   File: ShaderHelper.java    License: MIT License 4 votes vote down vote up
@Override
public int glGetUniformLocation(int program, String uniform) {
	return ARBShaderObjects.glGetUniformLocationARB(program, uniform);
}
 
Example #27
Source Project: OpenModsLib   Author: OpenMods   File: ShaderHelper.java    License: MIT License 4 votes vote down vote up
@Override
public void glUniform1i(int loc, int val) {
	ARBShaderObjects.glUniform1iARB(loc, val);
}
 
Example #28
Source Project: OpenModsLib   Author: OpenMods   File: ShaderHelper.java    License: MIT License 4 votes vote down vote up
@Override
public void glUniform1f(int loc, float val) {
	ARBShaderObjects.glUniform1fARB(loc, val);
}
 
Example #29
Source Project: OpenModsLib   Author: OpenMods   File: ShaderHelper.java    License: 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 #30
Source Project: FEMultiPlayer-V2   Author: eliatlarge   File: Renderer.java    License: 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));
   }