use of com.jogamp.opengl.GL2GL3 in project artisynth_core by artisynth.
the class GLShaderProgram method dispose.
@Override
public void dispose(GL gl) {
GL2GL3 gl23 = (GL2GL3) gl;
gl23.glDeleteProgram(id);
id = 0;
}
use of com.jogamp.opengl.GL2GL3 in project artisynth_core by artisynth.
the class GLOcclusionSelector method processSelection.
@Override
public void processSelection(GL gl) {
if (myTotalMaxQ == 0) {
super.processSelection(gl);
return;
}
// finish remaining queries
flushQueries((GL2GL3) gl);
// re-enable depth buffer
myViewer.setDepthEnabled(savedDepth);
if (myGLQueryTotal == 0) {
// then no queries were issued, so nothing to do ...
myViewer.setSelected(null);
} else {
int qid = 0;
LinkedList<HitRecord> records = new LinkedList<HitRecord>();
Iterator<IsRenderable> it = myViewer.renderIterator();
while (it.hasNext()) {
IsRenderable r = it.next();
if (r instanceof IsSelectable) {
IsSelectable s = (IsSelectable) r;
int numq = s.numSelectionQueriesNeeded();
int nums = (numq >= 0 ? numq : 1);
if (s.isSelectable()) {
for (int i = 0; i < nums; i++) {
if (myQuerySamples[qid + i] > 0) {
HitRecord rec = new HitRecord(myQuerySamples[qid + i]);
if (numq < 0) {
rec.objs.add(s);
} else {
s.getSelection(rec.objs, i);
}
if (rec.objs.size() > 0) {
records.add(rec);
}
}
}
}
qid += nums;
}
}
Collections.sort(records);
ArrayList<LinkedList<?>> selObjs = new ArrayList<>(records.size());
for (int i = 0; i < records.size(); i++) {
selObjs.add(records.get(i).objs);
}
myViewer.setSelected(selObjs);
}
// delete queries
((GL2GL3) myGl).glDeleteQueries(myGLQueries.length, myGLQueries, 0);
myGLQueries = null;
myGLQueryIds = null;
super.processSelection(gl);
}
use of com.jogamp.opengl.GL2GL3 in project artisynth_core by artisynth.
the class GLRenderBuffer method configure.
public void configure(GL gl, int width, int height, int format, int nsamples) {
bind(gl);
if (this.width != width || this.height != height || this.format != format || this.nsamples != nsamples) {
// Create secondary FBO
if (nsamples > 1 && (gl.isGL2GL3())) {
GL2GL3 gl23 = (GL2GL3) gl;
gl23.glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, nsamples, format, width, height);
} else {
gl.glRenderbufferStorage(GL.GL_RENDERBUFFER, format, width, height);
}
this.width = width;
this.format = format;
this.height = height;
this.nsamples = nsamples;
}
}
use of com.jogamp.opengl.GL2GL3 in project artisynth_core by artisynth.
the class FrameBufferObject method getPixels.
public ByteBuffer getPixels(GL gl, int format) {
// 4 bytes per RGBA pixel
int size = width * height * 4;
ByteBuffer pixels = BufferUtilities.newNativeByteBuffer(size);
if (numMultiSamples > 1 && gl.isGL2GL3()) {
GL2GL3 gl23 = (GL2GL3) gl;
// System.out.println ("blitting");
// read from multisample, write to single sample
gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, FBOhandle);
gl.glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, FBNhandle);
// Blit the multisampled FBO to the normal FBO
gl23.glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, GL.GL_COLOR_BUFFER_BIT, GL.GL_LINEAR);
// Bind the normal FBO for reading
gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, FBNhandle);
} else {
gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, FBOhandle);
}
gl.glReadPixels(0, 0, width, height, format, GL.GL_UNSIGNED_BYTE, pixels);
// GLSupport.showImage(pixels, width, height);
// rebind as draw
gl.glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, FBOhandle);
return pixels;
}
use of com.jogamp.opengl.GL2GL3 in project artisynth_core by artisynth.
the class GL3PipelineRenderer method unbind.
@Override
protected void unbind(GL gl) {
GL2GL3 gl3 = (GL2GL3) gl;
gl3.glBindVertexArray(0);
}
Aggregations