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


Java GL20.glUseProgram方法代码示例

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


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

示例1: destroy

import org.lwjgl.opengl.GL20; //导入方法依赖的package包/类
/**
 * Cleanup
 */
public void destroy() {
	GL20.glUseProgram(0);

	// Delete the shaders
	for (Shader shader : shaders) {
		GL20.glDetachShader(id, shader.id);
		shader.destroy();
	}

	// Delete the program
	GL20.glDeleteProgram(id);
}
 
开发者ID:tacocat,项目名称:lambda,代码行数:16,代码来源:ShaderProgram.java

示例2: glUseProgram

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

示例3: start

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

示例4: stop

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

示例5: 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

示例6: unbind

import org.lwjgl.opengl.GL20; //导入方法依赖的package包/类
/**
    * Unbinds this shader
    */
   public void unbind() {
GL20.glUseProgram(0);
   }
 
开发者ID:camilne,项目名称:open-world,代码行数:7,代码来源:Shader.java

示例7: cleanUp

import org.lwjgl.opengl.GL20; //导入方法依赖的package包/类
public void cleanUp() {
	GL20.glUseProgram(0);
	GL20.glDeleteProgram(programID);
}
 
开发者ID:TheThinMatrix,项目名称:LowPolyWater,代码行数:5,代码来源:ShaderProgram.java

示例8: bind

import org.lwjgl.opengl.GL20; //导入方法依赖的package包/类
/**
 * Used to activate the current shader
 */
public void bind() {
	GL20.glUseProgram(program);
}
 
开发者ID:ComunityEngine,项目名称:CommunityEngine-Java,代码行数:7,代码来源:Shader.java

示例9: stop

import org.lwjgl.opengl.GL20; //导入方法依赖的package包/类
public void stop() {
    GL20.glUseProgram(0);
}
 
开发者ID:GryPLOfficial,项目名称:EcoSystem-Official,代码行数:4,代码来源:ShaderProgram.java

示例10: start

import org.lwjgl.opengl.GL20; //导入方法依赖的package包/类
/**
 * Starts shader program.
 */
public void start() {
    GL20.glUseProgram(programID);
}
 
开发者ID:Essentria,项目名称:Elgin-Plant-Game,代码行数:7,代码来源:ShaderProgram.java

示例11: start

import org.lwjgl.opengl.GL20; //导入方法依赖的package包/类
public void start() {
    GL20.glUseProgram(programID);
}
 
开发者ID:GryPLOfficial,项目名称:EcoSystem-Official,代码行数:4,代码来源:ShaderProgram.java


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