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


Java GL20.glCreateShader方法代碼示例

本文整理匯總了Java中org.lwjgl.opengl.GL20.glCreateShader方法的典型用法代碼示例。如果您正苦於以下問題:Java GL20.glCreateShader方法的具體用法?Java GL20.glCreateShader怎麽用?Java GL20.glCreateShader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.lwjgl.opengl.GL20的用法示例。


在下文中一共展示了GL20.glCreateShader方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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,項目名稱:LowPolyWater,代碼行數:25,代碼來源:ShaderProgram.java

示例2: loadShader

import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
/**
 * reads shader from file.
 * @param file - File path
 * @param type - Shader type
 * @return - Shader ID to bind to program.
 */
private static int loadShader(String file, int type) {
    StringBuilder shaderSource = new StringBuilder();
    try {
        InputStream in = Class.class.getResourceAsStream(file);
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String line;
        while ((line = reader.readLine()) != null) {
            shaderSource.append(line).append("//\n");
        }
        reader.close();
    } catch (IOException e) {
        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!");
        System.exit(-1);
    }
    return shaderID;
}
 
開發者ID:Essentria,項目名稱:Elgin-Plant-Game,代碼行數:31,代碼來源: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: loadShader

import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
private static int loadShader(String file, int type) {
	StringBuilder shaderSource = new StringBuilder();
	try {
		InputStream in = Class.class.getResourceAsStream(file);
		BufferedReader reader = new BufferedReader(new InputStreamReader(in));
		String line;
		while ((line = reader.readLine()) != null) {
			shaderSource.append(line).append("//\n");
		}
		reader.close();
	} catch (IOException e) {
		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!");
		System.exit(-1);
	}
	return shaderID;
}
 
開發者ID:DevipriyaSarkar,項目名稱:Terrain,代碼行數:25,代碼來源:ShaderProgram.java

示例5: 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:GryPLOfficial,項目名稱:EcoSystem-Official,代碼行數:25,代碼來源:ShaderProgram.java

示例6: loadShader

import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
private static int loadShader(String filename, int type) {
	
	StringBuilder shaderSource = new StringBuilder();
	
	try {
		BufferedReader reader = new BufferedReader(new FileReader(filename));
		String line;
		while((line = reader.readLine()) != null) {
			shaderSource.append(line).append("\n");
		}
		reader.close();
	} catch (IOException e) {
		System.err.println("Could not read shader file!");
		e.printStackTrace();
		System.exit(-1);
	}
	
	int shaderID = GL20.glCreateShader(type);
	GL20.glShaderSource(shaderID, shaderSource);
	GL20.glCompileShader(shaderID);
	
	if(GL20.glGetShader(shaderID, GL20.GL_COMPILE_STATUS) == GL11.GL_FALSE) {
		System.out.println(GL20.glGetShaderInfoLog(shaderID, 500));
		System.err.println("Could not compile shader!");
		System.exit(-1);
	}
	
	return shaderID;
}
 
開發者ID:marcioz98,項目名稱:MRCEngine,代碼行數:30,代碼來源:ShaderProgram.java

示例7: createShader

import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
private int createShader(String resource, int type) {
	int shader = GL20.glCreateShader(type);
	GL20.glShaderSource(shader, resource);
	GL20.glCompileShader(shader);
	int compiled = GL20.glGetShaderi(shader, GL20.GL_COMPILE_STATUS);
	String shaderLog = GL20.glGetShaderInfoLog(shader, GL20.glGetShaderi(shader, GL20.GL_INFO_LOG_LENGTH));
	if (shaderLog.trim().length() > 0) {
		System.err.println(shaderLog);
	}
	if (compiled == 0) {
		throw new AssertionError("Could not compile shader");
	}
	return shader;
}
 
開發者ID:18107,項目名稱:MC-Ray-Tracer,代碼行數:15,代碼來源:Shader.java

示例8: addShader

import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
/**
    * Adds the specified shader part to the shader program
    * @param type The type of shader to add
    * @param fileName The full path of the shader
    * @return The shader source
    */
   private String addShader(int type, String fileName) throws IOException {
// The loaded shader source
String shaderSource = null;

// Load the file
StringBuilder builder = new StringBuilder();
BufferedReader reader = new BufferedReader(new FileReader(fileName));

// Read the file one line at a time
String line;
while((line = reader.readLine()) != null) {
    // Add the line to the source
    builder.append(line).append("\n");
}

// Release memory resources
reader.close();

// Set the shader source to the loaded file
shaderSource = builder.toString();

// The id of the shader part
int id = GL20.glCreateShader(type);

// Set the source of the shader
GL20.glShaderSource(id, shaderSource);
// Compile the shader source
GL20.glCompileShader(id);

// Check to make sure compliation was successful
closeIfShaderError(GL20.glGetShaderi(id, GL20.GL_COMPILE_STATUS) == 0, id);

// Attach the shader to the program
GL20.glAttachShader(pid, id);

return shaderSource;
   }
 
開發者ID:camilne,項目名稱:open-world,代碼行數:44,代碼來源:Shader.java

示例9: loadShader

import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
private static int loadShader(String file, int type) {
    int shaderID = GL20.glCreateShader(type);
    GL20.glShaderSource(shaderID, FileLoadUtils.loadFileSource(file));
    GL20.glCompileShader(shaderID);
    if (GL20.glGetShaderi(shaderID, GL20.GL_COMPILE_STATUS) == GL11.GL_FALSE) {
        final String glGetShaderInfoLog = GL20.glGetShaderInfoLog(shaderID, 500);
        LOGGER.error("Can not compile shader - {}", glGetShaderInfoLog);
        throw new IllegalArgumentException("Can not compile shader - " + glGetShaderInfoLog);
    }
    return shaderID;
}
 
開發者ID:Biacode,項目名稱:bia-engine,代碼行數:12,代碼來源:ShaderProgram.java

示例10: glCreateShader

import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
/**
 * creates a shader with the given mode and returns the GL id. params: mode
 */
public static int glCreateShader(int type)
{
    return arbShaders ? ARBShaderObjects.glCreateShaderObjectARB(type) : GL20.glCreateShader(type);
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:8,代碼來源:OpenGlHelper.java

示例11: loadShader

import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
/**
 * loads the current shader type into memory
 */
private int loadShader(String fileName, int type) {
	StringBuilder sb = new StringBuilder();
	Exception exception = null;
	try {
		InputStream in = Util.loadInternal(fileName);
		BufferedReader br = new BufferedReader(new InputStreamReader(in));

		String line;
		while ((line = br.readLine()) != null) {
			sb.append(line).append("\n");
		}
		br.close();
	} catch (Exception e) {
		exception = e;
		sb.append(fileName);
	}
	
	String previousString = "";
	String lastString = "";
	for (String s : sb.toString().split("\\s+")) {
		for (String s2 : s.split(";")) {
			if (lastString.equals("uniform")) {
				String uniform = s2.replace(" ", "").replace(";", "");
				uniformsDetection.add(uniform);
			}
			lastString = previousString;
			previousString = s2;
		}
	}
	
	int shaderID = GL20.glCreateShader(type);
	GL20.glShaderSource(shaderID, sb);
	GL20.glCompileShader(shaderID);
	
	if(GL20.glGetShaderi(shaderID, GL20.GL_COMPILE_STATUS) == GL11.GL_FALSE) {
		exception.printStackTrace();
		System.err.println(GL20.glGetShaderInfoLog(shaderID));
	}
	
	return shaderID;
}
 
開發者ID:ComunityEngine,項目名稱:CommunityEngine-Java,代碼行數:45,代碼來源:Shader.java


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