List of usage examples for org.lwjgl.opengl GL20 glUseProgram
public static void glUseProgram(@NativeType("GLuint") int program)
From source file:com.xrbpowered.gl.examples.GLGlass.java
License:Open Source License
@Override protected void setupResources() { super.setupResources(); glassShader = new GlassShader(); diffuse = new Texture("checker.png"); alpha1 = BufferTexture.createPlainColor(4, 4, new Color(0x22777777, true)); alpha2 = BufferTexture.createPlainColor(4, 4, new Color(0x00ffffff, true)); normal = new Texture("glass_n.png"); blurMask = new Texture("glass_blur.png"); plane = FastMeshBuilder.plane(4f, 1, 1, StandardShader.standardVertexInfo, null); Random random = new Random(); objectActors = new StaticMeshActor[NUM_OBJECTS]; for (int i = 0; i < NUM_OBJECTS; i++) { objectActors[i] = StaticMeshActor.make(scene, plane, StandardShader.getInstance(), diffuse, noSpecularTexture, plainNormalTexture); objectActors[i].position.x = random.nextFloat() * OBJECT_RANGE * 2f - OBJECT_RANGE; objectActors[i].position.y = random.nextFloat() * OBJECT_RANGE * 2f - OBJECT_RANGE; objectActors[i].position.z = random.nextFloat() * OBJECT_RANGE * 2f - OBJECT_RANGE; objectActors[i].rotation.x = (float) Math.PI / 2f; objectActors[i].updateTransform(); }/*from w ww .j a va2s . com*/ planeActors1 = new StaticMeshActor[NUM_PLANES]; planeActors2 = new StaticMeshActor[NUM_PLANES]; for (int i = 0; i < NUM_PLANES; i++) { planeActors1[i] = StaticMeshActor.make(scene, plane, StandardShader.getInstance(), alpha1, plainSpecularTexture, normal); planeActors1[i].setShader(glassShader); planeActors2[i] = StaticMeshActor.make(scene, plane, StandardShader.getInstance(), alpha2, noSpecularTexture, normal); planeActors2[i].setShader(glassShader); planeActors1[i].position.x = random.nextFloat() * OBJECT_RANGE * 2f - OBJECT_RANGE; planeActors1[i].position.y = random.nextFloat() * OBJECT_RANGE * 2f - OBJECT_RANGE; planeActors1[i].position.z = random.nextFloat() * OBJECT_RANGE * 2f - OBJECT_RANGE; planeActors1[i].rotation.x = (float) Math.PI / 2f; planeActors2[i].position = planeActors1[i].position; planeActors2[i].rotation = planeActors1[i].rotation; planeActors1[i].updateTransform(); planeActors2[i].updateTransform(); } interBuffers = new OffscreenBuffers(getTargetWidth(), getTargetHeight(), false); blurBuffers = new OffscreenBuffers(getTargetWidth() / 6, getTargetHeight() / 6, false); postProc = new PostProcessShader("post_blur_f.glsl") { @Override protected void storeUniformLocations() { super.storeUniformLocations(); GL20.glUseProgram(pId); GL20.glUniform1i(GL20.glGetUniformLocation(pId, "numSamples"), 5); GL20.glUniform1f(GL20.glGetUniformLocation(pId, "range"), 15f); GL20.glUseProgram(0); } }; lightActor.rotation = new Vector3f((float) Math.PI, 0, 0); lightActor.updateTransform(); }
From source file:com.xrbpowered.gl.examples.GLPerlin.java
License:Open Source License
@Override protected void setupResources() { super.setupResources(); shader = new PostProcessShader("post_noise_f.glsl") { private int pivotLocation; private int scaleLocation; private int seedLocation; @Override/*from ww w . j a v a2s . co m*/ protected void storeUniformLocations() { super.storeUniformLocations(); pivotLocation = GL20.glGetUniformLocation(pId, "pivot"); scaleLocation = GL20.glGetUniformLocation(pId, "scale"); seedLocation = GL20.glGetUniformLocation(pId, "seed"); GL20.glUseProgram(pId); GL20.glUniform1i(GL20.glGetUniformLocation(pId, "palette"), 0); GL20.glUseProgram(0); } @Override public void updateUniforms() { super.updateUniforms(); GL20.glUniform2f(pivotLocation, pivotx, pivoty); GL20.glUniform2f(scaleLocation, buffer.getWidth() / 2, buffer.getHeight() / 2); GL20.glUniform1i(seedLocation, seed); } }; resetBuffer(); }
From source file:com.xrbpowered.gl.res.shaders.PostProcessShader.java
License:Open Source License
@Override protected void storeUniformLocations() { timeLocation = GL20.glGetUniformLocation(pId, "time"); GL20.glUseProgram(pId); GL20.glUniform1i(GL20.glGetUniformLocation(pId, "colorBuf"), 0); GL20.glUseProgram(0);//w w w . j a va 2 s . c om }
From source file:com.xrbpowered.gl.res.shaders.Shader.java
License:Open Source License
public void use() { GL20.glUseProgram(pId); updateUniforms(); }
From source file:com.xrbpowered.gl.res.shaders.Shader.java
License:Open Source License
public void unuse() { GL20.glUseProgram(0); }
From source file:com.xrbpowered.gl.res.shaders.Shader.java
License:Open Source License
public void destroy() { GL20.glUseProgram(0); GL20.glDeleteProgram(pId); }
From source file:com.xrbpowered.gl.res.shaders.Shader.java
License:Open Source License
protected void initSamplers(String[] names) { GL20.glUseProgram(pId); for (int i = 0; i < names.length; i++) { GL20.glUniform1i(GL20.glGetUniformLocation(pId, names[i]), i); }/* w w w . j a va 2s . co m*/ GL20.glUseProgram(0); }
From source file:com.xrbpowered.gl.res.shaders.StandardShader.java
License:Open Source License
private void setPointLights(int n, Vector3f[] positions, Vector4f[] colors, Vector3f[] att) { GL20.glUseProgram(pId); GL20.glUniform1i(GL20.glGetUniformLocation(pId, "numPointLights"), n); for (int i = 0; i < n; i++) { String s = String.format("pointLights[%d].", i); uniform(GL20.glGetUniformLocation(pId, s + "position"), positions[i]); uniform(GL20.glGetUniformLocation(pId, s + "att"), att[i]); uniform(GL20.glGetUniformLocation(pId, s + "color"), colors[i]); }/* www .j a v a2 s . c o m*/ GL20.glUseProgram(0); }
From source file:com.xrbpowered.gl.res.shaders.StandardShader.java
License:Open Source License
private void setFog(float near, float far, Vector4f color) { GL20.glUseProgram(pId); GL20.glUniform1f(GL20.glGetUniformLocation(pId, "fogNear"), near); GL20.glUniform1f(GL20.glGetUniformLocation(pId, "fogFar"), far); uniform(GL20.glGetUniformLocation(pId, "fogColor"), color); GL20.glUseProgram(0);// w ww. ja v a2 s .c o m }
From source file:com.xrbpowered.gl.ui.UIShader.java
License:Open Source License
@Override protected void storeUniformLocations() { alphaLocation = GL20.glGetUniformLocation(pId, "alpha"); anchorLocation = GL20.glGetUniformLocation(pId, "anchor"); screenSizeLocation = GL20.glGetUniformLocation(pId, "screenSize"); GL20.glUseProgram(pId); GL20.glUniform1i(GL20.glGetUniformLocation(pId, "tex"), 0); GL20.glUniform2f(screenSizeLocation, Display.getWidth(), Display.getHeight()); GL20.glUseProgram(0);//from ww w .ja va2s . c o m }