$ mvn -C clean install
<dependency> <groupId>com.io7m.jcanephora</groupId> <artifactId>io7m-jcanephora-core</artifactId> <version>0.61.0</version> </dependency>
<dependency> <groupId>com.io7m.jcanephora</groupId> <artifactId>io7m-jcanephora-jogl</artifactId> <version>0.61.0</version> </dependency>
Copyright © 2015 <code@io7m.com> http://io7m.com Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
void _ (GLsizei, GLuint *)
GLuint texture; glGenTextures(1, &texture); checkGLErrors();
GLuint texture; void *data = makeTextureData(); glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
public JCGLTexture2DType _( JCGLTextureUnitType _, long _, long _, JCGLTextureFormat _, JCGLTextureWrapS _, JCGLTextureWrapT _, JCGLTextureFilterMinification _, JCGLTextureFilterMagnification _) throws JCGLException;
GLContext gc_main; GLContext gc_background; JCGLImplementationJOGLType i = JCGLImplementationJOGL.getInstance(); JCGLContextType c_main = i.newContextFrom(gc_main, "main"); JCGLContextType c_back = i.newContextFrom(gc_background, "background-resources");
JCGLArrayBuffersType g; JCGLArrayBufferType a = g.arrayBufferAllocate(128, JCGLUsageHint.USAGE_STATIC_DRAW);
JCGLArrayBuffersType g; JCGLArrayBufferType a; final JCGLBufferUpdateType<JCGLArrayBufferType> u = JCGLBufferUpdates.newUpdateReplacingAll(this.array_buffer); final ByteBuffer b = u.getData(); for (int index = 0; index < 128; ++index) { b.put(index, (byte) index); } g.arrayBufferUpdate(u); g.arrayBufferUnbind();
JCGLArrayBuffersType g_ab; JCGLArrayBufferType ab; final int vertex_size = 3 * 4; ab = g_ab.arrayBufferAllocate(vertex_size * 3L, JCGLUsageHint.USAGE_STATIC_DRAW); final JCGLBufferUpdateType<JCGLArrayBufferType> u = JCGLBufferUpdates.newUpdateReplacingAll(ab); final FloatBuffer d = u.getData().asFloatBuffer(); d.put(0, -0.5f); d.put(1, 0.5f); d.put(2, -0.5f); d.put(3, -0.5f); d.put(4, -0.5f); d.put(5, -0.5f); d.put(6, 0.5f); d.put(7, -0.5f); d.put(8, -0.5f); g_ab.arrayBufferUpdate(u); g_ab.arrayBufferUnbind();
JCGLArrayObjectsType aob; final JCGLArrayObjectBuilderType aob = g_ao.arrayObjectNewBuilder(); aob.setAttributeFloatingPoint( 0, ab, 3, JCGLScalarType.TYPE_FLOAT, vertex_size, 0L, false); JCGLArrayObjectType ao = g_ao.arrayObjectAllocate(aob);
JCGLBlendingType g; g.blendingEnable( BlendFunction.BLEND_SOURCE_ALPHA, BlendFunction.BLEND_ONE_MINUS_SOURCE_ALPHA);
JCGLClearType g; final JCGLClearSpecification.Builder cb = JCGLClearSpecification.builder(); cb.setColorBufferClear(new VectorI4F(0.1f, 0.1f, 0.1f, 1.0f)); cb.setDepthBufferClear(1.0f); JCGLClearSpecification c = cb.build(); g.clear(c);
JCGLColorBufferMaskingType g; g.colorBufferMask(false, true, true, true);
JCGLDepthBuffersType g; g.depthBufferClear(1.0f);
JCGLDepthBuffersType g; g.depthBufferWriteDisable();
JCGLDepthBuffersType g; g.depthBufferTestEnable(DepthFunction.DEPTH_LESS_THAN);
JCGLDrawType g; g.drawElements(Primitives.PRIMITIVE_TRIANGLES);
JCGLFramebuffersType g; JCGLFramebufferBuilderType b = g.framebufferNewBuilder();
JCGLFramebuffersType g; List<JCGLFramebufferColorAttachmentPointType> points = g.framebufferGetColorAttachmentPoints();
JCGLFramebuffersType g; List<JCGLFramebufferDrawBufferType> buffers = g.framebufferGetDrawBuffers();
JCGLFramebuffersType g; JCGLTexturesType gt; JCGLTextureUnitType u; List<FramebufferColorAttachmentPointType> points = g.framebufferGetColorAttachmentPoints(); List<JCGLFramebufferDrawBufferType> buffers = g.framebufferGetDrawBuffers(); JCGLTexture2DType d = gt.texture2DAllocate(u, 128, 128, JCGLTextureFormat.TEXTURE_FORMAT_DEPTH_16_2BPP, ...); JCGLTexture2DType c = gt.texture2DAllocate(u, 128, 128, JCGLTextureFormat.TEXTURE_FORMAT_RGBA_8_4BPP, ...); gt.textureUnitUnbind(u); JCGLFramebufferBuilderType b = g.framebufferNewBuilder(); b.attachColorTexture2DAt(points.get(0), buffers.get(0), c); b.attachDepthTexture2D(d);
JCGLFramebuffersType g; JCGLFramebufferBuilderType b; FramebufferType f = g.framebufferAllocate(b);
JCGLFramebuffersType g; JCGLFramebufferType f; g.framebufferDrawBind(f); { // Perform rendering. } g.framebufferDrawUnbind(f);
JCGLIndexBuffersType g; JCGLIndexBufferType a = g.indexBufferAllocate(3, JCGLUnsignedType.TYPE_UNSIGNED_INT, JCGLUsageHint.USAGE_STATIC_DRAW); final JCGLBufferUpdateType<JCGLIndexBufferType> u = JCGLBufferUpdates.newUpdateReplacingAll(this.index_buffer); final IntBuffer i = u.getData().asIntBuffer(); i.put(0, 0); i.put(1, 1); i.put(2, 2); g.indexBufferUpdate(u); g.indexBufferUnbind();
JCGLPolygonModesType g; g.polygonSetMode(JCGLPolygonMode.POLYGON_LINES);
JCGLShadersType g; List<String> v_source = new ArrayList<String>(); v_source.add("#version 330\n"); v_source.add("in vec4 position;\n"); v_source.add("void\n"); v_source.add("main (void)\n"); v_source.add("{\n"); v_source.add(" gl_Position = position;\n"); v_source.add("}\n"); JCGLVertexShaderType vs = g.shaderCompileVertex("example-v", v_source); List<String> g_source = new ArrayList<String>(); g_source.add("#version 330 core\n"); g_source.add("layout(points) in;\n"); g_source.add("layout(points, max_vertices = 1) out;\n"); g_source.add("void\n"); g_source.add("main ()\n"); g_source.add("{\n"); g_source.add(" gl_Position = gl_in[0].gl_Position;\n"); g_source.add(" EmitVertex();\n"); g_source.add(" EndPrimitive();\n"); g_source.add("}\n"); JCGLGeometryShaderType gs = g.shaderCompileGeometry("example-g", g_source); List<String> f_source = new ArrayList<String>(); f_source.add("#version 330\n"); f_source.add("uniform vec4 color;\n"); f_source.add("out vec4 color0;\n"); f_source.add("void\n"); f_source.add("main (void)\n"); f_source.add("{\n"); f_source.add(" color0 = color;\n"); f_source.add("}\n"); JCGLFragmentShaderType fs = g.shaderCompileFragment("example-f", f_source);
JCGLShadersType g; JCGLProgramShaderType p = g.shaderLinkProgram("program", vs, Optional.of(gs), fs);
JCGLShadersType g; Map<String, JCGLProgramUniformType> uniforms = p.getUniforms(); JCGLProgramUniformType p = uniforms.get("color"); assert p != null; g.programActivate(p); p.programUniformPutVector4f(p, new VectorI4F(1.0f, 0.0f, 0.0f, 1.0f));
JCGLStencilBuffersType g; g.stencilBufferClear(0);
JCGLTexturesType g; List<JCGLTextureUnitType> u = g.textureGetUnits();
JCGLTexturesType g; JCGLTextureUnitType u; JCGLTexture2DType t = g.texture2DAllocate( u, 256, 256, JCGLTextureFormat.TEXTURE_FORMAT_RGBA_8_4BPP, JCGLTextureWrapS.TEXTURE_WRAP_REPEAT, JCGLTextureWrapT.TEXTURE_WRAP_REPEAT, JCGLTextureFilterMinification.TEXTURE_FILTER_NEAREST, JCGLTextureFilterMagnification.TEXTURE_FILTER_NEAREST);
in vec3 f_normal; // Eye-space surface normal in vec3 f_position; // Eye-space surface position uniform mat4 m_view_inverse; // Inverse view matrix, eye-space -> world-space. uniform samplerCube t_reflection; out vec4 frag_color; void main (void) { vec3 n = normalize (f_normal); vec3 v = normalize (f_position); vec3 r = reflect (v, n); vec3 u = m_view_inverse * r; frag_color = texture (t_reflection, u); }
in vec3 f_normal; // Eye-space surface normal in vec3 f_position; // Eye-space surface position uniform mat4 m_view_inverse; // Inverse view matrix, eye-space -> world-space. uniform samplerCube t_reflection; out vec4 frag_color; void main (void) { const mat3 m_t = mat3 ( 1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0 ); vec3 n = normalize (f_normal); vec3 v = normalize (f_position); vec3 r = reflect (v, n); vec3 u = m_view_inverse * r; vec3 w = m_t * u; frag_color = texture (t_reflection, w); }
JCGLTimersType g; JCGLTimerType t = g.timerQueryAllocate();
JCGLDrawType gd; JCGLTimersType g; JCGLTimerType t; g.timerQueryBegin(t); gd.drawElements(JCGLPrimitives.PRIMITIVE_TRIANGLES); gd.drawElements(JCGLPrimitives.PRIMITIVE_TRIANGLES); gd.drawElements(JCGLPrimitives.PRIMITIVE_TRIANGLES); g.timerQueryFinish(t);
JCGLDrawType gd; JCGLTimersType g; JCGLTimerType t; if (g.timerQueryResultIsReady(t)) { long elapsed = g.timerQueryResultGet(t); // The time to execute the three draw commands is time_end - time_start nanoseconds }
JCGLViewportsType g; AreaInclusiveUnsignedLType area = AreaInclusiveUnsignedL.of( new UnsignedRangeInclusiveL(0, 639), new UnsignedRangeInclusiveL(0, 479) ); g.viewportSet(area);