当前位置: 首页>>代码示例>>Java>>正文


Java GL20.glUniform1i方法代码示例

本文整理汇总了Java中org.lwjgl.opengl.GL20.glUniform1i方法的典型用法代码示例。如果您正苦于以下问题:Java GL20.glUniform1i方法的具体用法?Java GL20.glUniform1i怎么用?Java GL20.glUniform1i使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.lwjgl.opengl.GL20的用法示例。


在下文中一共展示了GL20.glUniform1i方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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);
}
 
开发者ID:18107,项目名称:MC-Ray-Tracer,代码行数:30,代码来源:WorldLoader.java

示例2: loadTexUnit

import org.lwjgl.opengl.GL20; //导入方法依赖的package包/类
public void loadTexUnit(int texUnit) {
	if (!used || currentValue != texUnit) {
		GL20.glUniform1i(super.getLocation(), texUnit);
		used = true;
		currentValue = texUnit;
	}
}
 
开发者ID:TheThinMatrix,项目名称:LowPolyWater,代码行数:8,代码来源:UniformSampler.java

示例3: glUniform1i

import org.lwjgl.opengl.GL20; //导入方法依赖的package包/类
public static void glUniform1i(int location, int v0)
{
    if (arbShaders)
    {
        ARBShaderObjects.glUniform1iARB(location, v0);
    }
    else
    {
        GL20.glUniform1i(location, v0);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:12,代码来源:OpenGlHelper.java

示例4: setSampler2d

import org.lwjgl.opengl.GL20; //导入方法依赖的package包/类
public void setSampler2d(String label, int value, int activeTexture){
    int loc = getUniform(label);
    GL20.glUniform1i(loc, 0);
    GL13.glActiveTexture(GL13.GL_TEXTURE0 + activeTexture);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, value);
}
 
开发者ID:SerenityEnterprises,项目名称:SerenityCE,代码行数:8,代码来源:Shader.java

示例5: apply

import org.lwjgl.opengl.GL20; //导入方法依赖的package包/类
@Override
public void apply(Program program, Texture value)
{
	int location = program.findUniformLocation(this.getName());
	GL20.glUniform1i(location, this.sampler);
	GL13.glActiveTexture(GL13.GL_TEXTURE0 + this.sampler);
	value.bind();
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:9,代码来源:PropertyTexture.java

示例6: loadInt

import org.lwjgl.opengl.GL20; //导入方法依赖的package包/类
protected void loadInt(int location, int value) {
	GL20.glUniform1i(location, value);
}
 
开发者ID:marcioz98,项目名称:MRCEngine,代码行数:4,代码来源:ShaderProgram.java

示例7: 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);
}
 
开发者ID:18107,项目名称:MC-Ray-Tracer,代码行数:81,代码来源:RenderUtil.java

示例8: setInteger

import org.lwjgl.opengl.GL20; //导入方法依赖的package包/类
public void setInteger(String label, int value){
    // Sets the value.
    GL20.glUniform1i(getUniform(label), value);
}
 
开发者ID:SerenityEnterprises,项目名称:SerenityCE,代码行数:5,代码来源:Shader.java

示例9: loadData

import org.lwjgl.opengl.GL20; //导入方法依赖的package包/类
public void loadData(int value) {
    GL20.glUniform1i(uniformLocation, value);
}
 
开发者ID:Essentria,项目名称:Elgin-Plant-Game,代码行数:4,代码来源:Uniform1i.java

示例10: apply

