Java Code Examples for com.jogamp.opengl.GL3#glCreateShader()
The following examples show how to use
com.jogamp.opengl.GL3#glCreateShader() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JCudaDriverSimpleJOGL.java From jcuda-samples with MIT License | 6 votes |
/** * Initialize the shaders and the shader program * * @param gl The GL context */ private void initShaders(GL3 gl) { shaderProgramID = gl.glCreateProgram(); int vertexShaderID = gl.glCreateShader(GL_VERTEX_SHADER); gl.glShaderSource(vertexShaderID, 1, new String[]{vertexShaderSource}, null); gl.glCompileShader(vertexShaderID); gl.glAttachShader(shaderProgramID, vertexShaderID); gl.glDeleteShader(vertexShaderID); int fragmentShaderID = gl.glCreateShader(GL_FRAGMENT_SHADER); gl.glShaderSource(fragmentShaderID, 1, new String[]{fragmentShaderSource}, null); gl.glCompileShader(fragmentShaderID); gl.glAttachShader(shaderProgramID, fragmentShaderID); gl.glDeleteShader(fragmentShaderID); gl.glLinkProgram(shaderProgramID); gl.glValidateProgram(shaderProgramID); }
Example 2
Source File: NBodyVisualizer.java From gpu-nbody with MIT License | 5 votes |
/** * Creates a shader with the given type from the given file * * @param gl * @param shaderType * @param file * @return */ private int createShader(final GL3 gl, final int shaderType, final String file) { final int shaderId = gl.glCreateShader(shaderType); try { gl.glShaderSource(shaderId, 1, new String[] { readAllLines(file) }, null); gl.glCompileShader(shaderId); final IntBuffer vertexBufferCompilationStatus = Buffers.newDirectIntBuffer(1); gl.glGetShaderiv(shaderId, GL3.GL_COMPILE_STATUS, vertexBufferCompilationStatus); if (vertexBufferCompilationStatus.get(0) == GL.GL_FALSE) { final IntBuffer logLength = Buffers.newDirectIntBuffer(1); gl.glGetShaderiv(shaderId, GL3.GL_INFO_LOG_LENGTH, logLength); final ByteBuffer infoLog = Buffers.newDirectByteBuffer(logLength.get(0)); gl.glGetShaderInfoLog(shaderId, infoLog.limit(), logLength, infoLog); final byte[] infoLogArray = new byte[logLength.get(0)]; infoLog.get(infoLogArray); final String errorString = new String(infoLogArray); System.err.println(errorString); } return shaderId; } catch (final IOException e) { e.printStackTrace(); } return -1; }
Example 3
Source File: DwGeometryShader.java From PixelFlow with MIT License | 5 votes |
@Override protected void setup(){ PJOGL pjogl = (PJOGL) pgl; GL3 gl = pjogl.gl.getGL3(); glGeometry = gl.glCreateShader(GL3.GL_GEOMETRY_SHADER); gl.glShaderSource(glGeometry, src_geom.length, src_geom, (int[]) null, 0); gl.glCompileShader(glGeometry); DwGLSLShader.getShaderInfoLog(gl, glGeometry, GL3.GL_GEOMETRY_SHADER+" ("+filename_geom+")"); pgl.attachShader(glProgram, glGeometry); }