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


Java GLContext类代码示例

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


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

示例1: dispose

import com.jogamp.opengl.GLContext; //导入依赖的package包/类
/**
 * Disposes this texture name. When practical, this method should be called
 * explicitly. Otherwise, it will be called when this object is finalized
 * during garbage collection.
 */
public synchronized void dispose() {
  if (_context!=null) {
    GLContext current = GLContext.getCurrent();
    if (_context==current ||
        _context.makeCurrent()==GLContext.CONTEXT_CURRENT) {
      try {
        //System.out.println("dispose: deleting name="+_name);
        int[] names = {_name};
        glDeleteTextures(1,names,0);
      } finally {
        if (_context!=current) {
          _context.release();
          current.makeCurrent();
        }
      }
    }
    _context = null;
    _name = 0;
  }
}
 
开发者ID:MinesJTK,项目名称:jtk,代码行数:26,代码来源:GlTextureName.java

示例2: dispose

import com.jogamp.opengl.GLContext; //导入依赖的package包/类
/**
 * Disposes this display list. When practical, this method should be called
 * explicitly. Otherwise, it will be called when this object is finalized
 * during garbage collection.
 */
public synchronized void dispose() {
  if (_context!=null) {
    GLContext current = GLContext.getCurrent();
    if (_context==current ||
        _context.makeCurrent()==GLContext.CONTEXT_CURRENT) {
      try {
        glDeleteLists(_list,_range);
      } finally {
        if (_context!=current) {
          _context.release();
          current.makeCurrent();
        }
      }
    }
    _context = null;
    _list = 0;
    _range = 0;
  }
}
 
开发者ID:MinesJTK,项目名称:jtk,代码行数:25,代码来源:GlDisplayList.java

示例3: main

import com.jogamp.opengl.GLContext; //导入依赖的package包/类
public static void main(String[] args) {

        Display display = NewtFactory.createDisplay(null);
        Screen screen = NewtFactory.createScreen(display, 0);
        GLProfile glProfile = GLProfile.get(GLProfile.GL3);
        GLCapabilities glCapabilities = new GLCapabilities(glProfile);
        glWindow = GLWindow.create(screen, glCapabilities);

        glWindow.setSize(1044, 768);
        glWindow.setPosition(100, 50);
        glWindow.setUndecorated(false);
        glWindow.setAlwaysOnTop(false);
        glWindow.setFullscreen(false);
        glWindow.setPointerVisible(true);
        glWindow.confinePointer(false);
        glWindow.setTitle("Tutorial 09 - Interpolation");
        glWindow.setContextCreationFlags(GLContext.CTX_OPTION_DEBUG);
        glWindow.setVisible(true);

        Tutorial09 tutorial09 = new Tutorial09();
        glWindow.addGLEventListener(tutorial09);

        animator = new Animator(glWindow);
        animator.start();
    }
 
开发者ID:java-opengl-labs,项目名称:ogl-dev,代码行数:26,代码来源:Tutorial09.java

示例4: main

import com.jogamp.opengl.GLContext; //导入依赖的package包/类
public static void main(String[] args) {

        Display display = NewtFactory.createDisplay(null);
        Screen screen = NewtFactory.createScreen(display, 0);
        GLProfile glProfile = GLProfile.get(GLProfile.GL3);
        GLCapabilities glCapabilities = new GLCapabilities(glProfile);
        glWindow = GLWindow.create(screen, glCapabilities);

        glWindow.setSize(1044, 768);
        glWindow.setPosition(100, 50);
        glWindow.setUndecorated(false);
        glWindow.setAlwaysOnTop(false);
        glWindow.setFullscreen(false);
        glWindow.setPointerVisible(true);
        glWindow.confinePointer(false);
        glWindow.setTitle("Tutorial 05 - Uniform Variables");
        glWindow.setContextCreationFlags(GLContext.CTX_OPTION_DEBUG);
        glWindow.setVisible(true);

        Tutorial05 tutorial05 = new Tutorial05();
        glWindow.addGLEventListener(tutorial05);

        animator = new Animator(glWindow);
        animator.start();
    }
 
