本文整理汇总了Java中com.jogamp.opengl.GLException类的典型用法代码示例。如果您正苦于以下问题:Java GLException类的具体用法?Java GLException怎么用?Java GLException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GLException类属于com.jogamp.opengl包,在下文中一共展示了GLException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: display
import com.jogamp.opengl.GLException; //导入依赖的package包/类
/** Called when the canvas is updated. To update the display, call either
* <code>repaint()</code> or <code>display()</code>.
* @param drawable the Open GL context.
*/
@Override
public synchronized void display(GLAutoDrawable drawable) {
GL2 gl = getGL().getGL2();
if (reshapePending) {
reshapePending = false;
reshape(drawable, 0, 0, getWidth(), getHeight());
}
try {
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
displayPixmap(drawable);
drawText(gl);
gl.glFlush();
} catch (GLException e) {
log.warning(e.toString());
}
}
示例2: annotate
import com.jogamp.opengl.GLException; //导入依赖的package包/类
@Override
public void annotate(final GLAutoDrawable drawable) {
if (!showHotPixels) {
return;
}
final GL2 gl = drawable.getGL().getGL2();
try {
gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
gl.glBlendEquation(GL.GL_FUNC_ADD);
}
catch (final GLException e) {
e.printStackTrace();
showHotPixels = false;
}
gl.glColor4f(.1f, .1f, 1f, .25f);
gl.glLineWidth(1f);
for (final HotPixel p : hotPixelSet) {
gl.glRectf(p.x - 1, p.y - 1, p.x + 2, p.y + 2);
}
}
示例3: checkBlend
import com.jogamp.opengl.GLException; //导入依赖的package包/类
/** Convenience method to check if blending in OpenGL is available, and if so, to turn it on.
*
* @param gl the GL2 context
*/
protected void checkBlend(GL2 gl) {
if (!hasBlendChecked) {
hasBlendChecked = true;
String glExt = gl.glGetString(GL.GL_EXTENSIONS);
if (glExt.indexOf("GL_EXT_blend_color") != -1) {
hasBlend = true;
}
}
if (hasBlend) {
try {
gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE);
gl.glBlendEquation(GL.GL_FUNC_ADD);
} catch (GLException e) {
log.warning("tried to use glBlend which is supposed to be available but got following exception");
gl.glDisable(GL.GL_BLEND);
e.printStackTrace();
hasBlend = false;
}
}
}
示例4: ImageDisplay
import com.jogamp.opengl.GLException; //导入依赖的package包/类
/**
* Creates a new ImageDisplay, given some Open GL capabilities.
*
* @param caps the capabilities desired. See factory method.
* @see #createOpenGLCanvas() for factory method with predefined
* capabilities.
*/
public ImageDisplay(GLCapabilitiesImmutable caps) {
super(caps);
setLocale(java.util.Locale.US); // to avoid problems with other language support in JOGL
// this.setSize(300,200);
setVisible(true);
addGLEventListener(this);
try {
if (JAERViewer.sharedDrawable != null) {
setSharedContext(JAERViewer.sharedDrawable.getContext());
}
} catch (GLException e) {
log.warning("While trying to set the shared context to the JAERViewer.sharedDrawable context, caught exception: " + e.toString());
}
}
示例5: display
import com.jogamp.opengl.GLException; //导入依赖的package包/类
/**
* Called when the canvas is updated. To update the display, call either
* <code>repaint()</code> or <code>display()</code>.
*
* @param drawable the Open GL context.
*/
@Override
public synchronized void display(GLAutoDrawable drawable) {
GL2 gl = getGL().getGL2();
// gl.getContext().makeCurrent();
checkGLError(gl, "before display in ID");
if (reshapePending) {
reshapePending = false;
reshape(drawable, 0, 0, getWidth(), getHeight());
}
try {
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
displayPixmap(drawable);
drawText(gl);
gl.glFlush();
} catch (GLException e) {
log.warning(e.toString());
}
checkGLError(gl, "after setDefaultProjection in ID");
}
示例6: paintFrame
import com.jogamp.opengl.GLException; //导入依赖的package包/类
/**
* Used for active rendering. You call this when you want to actively render
* the frame. Internally, this calls the display() method of the drawable,
* which by callback to display(GLAutoDrawable). If openGL is disabled, then
* it calls paint() directly.
*
* @see #display(com.jogamp.opengl.GLAutoDrawable)
*/
public void paintFrame() {
// synchronized (drawable.getTreeLock()) {
try {
// drawable.getContext().makeCurrent();
drawable.display(); // we call the drawable's display method that ends up calling us back via our local
// display(GLAutoDrawable)!! very important to get this right
} catch (final GLException e) {
if (!(e.getCause() instanceof InterruptedException)) {
log.warning(e.toString());
}
} catch (final RuntimeException ie) {
if (!(ie.getCause() instanceof InterruptedException)) {
log.warning(ie.toString());
}
} finally {
// drawable.getContext().release();
}
// }
}
示例7: init
import com.jogamp.opengl.GLException; //导入依赖的package包/类
@Override
public void init(GLAutoDrawable drawable) {
VoxelMatrix voxelMatrix = displayable.getMatrix();
if (voxelMatrix == null) {
throw new GLException("Could not load the volume data");
}
dirtyValues = TRACKED_FLAGS;
highLOD = true;
GL2 gl2 = drawable.getGL().getGL2();
loadVertices(gl2);
loadTexture(gl2, voxelMatrix);
loadFrameBuffers(gl2);
loadPrograms(gl2);
loadRaycastingInitialUniforms(gl2, voxelMatrix);
loadMainInitialUniforms(gl2, voxelMatrix);
}
示例8: loadAndCompileShader
import com.jogamp.opengl.GLException; //导入依赖的package包/类
private void loadAndCompileShader(String codeFile, int location, int type, GL2 gl2) throws GLException {
String[] shaderCode = new String[1];
StringBuilder codeBuilder = new StringBuilder();
codeFile += type == GL2.GL_VERTEX_SHADER ? ".vp" : ".fp";
try (BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(SHADERS_ROOT + codeFile)))) {
String line;
while ((line = reader.readLine()) != null) {
codeBuilder.append(line);
codeBuilder.append('\n');
}
} catch (IOException ex) {
Logger.getLogger(VolumeRenderer.class.getName()).log(Level.SEVERE, null, ex);
}
shaderCode[0] = codeBuilder.toString();
if (shaderCode[0] == null || shaderCode[0].isEmpty()) {
throw new GLException("Could not read shader");
}
int shader = gl2.glCreateShader(type);
gl2.glShaderSource(shader, 1, shaderCode, new int[]{shaderCode[0].length()}, 0);
gl2.glCompileShader(shader);
shaderLocation[location] = shader;
checkCompile(gl2, shader, codeFile);
checkError(gl2, "Load and compile shader");
}
示例9: update
import com.jogamp.opengl.GLException; //导入依赖的package包/类
public static void update(GL2 gl) {
if (first) {
first = false;
Log.info("GLInfo > Version string: " + gl.glGetString(GL2.GL_VERSION));
// Log.debug("GLInfo > Extensions: " + gl.glGetString(GL2.GL_EXTENSIONS));
if (!gl.isExtensionAvailable("GL_VERSION_2_1")) {
String err = "OpenGL 2.1 not supported. JHelioviewer is not able to run.";
Log.error("GLInfo > " + err);
if (1 == JOptionPane.showOptionDialog(null, err, "Fatal Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, crashOptions, crashOptions[0]))
throw new GLException(err);
else
System.exit(-1);
}
int[] out = { 0 };
gl.glGetIntegerv(GL2.GL_MAX_TEXTURE_SIZE, out, 0);
maxTextureSize = out[0];
// Log.debug("GLInfo > max texture size: " + out[0]);
} else
Log.debug("GLInfo.update()");
}
示例10: initializeTexture
import com.jogamp.opengl.GLException; //导入依赖的package包/类
private Texture initializeTexture(GL2 gl) {
tileAtlas = null;
try {
tileAtlas = TextureIO.newTexture(new FileInputStream("Resources/DFfont.png"),false,".png");
tileAtlas.setTexParameteri(gl, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_POINT);
tileAtlas.setTexParameteri(gl, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_POINT);
tileAtlas.setTexParameteri(gl, GL2.GL_TEXTURE_WRAP_S, GL2.GL_CLAMP_TO_EDGE);
tileAtlas.setTexParameteri(gl, GL2.GL_TEXTURE_WRAP_T, GL2.GL_CLAMP_TO_EDGE);
} catch (IOException | GLException ex) {
//Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
}
return tileAtlas;
}
示例11: load
import com.jogamp.opengl.GLException; //导入依赖的package包/类
void load(GL2 gl) {
if (aTexture == null && !cannotBeLoaded && !aReady && aTexFile != null)
try {
aTexture = TextureIO.newTexture(aTexFile, false);
aTexture.setTexParameteri(gl, GL2.GL_TEXTURE_WRAP_S, GL2.GL_REPEAT);
aTexture.setTexParameteri(gl, GL2.GL_TEXTURE_WRAP_T, GL2.GL_REPEAT);
aReady = true;
} catch (IOException e) {
cannotBeLoaded = true;
aReady = false;
System.err.println("Die Datei " + aTexFile.getName() + " konnte nicht "
+ "korrekt geladen werden. Prüfen Sie die weiteren " + "Fehlermeldungen.");
e.printStackTrace();
} catch (GLException gle) {
gle.printStackTrace();
}
}
示例12: checkShader
import com.jogamp.opengl.GLException; //导入依赖的package包/类
/**
* Check a shader for errors.
* <p>
* Call this method on a compiled shader.
* @param gl the OpenGL interface
* @param shader the ID of the shader to check
*/
private static void checkShader(@Nonnull GL2 gl, int shader) {
IntBuffer intBuffer = IntBuffer.allocate(1);
gl.glGetShaderiv(shader, GL2.GL_COMPILE_STATUS, intBuffer);
if (intBuffer.get(0) == GL.GL_FALSE) {
gl.glGetShaderiv(shader, GL2.GL_INFO_LOG_LENGTH, intBuffer);
int length = intBuffer.get(0);
String out = null;
if (length > 0) {
ByteBuffer infoLog = Buffers.newDirectByteBuffer(length);
gl.glGetShaderInfoLog(shader, infoLog.limit(), intBuffer, infoLog);
byte[] infoBytes = new byte[length];
infoLog.get(infoBytes);
try {
out = new String(infoBytes, "UTF-8");
}
catch (UnsupportedEncodingException e) {
throw new GLException("Error during shader compilation");
}
}
throw new GLException("Error during shader compilation:\n" + out);
}
}
示例13: checkProgram
import com.jogamp.opengl.GLException; //导入依赖的package包/类
/**
* Check the program for errors.
* <p>
* Call this after a shader has been linked into the program.
* @param gl the OpenGL interface
*/
private void checkProgram(@Nonnull GL2 gl) {
IntBuffer intBuffer = IntBuffer.allocate(1);
gl.glGetProgramiv(id, GL2.GL_LINK_STATUS, intBuffer);
if (intBuffer.get(0) == GL.GL_FALSE) {
gl.glGetProgramiv(id, GL2.GL_INFO_LOG_LENGTH, intBuffer);
int length = intBuffer.get(0);
String out = null;
if (length > 0) {
ByteBuffer infoLog = Buffers.newDirectByteBuffer(length);
gl.glGetProgramInfoLog(id, infoLog.limit(), intBuffer, infoLog);
byte[] infoBytes = new byte[length];
infoLog.get(infoBytes);
try {
out = new String(infoBytes, "UTF-8");
}
catch (UnsupportedEncodingException e) {
throw new GLException("Error during program link");
}
}
throw new GLException("Error during program link:\n" + out);
}
}
示例14: getFontTexture
import com.jogamp.opengl.GLException; //导入依赖的package包/类
public Texture getFontTexture(String textureName) {
if (textureMap.containsKey(textureName)) {
return textureMap.get(textureName);
}
else {
String absolutePathToFontTextureFolder = this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath()
+ "res" + File.separator + "font" + File.separator;
String fontImage = absolutePathToFontTextureFolder + textureName + ".png";
Texture fontTexture = null;
try {
fontTexture = TextureIO.newTexture(new File(fontImage), false);
} catch (GLException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
textureMap.put(textureName, fontTexture);
return fontTexture;
}
}
示例15: loadShader
import com.jogamp.opengl.GLException; //导入依赖的package包/类
/**
* Loads a shader from a string.
*
* @param gl Current OpenGL context, assumed not null
* @param source Source code of the shader as one long string, assumed not null or empty
* @param type Type of shader, assumed valid
* @return OpenGL handle to the shader, not negative
* @throws GLException if a GLSL-capable context is not active or could not compile shader
*/
/*@Nonnegative*/
private static int loadShader(/*@Nonnull*/ final GL2ES2 gl,
/*@Nonnull*/ final String source,
final int type) {
// Create and read source
final int shader = gl.glCreateShader(type);
gl.glShaderSource(
shader, // shader handle
1, // number of strings
new String[] { source }, // array of strings
null); // lengths of strings
// Compile
gl.glCompileShader(shader);
if (!isShaderCompiled(gl, shader)) {
final String log = ShaderUtil.getShaderInfoLog(gl, shader);
throw new GLException(log);
}
return shader;
}