當前位置: 首頁>>代碼示例>>Java>>正文


Java GL20類代碼示例

本文整理匯總了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;
}
 
開發者ID:TheThinMatrix,項目名稱:OcclusionQueries,代碼行數:25,代碼來源:ShaderProgram.java

示例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);
}
 
開發者ID:GryPLOfficial,項目名稱:EcoSystem-Official,代碼行數:18,代碼來源:ShaderProgram.java

示例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);
}
 
開發者ID:andykuo1,項目名稱:candlelight,代碼行數:26,代碼來源:Shader.java

示例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);
	}
}
 
開發者ID:andykuo1,項目名稱:candlelight,代碼行數:10,代碼來源:Program.java

示例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_);
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:12,代碼來源:OpenGlHelper.java

示例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;
}
 
開發者ID:andykuo1,項目名稱:candlelight,代碼行數:32,代碼來源:Mesh.java

示例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);
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:12,代碼來源:OpenGlHelper.java

示例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);
}
 
開發者ID:marcioz98,項目名稱:MRCEngine,代碼行數:8,代碼來源:EntityRenderer.java

示例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);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:12,代碼來源:OpenGlHelper.java

示例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);
}
 
開發者ID:SerenityEnterprises,項目名稱:SerenityCE,代碼行數:8,代碼來源:Shader.java

示例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);
		}
	}
}
 
開發者ID:andykuo1,項目名稱:candlelight,代碼行數:13,代碼來源:Mesh.java

示例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
}
 
開發者ID:DevipriyaSarkar,項目名稱:Terrain,代碼行數:10,代碼來源:Loader.java

示例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);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:12,代碼來源:OpenGlHelper.java

示例14: glLinkProgram

import org.lwjgl.opengl.GL20; //導入依賴的package包/類
public static void glLinkProgram(int program)
{
    if (arbShaders)
    {
        ARBShaderObjects.glLinkProgramARB(program);
    }
    else
    {
        GL20.glLinkProgram(program);
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:12,代碼來源:OpenGlHelper.java

示例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);
}
 
開發者ID:tek256,項目名稱:LD38,代碼行數:12,代碼來源:Quad.java


注:本文中的org.lwjgl.opengl.GL20類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。