开发者ID:java-opengl-labs,项目名称:ogl-dev,代码行数:26,代码来源:Tutorial05.java

示例5: main

import com.jogamp.opengl.GLContext; //导入依赖的package包/类
public static void main(String[] args) {

        Display display = NewtFactory.createDisplay(null);
        Screen screen = NewtFactory.createScreen(display, 0);
        GLProfile glProfile = GLProfile.get(GLProfile.GL3);
        GLCapabilities glCapabilities = new GLCapabilities(glProfile);
        glWindow = GLWindow.create(screen, glCapabilities);

        glWindow.setSize(1034, 768);
        glWindow.setPosition(100, 50);
        glWindow.setUndecorated(false);
        glWindow.setAlwaysOnTop(false);
        glWindow.setFullscreen(false);
        glWindow.setPointerVisible(true);
        glWindow.confinePointer(false);
        glWindow.setTitle("Tutorial 03 - First triangle");
        glWindow.setContextCreationFlags(GLContext.CTX_OPTION_DEBUG);
        glWindow.setVisible(true);

        Tutorial03 tutorial03 = new Tutorial03();
        glWindow.addGLEventListener(tutorial03);

        animator = new Animator(glWindow);
        animator.start();
    }
 
开发者ID:java-opengl-labs,项目名称:ogl-dev,代码行数:26,代码来源:Tutorial03.java

示例6: main

import com.jogamp.opengl.GLContext; //导入依赖的package包/类
public static void main(String[] args) {

        Display display = NewtFactory.createDisplay(null);
        Screen screen = NewtFactory.createScreen(display, 0);
        GLProfile glProfile = GLProfile.get(GLProfile.GL3);
        GLCapabilities glCapabilities = new GLCapabilities(glProfile);
        glWindow = GLWindow.create(screen, glCapabilities);

        glWindow.setSize(1044, 768);
        glWindow.setPosition(100, 50);
        glWindow.setUndecorated(false);
        glWindow.setAlwaysOnTop(false);
        glWindow.setFullscreen(false);
        glWindow.setPointerVisible(true);
        glWindow.confinePointer(false);
        glWindow.setTitle("Tutorial 08 - Scaling Transformation");
        glWindow.setContextCreationFlags(GLContext.CTX_OPTION_DEBUG);
        glWindow.setVisible(true);

        Tutorial08 tutorial08 = new Tutorial08();
        glWindow.addGLEventListener(tutorial08);

        animator = new Animator(glWindow);
        animator.start();
    }
 
开发者ID:java-opengl-labs,项目名称:ogl-dev,代码行数:26,代码来源:Tutorial08.java

示例7: main

import com.jogamp.opengl.GLContext; //导入依赖的package包/类
public static void main(String[] args) {

        Display display = NewtFactory.createDisplay(null);
        Screen screen = NewtFactory.createScreen(display, 0);
        GLProfile glProfile = GLProfile.get(GLProfile.GL3);
        GLCapabilities glCapabilities = new GLCapabilities(glProfile);
        glWindow = GLWindow.create(screen, glCapabilities);

        glWindow.setSize(1044, 768);
        glWindow.setPosition(100, 50);
        glWindow.setUndecorated(false);
        glWindow.setAlwaysOnTop(false);
        glWindow.setFullscreen(false);
        glWindow.setPointerVisible(true);
        glWindow.confinePointer(false);
        glWindow.setTitle("Tutorial 04 - Shaders");
        glWindow.setContextCreationFlags(GLContext.CTX_OPTION_DEBUG);
        glWindow.setVisible(true);

        Tutorial04 tutorial04 = new Tutorial04();
        glWindow.addGLEventListener(tutorial04);

        animator = new Animator(glWindow);
        animator.start();
    }
 
