List of usage examples for org.lwjgl.opengl GL20 glAttachShader
public static void glAttachShader(@NativeType("GLuint") int program, @NativeType("GLuint") int shader)
From source file:jpcsp.graphics.RE.RenderingEngineLwjgl.java
License:Open Source License
@Override public void attachShader(int program, int shader) { GL20.glAttachShader(program, shader); }
From source file:lessur.util.shader.ShaderManager.java
License:GNU General Public License
/** * Attach's the shader to the program, and links the program * @throws Exception //from ww w .j av a2s .c o m */ public void attachAndLinkShader(int program, int shaderID) throws Exception { if (has_opengl2) { GL20.glAttachShader(program, shaderID); GL20.glLinkProgram(program); } else if (has_arb) { ARBShaderObjects.glAttachObjectARB(program, shaderID); ARBShaderObjects.glLinkProgramARB(program); } if (!linkedSuccessfully(program)) { StringBuilder errorMessage = new StringBuilder(); errorMessage.append("Linking Error\n"); errorMessage.append(getProgramInfoLog(program)); errorMessage.append("\n\n"); throw new Exception(errorMessage.toString()); } }
From source file:main.java.com.YeAJG.game.entity.Entity.java
License:Open Source License
private void SetupShaders(String shaderPath, String fragPath) { // Load the vertex shader and fragment shader vsId = ShaderHandler.loadShader(shaderPath); fsId = ShaderHandler.loadFrag(fragPath); // Create a new shader program that links both shaders pId = GL20.glCreateProgram();/*from ww w . j a va 2s.c o m*/ GL20.glAttachShader(pId, vsId); GL20.glAttachShader(pId, fsId); // Position information will be attribute 0 GL20.glBindAttribLocation(pId, 0, "in_Position"); // Color information will be attribute 1 GL20.glBindAttribLocation(pId, 1, "in_Color"); // Textute information will be attribute 2 GL20.glBindAttribLocation(pId, 2, "in_TextureCoord"); GL20.glLinkProgram(pId); GL20.glValidateProgram(pId); // Get matrices uniform locations projectionMatrixLocation = GL20.glGetUniformLocation(pId, "projectionMatrix"); viewMatrixLocation = GL20.glGetUniformLocation(pId, "viewMatrix"); modelMatrixLocation = GL20.glGetUniformLocation(pId, "modelMatrix"); decayLocation = GL20.glGetUniformLocation(pId, "decay"); Game.exitOnGLError("setupShaders"); }
From source file:me.thehutch.fusion.engine.render.opengl.gl20.OpenGL20Program.java
License:Open Source License
@Override public void attachShader(CharSequence source, int type) { ensureCreated("Program must be created to attach a shader."); // Generate a shader handle final int shaderId = GL20.glCreateShader(type); // Upload the shader's source to the GPU GL20.glShaderSource(shaderId, source); // Compile the shader GL20.glCompileShader(shaderId);//from w w w .ja va2 s . co m // Check for a shader compile error if (GL20.glGetShaderi(shaderId, GL_COMPILE_STATUS) == GL_FALSE) { // Get the shader info log length final int logLength = GL20.glGetShaderi(shaderId, GL20.GL_INFO_LOG_LENGTH); throw new IllegalStateException( "OpenGL Error: Could not compile shader\n" + GL20.glGetShaderInfoLog(shaderId, logLength)); } // Attach the shader GL20.glAttachShader(id, shaderId); // Add the shader to the program this.shaders.add(shaderId); // Check for errors RenderUtil.checkGLError(); }
From source file:net.betabears.the2dlibrary.graphics.shader.ShaderProgram.java
@Override public void init() { if (isLoaded && !isInited) { s0.createShader();// w w w. ja v a 2 s . co m s1.createShader(); id = GL20.glCreateProgram(); GL20.glAttachShader(id, s0.getID()); GL20.glAttachShader(id, s1.getID()); GL20.glLinkProgram(id); GL20.glValidateProgram(id); int i; while ((i = GL11.glGetError()) != 0) { LOGGER.log(Level.WARNING, "Error happened during creation of ShaderProgram. GL error code: {0}", i); } isInited = true; } else { LOGGER.log(Level.WARNING, "load() wasn't called before init() or init() has been called already."); } }
From source file:net.neilcsmith.praxis.video.opengl.internal.ShaderProgram.java
License:Apache License
private int linkProgram() { int program = GL20.glCreateProgram(); if (program == 0) return -1; GL20.glAttachShader(program, vertexShaderHandle); GL20.glAttachShader(program, fragmentShaderHandle); GL20.glLinkProgram(program);//from w w w . ja va 2 s . co m // ByteBuffer tmp = ByteBuffer.allocateDirect(4); // tmp.order(ByteOrder.nativeOrder()); // IntBuffer intbuf = tmp.asIntBuffer(); GL20.glGetProgram(program, GL20.GL_LINK_STATUS, intbuf); int linked = intbuf.get(0); if (linked == 0) { return -1; } return program; }
From source file:net.smert.frameworkgl.opengl.helpers.ShaderHelper.java
License:Apache License
public void attach(int programID, int shaderID) { GL20.glAttachShader(programID, shaderID); }
From source file:opengl.test.object.object.java
protected final void vertexShader(String file) { this.vertexID = GL20.glCreateShader(GL20.GL_VERTEX_SHADER); GL20.glShaderSource(this.vertexID, object.sourceLoader(file)); GL20.glCompileShader(this.vertexID); if (GL20.glGetShaderi(this.vertexID, GL20.GL_COMPILE_STATUS) != GL11.GL_TRUE) { throw new RuntimeException("Khong the compile vertexShader"); }/*from ww w .j av a2 s.c o m*/ GL20.glAttachShader(this.programID, this.vertexID); }
From source file:opengl.test.object.object.java
protected final void fragmentShader(String file) { this.fragmentID = GL20.glCreateShader(GL20.GL_FRAGMENT_SHADER); GL20.glShaderSource(this.fragmentID, object.sourceLoader(file)); GL20.glCompileShader(this.fragmentID); if (GL20.glGetShaderi(this.fragmentID, GL20.GL_COMPILE_STATUS) != GL11.GL_TRUE) { throw new RuntimeException("Khong the compile fragmentShader"); }/*from w w w . j ava 2s . co m*/ GL20.glAttachShader(this.programID, this.fragmentID); }
From source file:opengl.test.object.tree.testobject.leaf.java
private void vertexShader(String file) { this.vertexID = GL20.glCreateShader(GL20.GL_VERTEX_SHADER); GL20.glShaderSource(this.vertexID, leaf.sourceLoader(file)); GL20.glCompileShader(this.vertexID); if (GL20.glGetShaderi(this.vertexID, GL20.GL_COMPILE_STATUS) != GL11.GL_TRUE) { throw new RuntimeException("Khong the compile vertexShader"); }/*from w w w .jav a2 s .c om*/ GL20.glAttachShader(this.programID, this.vertexID); }