本文整理匯總了Java中org.lwjgl.opengl.GL20.glUniform1f方法的典型用法代碼示例。如果您正苦於以下問題:Java GL20.glUniform1f方法的具體用法?Java GL20.glUniform1f怎麽用?Java GL20.glUniform1f使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.lwjgl.opengl.GL20
的用法示例。
在下文中一共展示了GL20.glUniform1f方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadBoolean
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
protected void loadBoolean(int location, boolean value) {
float toLoad = 0;
if(value) {
toLoad = 1;
}
GL20.glUniform1f(location, toLoad);
}
示例2: loadFloat
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
public void loadFloat(float value){
if(!used || currentValue!=value){
GL20.glUniform1f(super.getLocation(), value);
used = true;
currentValue = value;
}
}
示例3: loadBoolean
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
protected void loadBoolean(final int location, final boolean value) {
float toLoad = 0;
if (value) {
toLoad = 1;
}
GL20.glUniform1f(location, toLoad);
}
示例4: loadBoolean
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
public void loadBoolean(boolean bool){
if(!used || currentBool != bool){
GL20.glUniform1f(super.getLocation(), bool ? 1f : 0f);
used = true;
currentBool = bool;
}
}
示例5: set
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
/** Set an array or individual float(s)
*
* @param uniform name of a uniform
* @param floats float(s) to set
*/
public void set(String uniform, float...floats){
if(floats.length == 1){
GL20.glUniform1f(getUniform(uniform), floats[0]);
}else if(floats.length == 2){
GL20.glUniform2f(getUniform(uniform), floats[0], floats[1]);
}else if(floats.length == 3){
GL20.glUniform3f(getUniform(uniform), floats[0], floats[1], floats[2]);
}else if(floats.length >= 4){
GL20.glUniform4f(getUniform(uniform), floats[0], floats[1], floats[2], floats[3]);
}
}
示例6: loadBoolean
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
public void loadBoolean(boolean bool) {
if (!used || currentBool != bool) {
GL20.glUniform1f(super.getLocation(), bool ? 1f : 0f);
used = true;
currentBool = bool;
}
}
示例7: loadFloat
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
public void loadFloat(float value) {
if (!used || currentValue != value) {
GL20.glUniform1f(super.getLocation(), value);
used = true;
currentValue = value;
}
}
示例8: loadFloat
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
protected void loadFloat(int location, float value) {
GL20.glUniform1f(location, value);
}
示例9: 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);
}
示例10: loadData
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
public void loadData(boolean value) {
GL20.glUniform1f(uniformLocation, value ? 1 : 0);
}
示例11: loadData
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
public void loadData(float value) {
GL20.glUniform1f(uniformLocation, value);
}
示例12: setUniform
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
public void setUniform(String uniformName, float x)
{
GL20.glUniform1f(this.findUniformLocation(uniformName), x);
}
示例13: setUniform
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
/**
* Sets the specified uniform with the specified value
* @param uniform
* @param value The float value
*/
public void setUniform(String uniform, float value) {
GL20.glUniform1f(uniforms.get(uniform), value);
}