开发者ID:java-opengl-labs,项目名称:ogl-dev,代码行数:26,代码来源:Tutorial04.java

示例8: main

import com.jogamp.opengl.GLContext; //导入依赖的package包/类
public static void main(String[] args) {

        Display display = NewtFactory.createDisplay(null);
        Screen screen = NewtFactory.createScreen(display, 0);
        GLProfile glProfile = GLProfile.get(GLProfile.GL3);
        GLCapabilities glCapabilities = new GLCapabilities(glProfile);
        glWindow = GLWindow.create(screen, glCapabilities);

        glWindow.setSize(1044, 768);
        glWindow.setPosition(100, 50);
        glWindow.setUndecorated(false);
        glWindow.setAlwaysOnTop(false);
        glWindow.setFullscreen(false);
        glWindow.setPointerVisible(true);
        glWindow.confinePointer(false);
        glWindow.setTitle("Tutorial 06 - Translation Transformation");
        glWindow.setContextCreationFlags(GLContext.CTX_OPTION_DEBUG);
        glWindow.setVisible(true);

        Tutorial06 tutorial06 = new Tutorial06();
        glWindow.addGLEventListener(tutorial06);

        animator = new Animator(glWindow);
        animator.start();
    }
 
开发者ID:java-opengl-labs,项目名称:ogl-dev,代码行数:26,代码来源:Tutorial06.java

示例9: main

import com.jogamp.opengl.GLContext; //导入依赖的package包/类
public static void main(String[] args) {

        Display display = NewtFactory.createDisplay(null);
        Screen screen = NewtFactory.createScreen(display, 0);
        GLProfile glProfile = GLProfile.get(GLProfile.GL3);
        GLCapabilities glCapabilities = new GLCapabilities(glProfile);
        glWindow = GLWindow.create(screen, glCapabilities);

        glWindow.setSize(1024, 768);
        glWindow.setPosition(100, 50);
        glWindow.setUndecorated(false);
        glWindow.setAlwaysOnTop(false);
        glWindow.setFullscreen(false);
        glWindow.setPointerVisible(true);
        glWindow.confinePointer(false);
        glWindow.setTitle("Tutorial 02 -  Hello Dot");
        glWindow.setContextCreationFlags(GLContext.CTX_OPTION_DEBUG);
        glWindow.setVisible(true);

        Tutorial02 tutorial02 = new Tutorial02();
        glWindow.addGLEventListener(tutorial02);

        animator = new Animator(glWindow);
        animator.start();
    }
 
开发者ID:java-opengl-labs,项目名称:ogl-dev,代码行数:26,代码来源:Tutorial02.java

示例10: main

import com.jogamp.opengl.GLContext; //导入依赖的package包/类
public static void main(String[] args) {

        Display display = NewtFactory.createDisplay(null);
        Screen screen = NewtFactory.createScreen(display, 0);
        GLProfile glProfile = GLProfile.get(GLProfile.GL3);
        GLCapabilities glCapabilities = new GLCapabilities(glProfile);
        glWindow = GLWindow.create(screen, glCapabilities);

        glWindow.setSize(1024, 768);
        glWindow.setPosition(100, 50);
        glWindow.setUndecorated(false);
        glWindow.setAlwaysOnTop(false);
        glWindow.setFullscreen(false);
        glWindow.setPointerVisible(true);
        glWindow.confinePointer(false);
        glWindow.setTitle("Tutorial 01 - Open a window");
        glWindow.setContextCreationFlags(GLContext.CTX_OPTION_DEBUG);
        glWindow.setVisible(true);

        Tutorial01 tutorial01 = new Tutorial01();
        glWindow.addGLEventListener(tutorial01);

        animator = new Animator(glWindow);
        animator.start();
    }
 
开发者ID:java-opengl-labs,项目名称:ogl-dev,代码行数:26,代码来源:Tutorial01.java

示例11: main

