本文整理匯總了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);
}