import org.lwjgl.opengl.GL20; //导入方法依赖的package包/类
@Override
public void apply(Program program, Boolean value)
{
	int location = program.findUniformLocation(this.getName());
	GL20.glUniform1i(location, value ? 1 : 0);
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:7,代码来源:PropertyBool.java

示例11: apply

import org.lwjgl.opengl.GL20; //导入方法依赖的package包/类
@Override
public void apply(Program program, Integer value)
{
	int location = program.findUniformLocation(this.getName());
	GL20.glUniform1i(location, value);
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:7,代码来源:PropertyInt.java

示例12: renderWorld

import org.lwjgl.opengl.GL20; //导入方法依赖的package包/类
/**
 * Render the world.
 * Called between {@link net.minecraft.client.renderer.EntityRenderer#renderWorld(float, long) renderWorld}
 * and {@link net.minecraft.client.renderer.EntityRenderer#renderWorldPass(int, float, long) renderWorldPass}
 */
public void renderWorld(EntityRenderer er, Minecraft mc, Framebuffer framebuffer, Shader shader,
		int[] framebufferTextures, float partialTicks, long finishTimeNano, int width, int height, float sizeIncrease) {
	//save the players state
	player = mc.getRenderViewEntity();
	yaw = player.rotationYaw;
	pitch = player.rotationPitch;
	prevYaw = player.prevRotationYaw;
	prevPitch = player.prevRotationPitch;

	//clear the primary framebuffer
	mc.getFramebuffer().framebufferClear();
	//clear the secondary framebuffer
	framebuffer.framebufferClear();
	//bind the secondary framebuffer
	framebuffer.bindFramebuffer(false);

	//displayWidth and displayHeight are called during world rendering
	//set them to the secondary framebuffer dimensions
	mc.displayWidth = (int)(height*sizeIncrease);
	mc.displayHeight = (int)(height*sizeIncrease); //Must be square

	RenderUtil.partialWidth = mc.displayWidth; //TODO is this even needed?
	RenderUtil.partialHeight = mc.displayHeight; //TODO remove

	RenderUtil.render360 = true;

	Globe globe = globes[globeIndex];
	for (int i=0; i<globe.getCount(); i++) {
		// set camera/player rotation state (read by hooks at the correct moment)
		coordFrame = globe.getCoordFrame(i);
		playerFov = globe.getFov(i);

		// the forward vector is the opposite direction of the z-axis
		float x = -coordFrame.get(2);
		float y = -coordFrame.get(6);
		float z = -coordFrame.get(10);

		// calculate the delta yaw/pitch to point the player
		float lon = (float)Math.atan2(x, -z);
		float lat = (float)Math.atan2(y, Math.sqrt(x*x+z*z));
		playerDeltaYaw = lon;
		playerDeltaPitch = lat;

		// render to texture
		OpenGlHelper.glFramebufferTexture2D(OpenGlHelper.GL_FRAMEBUFFER, OpenGlHelper.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, framebufferTextures[i], 0);
		GlStateManager.bindTexture(0);
		er.renderWorldPass(2, partialTicks, finishTimeNano);

		// reset player view
		player.rotationYaw = yaw;
		player.rotationPitch = pitch;
		player.prevRotationYaw = prevYaw;
		player.prevRotationPitch = prevPitch;
	}

	//reset displayWidth and displayHeight to the primary framebuffer dimensions
	mc.displayWidth = width;
	mc.displayHeight = height;

	//reset viewport to full screen
	GlStateManager.viewport(0, 0, width, height);
	//bind primary framebuffer
	mc.getFramebuffer().bindFramebuffer(false);

	if (!getResizeGui() || mc.gameSettings.hideGUI) {
		GL20.glUseProgram(shader.getShaderProgram());
		int cursorUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "drawCursor");
		GL20.glUniform1i(cursorUniform, 0);
		runShader(mc, shader, framebufferTextures);
	}
}
 
开发者ID:shaunlebron,项目名称:flex-fov,代码行数:77,代码来源:RenderMethod.java

示例13: setUniform

import org.lwjgl.opengl.GL20; //导入方法依赖的package包/类
/**
    * Sets the specified uniform with the specified value
    * @param uniform
    * @param value The integer value
    */
   public void setUniform(String uniform, int value) {
GL20.glUniform1i(uniforms.get(uniform), value);
   }
 
开发者ID:camilne,项目名称:open-world,代码行数:9,代码来源:Shader.java

示例14: set

import org.lwjgl.opengl.GL20; //导入方法依赖的package包/类
/**Set a boolean value on the shader
 * 
 * @param uniform name of the uniform
 * @param value the value of the boolean
 */
public void set(String uniform, boolean value){
	GL20.glUniform1i(getUniform(uniform), value ? 1 : 0);
}
 
开发者ID:tek256,项目名称:LD38,代码行数:9,代码来源:Shader.java


注:本文中的org.lwjgl.opengl.GL20.glUniform1i方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。