import com.jogamp.opengl.GLContext; //导入依赖的package包/类
public static void main(String[] args) {

        Display display = NewtFactory.createDisplay(null);
        Screen screen = NewtFactory.createScreen(display, 0);
        GLProfile glProfile = GLProfile.get(GLProfile.GL3);
        GLCapabilities glCapabilities = new GLCapabilities(glProfile);
        glWindow = GLWindow.create(screen, glCapabilities);

        glWindow.setSize(1044, 768);
        glWindow.setPosition(100, 50);
        glWindow.setUndecorated(false);
        glWindow.setAlwaysOnTop(false);
        glWindow.setFullscreen(false);
        glWindow.setPointerVisible(true);
        glWindow.confinePointer(false);
        glWindow.setTitle("Tutorial 07 - Rotation Transformation");
        glWindow.setContextCreationFlags(GLContext.CTX_OPTION_DEBUG);
        glWindow.setVisible(true);

        Tutorial07 tutorial07 = new Tutorial07();
        glWindow.addGLEventListener(tutorial07);

        animator = new Animator(glWindow);
        animator.start();
    }
 
开发者ID:java-opengl-labs,项目名称:ogl-dev,代码行数:26,代码来源:Tutorial07.java

示例12: main

import com.jogamp.opengl.GLContext; //导入依赖的package包/类
public static void main(String[] args) {

        Display display = NewtFactory.createDisplay(null);
        Screen screen = NewtFactory.createScreen(display, 0);
        GLProfile glProfile = GLProfile.get(GLProfile.GL3);
        GLCapabilities glCapabilities = new GLCapabilities(glProfile);
        glWindow = GLWindow.create(screen, glCapabilities);

        glWindow.setSize(1044, 768);
        glWindow.setPosition(100, 50);
        glWindow.setUndecorated(false);
        glWindow.setAlwaysOnTop(false);
        glWindow.setFullscreen(false);
        glWindow.setPointerVisible(true);
        glWindow.confinePointer(false);
        glWindow.setTitle("Tutorial10 - Indexed Draws");
        glWindow.setContextCreationFlags(GLContext.CTX_OPTION_DEBUG);
        glWindow.setVisible(true);

        Tutorial10 tutorial10 = new Tutorial10();
        glWindow.addGLEventListener(tutorial10);

        animator = new Animator(glWindow);
        animator.start();
    }
 
开发者ID:java-opengl-labs,项目名称:ogl-dev,代码行数:26,代码来源:Tutorial10.java

示例13: PipelinedQuadRenderer

import com.jogamp.opengl.GLContext; //导入依赖的package包/类
public PipelinedQuadRenderer() {
	final GL2 gl = GLContext.getCurrentGL().getGL2();
	mVertCoords = Buffers.newDirectFloatBuffer(kTotalBufferSizeCoordsVerts);
	mTexCoords = Buffers.newDirectFloatBuffer(kTotalBufferSizeCoordsTex);

	try {
		final int[] vbos = new int[2];
		gl.glGenBuffers(2, IntBuffer.wrap(vbos));

		mVBO_For_ResuableTileVertices = vbos[0];
		mVBO_For_ResuableTileTexCoords = vbos[1];

		gl.glBindBuffer(GL.GL_ARRAY_BUFFER,
				mVBO_For_ResuableTileVertices);
		gl.glBufferData(GL.GL_ARRAY_BUFFER, kTotalBufferSizeBytesVerts,
				null, GL2ES2.GL_STREAM_DRAW); // stream draw because this is a single quad use pipeline

		gl.glBindBuffer(GL.GL_ARRAY_BUFFER,
				mVBO_For_ResuableTileTexCoords);
		gl.glBufferData(GL.GL_ARRAY_BUFFER, kTotalBufferSizeBytesTex,
				null, GL2ES2.GL_STREAM_DRAW); // stream draw because this is a single quad use pipeline
	} catch (final Exception e) {
		usingVBOs = false;
	}
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:26,代码来源:PipelinedQuadRenderer.java

示例14: 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

示例15: 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


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