本文整理汇总了Java中org.lwjgl.opengl.GL20类的典型用法代码示例。如果您正苦于以下问题:Java GL20类的具体用法?Java GL20怎么用?Java GL20使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GL20类属于org.lwjgl.opengl包,在下文中一共展示了GL20类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadShader
import org.lwjgl.opengl.GL20; //导入依赖的package包/类
private int loadShader(MyFile file, int type) {
StringBuilder shaderSource = new StringBuilder();
try {
BufferedReader reader = file.getReader();
String line;
while ((line = reader.readLine()) != null) {
shaderSource.append(line).append("//\n");
}
reader.close();
} catch (Exception e) {
System.err.println("Could not read file.");
e.printStackTrace();
System.exit(-1);
}
int shaderID = GL20.glCreateShader(type);
GL20.glShaderSource(shaderID, shaderSource);
GL20.glCompileShader(shaderID);
if (GL20.glGetShaderi(shaderID, GL20.GL_COMPILE_STATUS) == GL11.GL_FALSE) {
System.out.println(GL20.glGetShaderInfoLog(shaderID, 500));
System.err.println("Could not compile shader "+ file);
System.exit(-1);
}
return shaderID;
}
示例2: ShaderProgram
import org.lwjgl.opengl.GL20; //导入依赖的package包/类
public ShaderProgram(MyFile vertexFile, MyFile geometryFile, MyFile fragmentFile, String... inVariables) {
int vertexShaderID = loadShader(vertexFile, GL20.GL_VERTEX_SHADER);
int geometryShaderID = loadShader(geometryFile, GL32.GL_GEOMETRY_SHADER);
int fragmentShaderID = loadShader(fragmentFile, GL20.GL_FRAGMENT_SHADER);
programID = GL20.glCreateProgram();
GL20.glAttachShader(programID, vertexShaderID);
GL20.glAttachShader(programID, geometryShaderID);
GL20.glAttachShader(programID, fragmentShaderID);
bindAttributes(inVariables);
GL20.glLinkProgram(programID);
GL20.glDetachShader(programID, vertexShaderID);
GL20.glDetachShader(programID, geometryShaderID);
GL20.glDetachShader(programID, fragmentShaderID);
GL20.glDeleteShader(vertexShaderID);
GL20.glDeleteShader(geometryShaderID);
GL20.glDeleteShader(fragmentShaderID);
}
示例3: Shader
import org.lwjgl.opengl.GL20; //导入依赖的package包/类
public Shader(String source, int type)
{
this.type = type;
this.handle = GL20.glCreateShader(this.type);
if (this.handle == 0)
{
throw new GLException("Unable to create main.shader!");
}
GL20.glShaderSource(this.handle, source);
GL20.glCompileShader(this.handle);
int status = GL20.glGetShaderi(this.handle, GL20.GL_COMPILE_STATUS);
if (status == GL11.GL_FALSE)
{
String infolog = GL20.glGetShaderInfoLog(this.handle);
GL20.glDeleteShader(this.handle);
this.handle = 0;
throw new GLException(infolog);
}
SHADERS.add(this);
}
示例4: setUniform
import org.lwjgl.opengl.GL20; //导入依赖的package包/类
public void setUniform(String uniformName, Matrix4fc matrix)
{
try (MemoryStack stack = MemoryStack.stackPush())
{
FloatBuffer fb = stack.mallocFloat(16);
matrix.get(fb);
GL20.glUniformMatrix4fv(this.findUniformLocation(uniformName), false, fb);
}
}
示例5: glDeleteShader
import org.lwjgl.opengl.GL20; //导入依赖的package包/类
public static void glDeleteShader(int p_153180_0_)
{
if (arbShaders)
{
ARBShaderObjects.glDeleteObjectARB(p_153180_0_);
}
else
{
GL20.glDeleteShader(p_153180_0_);
}
}
示例6: setVertexArrayBuffer
import org.lwjgl.opengl.GL20; //导入依赖的package包/类
public Mesh setVertexArrayBuffer(int location, int size, int stride, VBO buffer)
{
GL30.glBindVertexArray(this.handle);
buffer.bind();
GL20.glVertexAttribPointer(location, size, buffer.getType(), buffer.isNormalized(), stride, 0);
if (this.vertexBuffers.length <= location)
{
this.vertexBuffers = Arrays.copyOf(this.vertexBuffers, location + 1);
}
VBO vbo = this.vertexBuffers[location];
if (vbo != null)
{
try
{
vbo.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
this.vertexBuffers[location] = buffer;
buffer.unbind();
GL30.glBindVertexArray(0);
return this;
}
示例7: glUniformMatrix2
import org.lwjgl.opengl.GL20; //导入依赖的package包/类
public static void glUniformMatrix2(int location, boolean transpose, FloatBuffer matrices)
{
if (arbShaders)
{
ARBShaderObjects.glUniformMatrix2ARB(location, transpose, matrices);
}
else
{
GL20.glUniformMatrix2(location, transpose, matrices);
}
}
示例8: unbindTexturedModel
import org.lwjgl.opengl.GL20; //导入依赖的package包/类
private void unbindTexturedModel() {
MasterRenderer.enableCulling();
GL20.glDisableVertexAttribArray(0);
GL20.glDisableVertexAttribArray(1);
GL20.glDisableVertexAttribArray(2);
GL30.glBindVertexArray(0);
}
示例9: glUniform3
import org.lwjgl.opengl.GL20; //导入依赖的package包/类
public static void glUniform3(int location, IntBuffer values)
{
if (arbShaders)
{
ARBShaderObjects.glUniform3ARB(location, values);
}
else
{
GL20.glUniform3(location, values);
}
}
示例10: setSampler2d
import org.lwjgl.opengl.GL20; //导入依赖的package包/类
public void setSampler2d(String label, int value){
int loc = getUniform(label);
GL20.glUniform1i(loc, 0);
GL13.glActiveTexture(GL13.GL_TEXTURE0);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, value);
}
示例11: bind
import org.lwjgl.opengl.GL20; //导入依赖的package包/类
public void bind()
{
GL30.glBindVertexArray(this.handle);
for(int i = 0; i < this.vertexBuffers.length; ++i)
{
if (this.vertexBuffers[i] != null)
{
GL20.glEnableVertexAttribArray(i);
}
}
}
示例12: storeDataInAttributeList
import org.lwjgl.opengl.GL20; //导入依赖的package包/类
private void storeDataInAttributeList(int attributeNumber, int coordinateSize, float[] data) {
int vboID = GL15.glGenBuffers();
vbos.add(vboID);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboID);
FloatBuffer buffer = storeDataInFloatBuffer(data);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW); // store data in the buffer - static data after it is stored in VBO
GL20.glVertexAttribPointer(attributeNumber, coordinateSize, GL11.GL_FLOAT, false, 0, 0); // store into the VAO
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); // un-bind VBO
}
示例13: glShaderSource
import org.lwjgl.opengl.GL20; //导入依赖的package包/类
public static void glShaderSource(int shaderIn, ByteBuffer string)
{
if (arbShaders)
{
ARBShaderObjects.glShaderSourceARB(shaderIn, string);
}
else
{
GL20.glShaderSource(shaderIn, string);
}
}
示例14: glLinkProgram
import org.lwjgl.opengl.GL20; //导入依赖的package包/类
public static void glLinkProgram(int program)
{
if (arbShaders)
{
ARBShaderObjects.glLinkProgramARB(program);
}
else
{
GL20.glLinkProgram(program);
}
}
示例15: draw
import org.lwjgl.opengl.GL20; //导入依赖的package包/类
public void draw(){
GL30.glBindVertexArray(vao);
GL20.glEnableVertexAttribArray(0);
GL20.glEnableVertexAttribArray(1);
GL11.glDrawElements(GL11.GL_TRIANGLES, 6, GL11.GL_UNSIGNED_INT, 0);
GL20.glDisableVertexAttribArray(0);
GL20.glDisableVertexAttribArray(1);
GL30.glBindVertexArray(vao);
}