本文整理匯總了Java中org.lwjgl.opengl.GL20.glGetUniformLocation方法的典型用法代碼示例。如果您正苦於以下問題:Java GL20.glGetUniformLocation方法的具體用法?Java GL20.glGetUniformLocation怎麽用?Java GL20.glGetUniformLocation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.lwjgl.opengl.GL20
的用法示例。
在下文中一共展示了GL20.glGetUniformLocation方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: fetchUniforms
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
private Uniform[] fetchUniforms()
{
int len = GL20.glGetProgrami(this.handle, GL20.GL_ACTIVE_UNIFORMS);
int strlen = GL20.glGetProgrami(this.handle, GL20.GL_ACTIVE_UNIFORM_MAX_LENGTH);
Uniform[] uniforms = new Uniform[len];
IntBuffer sizeBuffer = BufferUtils.createIntBuffer(1);
IntBuffer typeBuffer = BufferUtils.createIntBuffer(1);
for(int i = 0; i < uniforms.length; ++i)
{
String name = GL20.glGetActiveUniform(this.handle, i, strlen, sizeBuffer, typeBuffer);
int location = GL20.glGetUniformLocation(this.handle, name);
uniforms[i] = new Uniform(this, name, typeBuffer.get(), location);
typeBuffer.flip();
}
return uniforms;
}
示例2: initializeWorld
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
private void initializeWorld(int renderDistance, int centerX, int centerY, int centerZ, Shader shader) {
playerChunkX = centerX;
playerChunkZ = centerZ;
//initialize the world
worldChunks = new int[(renderDistance*2-1)*16*(renderDistance*2-1)];
worldMetadata = new int[(renderDistance*2-1)*16*(renderDistance*2-1)];
chunkIdList = new ArrayDeque<Integer>();
metadataIdList = new ArrayDeque<Integer>();
for (int i = worldChunks.length; i > 0; i--) {
chunkIdList.push(i);
}
for (int i = worldMetadata.length; i > 0; i--) {
metadataIdList.push(i);
}
//update the buffer size
GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, shader.getChunkSsbo());
GL15.glBufferData(GL43.GL_SHADER_STORAGE_BUFFER, chunkSize*worldChunks.length*2*4, GL15.GL_DYNAMIC_DRAW);
GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, shader.getMetadataSsbo());
GL15.glBufferData(GL43.GL_SHADER_STORAGE_BUFFER, chunkSize*worldMetadata.length*4, GL15.GL_DYNAMIC_DRAW);
GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, 0);
//inform the shader of the new render distance
int renderDistanceUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "renderDistance");
GL20.glUniform1i(renderDistanceUniform, renderDistance-1);
}
示例3: addUniform
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
/**
* Adds the specified uniform to the lookup table and shader
* @param uniform
*/
public void addUniform(String uniform) {
// The location in memory of the uniform
int location = GL20.glGetUniformLocation(pid, uniform);
// If the uniform does not exist
if(location == -1) {
System.err.println("Error in Shader.addUniform(): uniform [" + uniform + "] does not exist");
System.exit(1);
}
// Add the uniform to the lookup table
uniforms.put(uniform, location);
}
示例4: getUniformLocation
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
/**
* Cached lookup for uniform variable locations
* @param name variable name in shader
* @return location
*/
private int getUniformLocation(String name) {
// Return location if it is already known
if (uniforms.containsKey(name)) {
return uniforms.get(name);
} else {
int location = GL20.glGetUniformLocation(id, name);
uniforms.put(name, location);
return location;
}
}
示例5: findUniformLocation
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
public int findUniformLocation(String uniformName)
{
Uniform uniform = this.uniforms.get(uniformName);
if (uniform == null)
{
int location = GL20.glGetUniformLocation(this.handle, uniformName);
if (location < 0)
{
throw new GLException("Could not find uniform with name: " + uniformName);
}
return location;
}
return uniform.location;
}
示例6: getUniformLocation
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
public int getUniformLocation(String uniform) {
for (String s : uniformsDetection) {
if (s.equals(uniform)) {
return GL20.glGetUniformLocation(program, uniform);
}
}
System.err.println("Uniform not found: " + uniform);
return -1;
}
示例7: getUniformLocation
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
protected int getUniformLocation(String uniformName) {
return GL20.glGetUniformLocation(programID, uniformName);
}
示例8: runShader
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
public static void runShader() {
Minecraft mc = Minecraft.getMinecraft();
//TODO remove
if (Keyboard.isKeyDown(Keyboard.KEY_NUMPAD5)) {
destroyShader();
createShader();
}
//Use shader program
GL20.glUseProgram(shader.getShaderProgram());
//TODO third person view
Entity entity = mc.getRenderViewEntity();
float partialTicks = mc.getRenderPartialTicks();
double entityPosX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double)partialTicks;
double entityPosY = entity.lastTickPosY + entity.getEyeHeight() + (entity.posY - entity.lastTickPosY) * (double)partialTicks;
double entityPosZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double)partialTicks;
float fov = (float) Math.toRadians(mc.entityRenderer.getFOVModifier(partialTicks, true));
//Set uniform values
int texUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "tex");
GL20.glUniform1i(texUniform, 0);
int cameraPosUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "cameraPos");
GL20.glUniform3f(cameraPosUniform, (float)entityPosX%16, (float)entityPosY%16, (float)entityPosZ%16);
int cameraDirUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "cameraDir");
GL20.glUniform3f(cameraDirUniform, -(float)Math.toRadians(entity.rotationPitch), (float)Math.toRadians(180+entity.rotationYaw), 0);
int fovyUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "fovy");
GL20.glUniform1f(fovyUniform, fov);
int fovxUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "fovx");
GL20.glUniform1f(fovxUniform, fov*Display.getWidth()/(float)Display.getHeight());
int sphericalUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "spherical");
GL20.glUniform1i(sphericalUniform, RayTracerSettings.spherical ? 1 : 0);
int stereoscopicUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "stereoscopic3d");
GL20.glUniform1i(stereoscopicUniform, RayTracerSettings.stereoscopic ? 1 : 0);
int eyeWidthUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "eyeWidth");
GL20.glUniform1f(eyeWidthUniform, 0.063f); //TODO input eyeWidth option
if (!pauseRendering) {
if (worldLoader == null) {
worldLoader = new WorldLoader();
}
if (worldLoader.dimension != mc.world.provider.getDimension()) {
worldLoader.dimension = mc.world.provider.getDimension();
}
worldLoader.updateWorld(entityPosX, entityPosY, entityPosZ, shader);
//Setup view
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glPushMatrix();
GL11.glLoadIdentity();
GL11.glOrtho(-1, 1, -1, 1, -1, 1);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glPushMatrix();
GL11.glLoadIdentity();
//Bind vbo and texture
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, shader.getVbo());
GL20.glEnableVertexAttribArray(0);
GL20.glVertexAttribPointer(0, 2, GL11.GL_BYTE, false, 0, 0L);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, 8);
//Render
GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, 6);
//Reset vbo and texture
GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
GL20.glDisableVertexAttribArray(0);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
//Reset view
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glPopMatrix();
}
//Stop using shader program
GL20.glUseProgram(0);
}
示例9: getUniformLocation
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
protected int getUniformLocation(final String uniformName) {
return GL20.glGetUniformLocation(programId, uniformName);
}
示例10: storeUniformLocation
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
protected void storeUniformLocation(int programID){
location = GL20.glGetUniformLocation(programID, name);
if(location == NOT_FOUND){
System.err.println("No uniform variable called \"" + name + "\" found for shader program: "+programID);
}
}
示例11: glGetUniformLocation
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
public static int glGetUniformLocation(int programObj, CharSequence name)
{
return arbShaders ? ARBShaderObjects.glGetUniformLocationARB(programObj, name) : GL20.glGetUniformLocation(programObj, name);
}
示例12: Uniform
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
public Uniform(String uniformName, int programID) {
this.uniformLocation = GL20.glGetUniformLocation(programID, uniformName);
this.programID = programID;
this.uniformName = uniformName;
}
示例13: storeUniformLocation
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
protected void storeUniformLocation(int programID){
location = GL20.glGetUniformLocation(programID, name);
if(location == NOT_FOUND){
System.err.println("No uniform variable called " + name + " found!");
}
}
示例14: storeUniformLocation
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
protected void storeUniformLocation(int programID) {
location = GL20.glGetUniformLocation(programID, name);
if (location == NOT_FOUND) {
System.err.println("No uniform variable called \"" + name + "\" found for shader program: " + programID);
}
}