本文整理汇总了Java中org.lwjgl.opengl.GL20.glAttachShader方法的典型用法代码示例。如果您正苦于以下问题:Java GL20.glAttachShader方法的具体用法?Java GL20.glAttachShader怎么用?Java GL20.glAttachShader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.lwjgl.opengl.GL20
的用法示例。
在下文中一共展示了GL20.glAttachShader方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: ShaderProgram
import org.lwjgl.opengl.GL20; //导入方法依赖的package包/类
/**
* @param shaders list of shaders to use in program
*/
public ShaderProgram(Shader ... shaders) {
id = GL20.glCreateProgram();
this.shaders = shaders;
// Attach shaders
for (Shader shader : shaders) {
GL20.glAttachShader(id, shader.id);
}
// Link
GL20.glLinkProgram(id);
if (GL20.glGetProgrami(id, GL20.GL_LINK_STATUS) == GL11.GL_FALSE) {
throw new Error("Failed to link shader program.");
}
// Validate
GL20.glValidateProgram(id);
if (GL20.glGetProgrami(id, GL20.GL_VALIDATE_STATUS) == GL11.GL_FALSE) {
throw new Error("Failed to validate shader program.");
}
}
示例3: 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);
}
示例4: ShaderProgram
import org.lwjgl.opengl.GL20; //导入方法依赖的package包/类
public ShaderProgram(String vertexFile, String fragmentFile) {
vertexShaderID = loadShader(vertexFile, GL20.GL_VERTEX_SHADER);
fragmentShaderID = loadShader(fragmentFile, GL20.GL_FRAGMENT_SHADER);
programID = GL20.glCreateProgram();
GL20.glAttachShader(programID, vertexShaderID);
GL20.glAttachShader(programID, fragmentShaderID);
bindAttributes();
GL20.glLinkProgram(programID);
GL20.glValidateProgram(programID);
getAllUniformLocations();
}
示例5: ShaderProgram
import org.lwjgl.opengl.GL20; //导入方法依赖的package包/类
public ShaderProgram(MyFile vertexFile, MyFile fragmentFile, String... inVariables) {
int vertexShaderID = loadShader(vertexFile, GL20.GL_VERTEX_SHADER);
int fragmentShaderID = loadShader(fragmentFile, GL20.GL_FRAGMENT_SHADER);
programID = GL20.glCreateProgram();
GL20.glAttachShader(programID, vertexShaderID);
GL20.glAttachShader(programID, fragmentShaderID);
bindAttributes(inVariables);
GL20.glLinkProgram(programID);
GL20.glDetachShader(programID, vertexShaderID);
GL20.glDetachShader(programID, fragmentShaderID);
GL20.glDeleteShader(vertexShaderID);
GL20.glDeleteShader(fragmentShaderID);
}
示例6: 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;
}
示例7: ShaderProgram
import org.lwjgl.opengl.GL20; //导入方法依赖的package包/类
public ShaderProgram(final String vertexFile, final String fragmentFle) {
LOGGER.debug("Initializing shader program for vertex - {} and fragment - {}", vertexFile, fragmentFle);
vertShaderId = loadShader(vertexFile, GL20.GL_VERTEX_SHADER);
fragShaderId = loadShader(fragmentFle, GL20.GL_FRAGMENT_SHADER);
programId = GL20.glCreateProgram();
GL20.glAttachShader(programId, vertShaderId);
GL20.glAttachShader(programId, fragShaderId);
bindAttributes();
GL20.glLinkProgram(programId);
GL20.glValidateProgram(programId);
LOGGER.debug("Initialized shader - {} vertex - {} fragment - {}", programId, vertShaderId, fragShaderId);
getAllUniformLocations();
}
示例8: glAttachShader
import org.lwjgl.opengl.GL20; //导入方法依赖的package包/类
public static void glAttachShader(int program, int shaderIn)
{
if (arbShaders)
{
ARBShaderObjects.glAttachObjectARB(program, shaderIn);
}
else
{
GL20.glAttachShader(program, shaderIn);
}
}
示例9: ShaderProgram
import org.lwjgl.opengl.GL20; //导入方法依赖的package包/类
/**
* Loads shader files and binds them the this program.
* @param vertexFile - Vertex Shader location
* @param fragmentFile - Fragment Shader location
*/
public ShaderProgram(String vertexFile, String fragmentFile) {
vertexShaderID = loadShader(vertexFile, GL20.GL_VERTEX_SHADER);
fragmentShaderID = loadShader(fragmentFile, GL20.GL_FRAGMENT_SHADER);
programID = GL20.glCreateProgram();
GL20.glAttachShader(programID, vertexShaderID);
GL20.glAttachShader(programID, fragmentShaderID);
bindAttributes();
GL20.glLinkProgram(programID);
GL20.glValidateProgram(programID);
initUniforms();
}
示例10: createShaderProgram
import org.lwjgl.opengl.GL20; //导入方法依赖的package包/类
public void createShaderProgram(RenderMethod renderMethod) {
shaderProgram = GL20.glCreateProgram();
vshader = createShader(vertexShader, GL20.GL_VERTEX_SHADER);
fshader = createShader(renderMethod.getFragmentShader(), GL20.GL_FRAGMENT_SHADER);
GL20.glAttachShader(shaderProgram, vshader);
GL20.glAttachShader(shaderProgram, fshader);
GL20.glBindAttribLocation(shaderProgram, 0, "vertex");
GL30.glBindFragDataLocation(shaderProgram, 0, "color");
GL20.glLinkProgram(shaderProgram);
int linked = GL20.glGetProgrami(shaderProgram, GL20.GL_LINK_STATUS);
String programLog = GL20.glGetProgramInfoLog(shaderProgram, GL20.glGetProgrami(shaderProgram, GL20.GL_INFO_LOG_LENGTH));
if (programLog.trim().length() > 0) {
System.err.println(programLog);
}
if (linked == 0) {
throw new AssertionError("Could not link program");
}
//init vbo
vbo = GL15.glGenBuffers();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);
ByteBuffer bb = BufferUtils.createByteBuffer(2 * 6);
bb.put((byte) -1).put((byte) -1);
bb.put((byte) 1).put((byte) -1);
bb.put((byte) 1).put((byte) 1);
bb.put((byte) 1).put((byte) 1);
bb.put((byte) -1).put((byte) 1);
bb.put((byte) -1).put((byte) -1);
bb.flip();
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, bb, GL15.GL_STATIC_DRAW);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
}
示例11: createProgram
import org.lwjgl.opengl.GL20; //导入方法依赖的package包/类
private void createProgram() {
program = GL20.glCreateProgram();
GL20.glAttachShader(program, vertex);
GL20.glAttachShader(program, fragment);
}