当前位置: 首页>>代码示例>>Java>>正文


Java GLContext.getCurrentGL方法代码示例

本文整理汇总了Java中com.jogamp.opengl.GLContext.getCurrentGL方法的典型用法代码示例。如果您正苦于以下问题:Java GLContext.getCurrentGL方法的具体用法?Java GLContext.getCurrentGL怎么用?Java GLContext.getCurrentGL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jogamp.opengl.GLContext的用法示例。


在下文中一共展示了GLContext.getCurrentGL方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: beginRendering

import com.jogamp.opengl.GLContext; //导入方法依赖的package包/类
/**
 * Starts a render cycle.
 *
 * @param ortho
 *            True to use orthographic projection
 * @param width
 *            Width of the current OpenGL viewport
 * @param height
 *            Height of the current OpenGL viewport
 * @param disableDepthTest
 *            True to ignore depth values
 * @throws GLException
 *             if no OpenGL context is current or it's an unexpected version
 * @throws IllegalArgumentException
 *             if width or height is negative
 */
private void beginRendering(final boolean ortho,
		/*@Nonnegative*/ final int width,
		/*@Nonnegative*/ final int height,
		final boolean disableDepthTest) {

	Check.argument(initialized, "Call init() method before use TextRenderer");
	Check.argument(width >= 0, "Width cannot be negative");
	Check.argument(height >= 0, "Height cannot be negative");

	// Get the current OpenGL context
	final GL gl = GLContext.getCurrentGL();

	// Make sure components are set up properly
	if (!ready) {
		glyphCache.addListener(mediator);
		glyphRenderer.addListener(mediator);
		ready = true;
	}

	// Delegate to components
	glyphCache.beginRendering(gl);
	glyphRenderer.beginRendering(gl, ortho, width, height, disableDepthTest);
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:40,代码来源:TextRenderer.java

示例2: draw3D

import com.jogamp.opengl.GLContext; //导入方法依赖的package包/类
/**
 * Draws text at a location in 3D space.
 *
 * <p>
 * Uses the renderer's current color. The baseline of the leftmost character
 * is placed at position (x, y, z) in the current coordinate system.
 *
 * @param text
 *            Text to draw
 * @param x
 *            Position to draw on X axis
 * @param y
 *            Position to draw on Y axis
 * @param z
 *            Position to draw on Z axis
 * @param scale
 *            Uniform scale applied to width and height of text
 * @throws GLException
 *             if no OpenGL context is current, or is unexpected version
 * @throws NullPointerException
 *             if text is null
 */
public void draw3D(/*@Nonnull*/ final String text,
		/*@CheckForSigned*/ float x,
		/*@CheckForSigned*/ final float y,
		/*@CheckForSigned*/ final float z,
		/*@CheckForSigned*/ final float scale) {

	Check.notNull(text, "Text cannot be null");

	// Get the current OpenGL context
	final GL gl = GLContext.getCurrentGL();

	// Get all the glyphs for the string
	final List<Glyph> glyphs = glyphProducer.createGlyphs(text);

	// Render each glyph
	for (final Glyph glyph : glyphs) {
		if (glyph.location == null) {
			glyphCache.upload(glyph);
		}
		final TextureCoords coords = glyphCache.find(glyph);
		final float advance = glyphRenderer.drawGlyph(gl, glyph, x, y, z, scale, coords);
		x += advance * scale;
	}
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:47,代码来源:TextRenderer.java

示例3: dispose

import com.jogamp.opengl.GLContext; //导入方法依赖的package包/类
/**
 * Destroys resources used by the text renderer.
 *
 * @throws GLException
 *             if no OpenGL context is current, or is unexpected version
 */
public void dispose() {

	// Get the current OpenGL context
	final GL gl = GLContext.getCurrentGL();

	// Destroy the glyph cache
	glyphCache.dispose(gl);

	// Destroy the glyph renderer
	glyphRenderer.dispose(gl);
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:18,代码来源:TextRenderer.java

示例4: endRendering

import com.jogamp.opengl.GLContext; //导入方法依赖的package包/类
/**
 * Finishes a render cycle.
 */
public void endRendering() {

	// Get the current OpenGL context
	final GL gl = GLContext.getCurrentGL();

	// Tear down components
	glyphCache.endRendering(gl);
	glyphRenderer.endRendering(gl);
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:13,代码来源:TextRenderer.java

示例5: onGlyphRendererEvent

import com.jogamp.opengl.GLContext; //导入方法依赖的package包/类
@Override
public void onGlyphRendererEvent(/*@Nonnull*/ final GlyphRenderer.EventType type) {

	Check.notNull(type, "Event type cannot be null");

	switch (type) {
	case AUTOMATIC_FLUSH:
		final GL gl = GLContext.getCurrentGL();
		glyphCache.update(gl);
		break;
	}
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:13,代码来源:TextRenderer.java

示例6: writeToTargaFile

import com.jogamp.opengl.GLContext; //导入方法依赖的package包/类
/**
 * Takes a fast screenshot of the current OpenGL drawable to a Targa
 * file. Requires the OpenGL context for the desired drawable to be
 * current. Takes the screenshot from the last assigned read buffer,
 * or the OpenGL default read buffer if none has been specified by
 * the user (GL_FRONT for single-buffered configurations and GL_BACK
 * for double-buffered configurations). This is the fastest
 * mechanism for taking a screenshot of an application. Contributed
 * by Carsten Weisse of Bytonic Software (http://bytonic.de/).
 *
 * @param file the file to write containing the screenshot
 * @param x the starting x coordinate of the screenshot, measured from the lower-left
 * @param y the starting y coordinate of the screenshot, measured from the lower-left
 * @param width the width of the desired screenshot area
 * @param height the height of the desired screenshot area
 * @param alpha whether the alpha channel should be saved. If true,
 *   requires GL_EXT_abgr extension to be present.
 *
 * @throws GLException if an OpenGL context was not current or
 *   another OpenGL-related error occurred
 * @throws IOException if an I/O error occurred while writing the
 *   file
 */
public static void writeToTargaFile(File file,
                                    int x,
                                    int y,
                                    int width,
                                    int height,
                                    boolean alpha) throws GLException, IOException {
    if (alpha) {
        checkExtABGR();
    }

    TGAWriter writer = new TGAWriter();
    writer.open(file, width, height, alpha);
    ByteBuffer bgr = writer.getImageData();

    GL gl = GLContext.getCurrentGL();

    // Set up pixel storage modes
    GLPixelStorageModes psm = new GLPixelStorageModes();
    psm.setPackAlignment(gl, 1);

    int readbackType = (alpha ? GL2.GL_ABGR_EXT : GL2GL3.GL_BGR);

    // read the BGR values into the image buffer
    gl.glReadPixels(x, y, width, height, readbackType,
            GL.GL_UNSIGNED_BYTE, bgr);

    // Restore pixel storage modes
    psm.restore(gl);

    // close the file
    writer.close();
}
 
开发者ID:madebyjeffrey,项目名称:TerraJ,代码行数:56,代码来源:Screenshot.java

示例7: checkExtABGR

import com.jogamp.opengl.GLContext; //导入方法依赖的package包/类
private static void checkExtABGR() {
    GL gl = GLContext.getCurrentGL();

    if (!gl.isExtensionAvailable(GLExtensions.EXT_abgr)) {
        throw new IllegalArgumentException("Saving alpha channel requires GL_EXT_abgr");
    }
}
 
开发者ID:madebyjeffrey,项目名称:TerraJ,代码行数:8,代码来源:Screenshot.java

示例8: flush

import com.jogamp.opengl.GLContext; //导入方法依赖的package包/类
/**
 * Forces all stored text to be rendered.
 *
 * <p>
 * This should be called after each call to {@code draw} if you are setting
 * OpenGL state such as the modelview matrix between calls to {@code draw}.
 *
 * @throws GLException
 *             if no OpenGL context is current, or is unexpected version
 * @throws IllegalStateException
 *             if not in a render cycle
 */
public void flush() {

	// Get the current OpenGL context
	final GL gl = GLContext.getCurrentGL();

	// Make sure glyph cache is up to date
	glyphCache.update(gl);

	// Render outstanding glyphs
	glyphRenderer.flush(gl);
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:24,代码来源:TextRenderer.java

示例9: newTexture

import com.jogamp.opengl.GLContext; //导入方法依赖的package包/类
/**
 * Creates an OpenGL texture object from the specified file using
 * the current OpenGL context.
 *
 * @param file the file from which to read the texture data
 * @param mipmap     whether mipmaps should be produced for this
 *                   texture either by autogenerating them or
 *                   reading them from the file. Some file formats
 *                   support multiple mipmaps in a single file in
 *                   which case those mipmaps will be used rather
 *                   than generating them.
 * @throws IOException if an error occurred while reading the file
 * @throws GLException if no OpenGL context is current or if an
 *                     OpenGL error occurred
 */
public static Texture newTexture(final File file, final boolean mipmap) throws IOException, GLException {
    final GL gl = GLContext.getCurrentGL();
    final GLProfile glp = gl.getGLProfile();
    final TextureData data = newTextureData(glp, file, mipmap, IOUtil.getFileSuffix(file));
    final Texture texture = newTexture(gl, data);
    data.flush();
    return texture;
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:24,代码来源:TextureIO.java

示例10: deleteBackingStore

import com.jogamp.opengl.GLContext; //导入方法依赖的package包/类
/**
 * Disposes of a backing store.
 *
 * <p>
 * Happens immediately before a backing store needs to be expanded, since the manager will
 * actually make a new one.
 *
 * @param bs Backing store being deleted
 * @throws NullPointerException if backing store is null
 * @throws ClassCastException if backing store is not a {@code TextureBackingStore}
 */
@Override
public void deleteBackingStore(/*@Nonnull*/ final Object bs) {

    Check.notNull(bs, "Backing store cannot be null");

    // Dispose the backing store
    final GL gl = GLContext.getCurrentGL();
    final TextureBackingStore tbs = (TextureBackingStore) bs;
    tbs.dispose(gl);
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:22,代码来源:TextureBackingStoreManager.java


注:本文中的com.jogamp.opengl.GLContext.getCurrentGL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。