本文整理汇总了Java中net.minecraft.client.renderer.OpenGlHelper.glShaderSource方法的典型用法代码示例。如果您正苦于以下问题:Java OpenGlHelper.glShaderSource方法的具体用法?Java OpenGlHelper.glShaderSource怎么用?Java OpenGlHelper.glShaderSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.client.renderer.OpenGlHelper
的用法示例。
在下文中一共展示了OpenGlHelper.glShaderSource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadShader
import net.minecraft.client.renderer.OpenGlHelper; //导入方法依赖的package包/类
public static ShaderLoader loadShader(IResourceManager resourceManager, ShaderLoader.ShaderType type, String filename) throws IOException
{
ShaderLoader shaderloader = (ShaderLoader)type.getLoadedShaders().get(filename);
if (shaderloader == null)
{
ResourceLocation resourcelocation = new ResourceLocation("shaders/program/" + filename + type.getShaderExtension());
BufferedInputStream bufferedinputstream = new BufferedInputStream(resourceManager.getResource(resourcelocation).getInputStream());
byte[] abyte = toByteArray(bufferedinputstream);
ByteBuffer bytebuffer = BufferUtils.createByteBuffer(abyte.length);
bytebuffer.put(abyte);
bytebuffer.position(0);
int i = OpenGlHelper.glCreateShader(type.getShaderMode());
OpenGlHelper.glShaderSource(i, bytebuffer);
OpenGlHelper.glCompileShader(i);
if (OpenGlHelper.glGetShaderi(i, OpenGlHelper.GL_COMPILE_STATUS) == 0)
{
String s = StringUtils.trim(OpenGlHelper.glGetShaderInfoLog(i, 32768));
JsonException jsonexception = new JsonException("Couldn\'t compile " + type.getShaderName() + " program: " + s);
jsonexception.func_151381_b(resourcelocation.getResourcePath());
throw jsonexception;
}
shaderloader = new ShaderLoader(type, i, filename);
type.getLoadedShaders().put(filename, shaderloader);
}
return shaderloader;
}
示例2: loadShader
import net.minecraft.client.renderer.OpenGlHelper; //导入方法依赖的package包/类
public static ShaderLoader loadShader(IResourceManager resourceManager, ShaderLoader.ShaderType type, String filename) throws IOException
{
ShaderLoader shaderloader = (ShaderLoader)type.getLoadedShaders().get(filename);
if (shaderloader == null)
{
ResourceLocation resourcelocation = new ResourceLocation("shaders/program/" + filename + type.getShaderExtension());
IResource iresource = resourceManager.getResource(resourcelocation);
try
{
byte[] abyte = IOUtils.toByteArray((InputStream)(new BufferedInputStream(iresource.getInputStream())));
ByteBuffer bytebuffer = BufferUtils.createByteBuffer(abyte.length);
bytebuffer.put(abyte);
bytebuffer.position(0);
int i = OpenGlHelper.glCreateShader(type.getShaderMode());
OpenGlHelper.glShaderSource(i, bytebuffer);
OpenGlHelper.glCompileShader(i);
if (OpenGlHelper.glGetShaderi(i, OpenGlHelper.GL_COMPILE_STATUS) == 0)
{
String s = StringUtils.trim(OpenGlHelper.glGetShaderInfoLog(i, 32768));
JsonException jsonexception = new JsonException("Couldn\'t compile " + type.getShaderName() + " program: " + s);
jsonexception.setFilenameAndFlush(resourcelocation.getResourcePath());
throw jsonexception;
}
shaderloader = new ShaderLoader(type, i, filename);
type.getLoadedShaders().put(filename, shaderloader);
}
finally
{
IOUtils.closeQuietly((Closeable)iresource);
}
}
return shaderloader;
}