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


Java GLAutoDrawable.getSurfaceHeight方法代码示例

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


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

示例1: glTransform

import com.jogamp.opengl.GLAutoDrawable; //导入方法依赖的package包/类
public synchronized void glTransform(GLAutoDrawable drawable,GL2 gl) {

		drawableWidth = drawable.getSurfaceWidth ();
		drawableHeight= drawable.getSurfaceHeight();

		//FIXME scale better when trace is wider than high

		// move pixels to one side when traces are to be displayed
		if (showTraces) {
			if ((drawableWidth/chip.getSizeX()) > (drawableHeight/chip.getSizeY())) {
				broaderThanHigh= true;
				// draw chip canvas on the right
				gl.glTranslatef( (.4f * (drawableWidth-drawableHeight) *
					chip.getSizeY())/drawableHeight,0f,0f );
			} else {
				broaderThanHigh= false;
				// not implemented (highly unlikely)
			}
		}

		float dx= x2-x1;
		float dy= y2-y1;
		gl.glScalef(chip.getSizeX()/Math.max(dx, dy),
			chip.getSizeY()/Math.max(dx, dy),1f);
		gl.glTranslatef(currentX()-x1, currentY()-y1, 0f);
	}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:27,代码来源:OpticalFlowIntegrator.java

示例2: drawSymbolOverlay

import com.jogamp.opengl.GLAutoDrawable; //导入方法依赖的package包/类
private void drawSymbolOverlay(GLAutoDrawable drawable, int symbolID) {
    GL2 gl = drawable.getGL().getGL2();
    if (symbolTextures == null || symbolID < 0 || symbolID >= symbolTextures.length || symbolTextures[symbolID] == null) {
        return;
    }

    int left = 10, bot = 10, offset = 0;
    final int w = chip.getSizeX() / 2, h = chip.getSizeY() / 2, sw = drawable.getSurfaceWidth(), sh = drawable.getSurfaceHeight();
    if (tracker.getNumVisibleClusters() > 0) {
        Cluster hand = tracker.getVisibleClusters().getFirst();
        offset = (int) ((float) hand.getLocation().y / 5);
    }
    symbolTextures[symbolID].bind(gl);
    symbolTextures[symbolID].enable(gl);
    drawPolygon(gl, left, bot + offset, w, h);
    symbolTextures[symbolID].disable(gl);
    String s = playToWin ? "Playing to win" : "Playing to tie";
    textRenderer.setColor(.75f, 0.75f, 0.75f, 1);
    textRenderer.begin3DRendering();
    Rectangle2D r = textRenderer.getBounds(s);
    textRenderer.draw3D(s, left, bot, 0, (float) w / sw);
    textRenderer.end3DRendering();
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:24,代码来源:RoShamBoCNN.java

示例3: drawTimeScaling

import com.jogamp.opengl.GLAutoDrawable; //导入方法依赖的package包/类
private void drawTimeScaling(GLAutoDrawable drawable, float timeExpansion) {
    if (!isTimeScaling()) {
        return;
    }
    final int sx = chip.getSizeX(), sy = chip.getSizeY();
    final float yorig = .95f * sy, xpos = 0, barh = .03f * sy;
    int h = drawable.getSurfaceHeight(), w = drawable.getSurfaceWidth();
    GL2 gl = drawable.getGL().getGL2();

    gl.glPushMatrix();
    gl.glColor3f(1, 1, 1);
    GLUT glut = chip.getCanvas().getGlut();
    StringBuilder s = new StringBuilder();
    if ((timeExpansion < 1) && (timeExpansion != 0)) {
        s.append('/');
        timeExpansion = 1 / timeExpansion;
    } else {
        s.append('x');
    }
    int font = GLUT.BITMAP_9_BY_15;
    String s2 = String.format("Time factor: %10s", engFmt.format(timeExpansion) + s);

    float sw = (glut.glutBitmapLength(font, s2) / (float) w) * sx;
    gl.glRasterPos3f(0, yorig, 0);
    glut.glutBitmapString(font, s2);
    float x0 = xpos;
    float x1 = (float) (xpos + (x0 * Math.log10(timeExpansion)));
    float y0 = sy + barh;
    float y1 = y0;
    gl.glRectf(x0, y0, x1, y1);
    gl.glPopMatrix();

}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:34,代码来源:Info.java

示例4: displayPixmap

import com.jogamp.opengl.GLAutoDrawable; //导入方法依赖的package包/类
/** Displays the pixmap of pixel values.
 *
 * @param drawable
 */
synchronized private void displayPixmap(GLAutoDrawable drawable) {
	GL2 gl = drawable.getGL().getGL2();
	if (gl == null) {
		return;
	}

	checkGLError(gl, "before pixmap");
	final int wi = drawable.getSurfaceWidth(), hi = drawable.getSurfaceHeight();
	float scale = 1;
	if (fillsVertically) {// tall chip, use chip height
		scale = ((float) hi - (2 * borderPixels)) / getSizeY();
	} else if (fillsHorizontally) {
		scale = ((float) wi - (2 * borderPixels)) / getSizeX();
	}

	gl.glPixelZoom(scale, scale);
	gl.glRasterPos2f(-.5f, -.5f); // to LL corner of chip, but must be inside viewport or else it is ignored, breaks on zoom     if (zoom.isZoomEnabled() == false) {

	checkPixmapAllocation();
	{
		try {
			pixmap.rewind();
			gl.glDrawPixels(sizeX, sizeY, GL.GL_RGB, GL.GL_FLOAT, pixmap);
		} catch (IndexOutOfBoundsException e) {
			log.warning(e.toString());
		}
	}
	//        FloatBuffer minMax=FloatBuffer.allocate(6);
	//        gl.glGetMinmax(GL.GL_MINMAX, true, GL.GL_RGB, GL.GL_FLOAT, minMax);
	//        gl.glDisable(GL.GL_MINMAX);
	checkGLError(gl, "after rendering image");


	// outline frame
	gl.glColor4f(0, 0, 1f, 0f);
	gl.glLineWidth(1f);
	{
		gl.glBegin(GL.GL_LINE_LOOP);
		final float o = .5f;
		final float w = sizeX - 1;
		final float h = sizeY - 1;
		gl.glVertex2f(-o, -o);
		gl.glVertex2f(w + o, -o);
		gl.glVertex2f(w + o, h + o);
		gl.glVertex2f(-o, h + o);
		gl.glEnd();
	}
	checkGLError(gl, "after rendering frame");
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:54,代码来源:ImageDisplay.java

示例5: displayPixmap

import com.jogamp.opengl.GLAutoDrawable; //导入方法依赖的package包/类
/**
 * Displays the pixmap of pixel values.
 *
 * @param drawable
 */
synchronized private void displayPixmap(GLAutoDrawable drawable) {
    GL2 gl = drawable.getGL().getGL2();
    if (gl == null) {
        return;
    }

    checkGLError(gl, "before pixmap");
    final int wi = drawable.getSurfaceWidth(), hi = drawable.getSurfaceHeight();
    float scale = 1;
    if (fillsVertically) {// tall chip, use chip height
        scale = (hi - (2 * borderPixels)) / getSizeY();
    } else if (fillsHorizontally) {
        scale = (wi - (2 * borderPixels)) / getSizeX();
    }

    gl.glPixelZoom(scale, scale);
    //        gl.glRasterPos2f(-.5f, -.5f); // to LL corner of chip, but must be inside viewport or else it is ignored, breaks on zoom     if (zoom.isZoomEnabled() == false) {
    gl.glRasterPos2f(0, 0); // to LL corner of chip, but must be inside viewport or else it is ignored, breaks on zoom     if (zoom.isZoomEnabled() == false) {

    checkPixmapAllocation();
    {
        try {
            pixmap.rewind();
            gl.glDrawPixels(sizeX, sizeY, GL.GL_RGB, GL.GL_FLOAT, pixmap);
        } catch (IndexOutOfBoundsException e) {
            log.warning(e.toString());
        }
    }
    //        FloatBuffer minMax=FloatBuffer.allocate(6);
    //        gl.glGetMinmax(GL.GL_MINMAX, true, GL.GL_RGB, GL.GL_FLOAT, minMax);
    //        gl.glDisable(GL.GL_MINMAX);
    checkGLError(gl, "after rendering image");

    // outline frame
    gl.glColor4f(0, 0, 1f, 0f);
    gl.glLineWidth(2f);
    {
        gl.glBegin(GL.GL_LINE_LOOP);
        final float o = 0;
        final float w = sizeX;
        final float h = sizeY;
        gl.glVertex2f(-o, -o);
        gl.glVertex2f(w + o, -o);
        gl.glVertex2f(w + o, h + o);
        gl.glVertex2f(-o, h + o);
        gl.glEnd();
    }
    checkGLError(gl, "after rendering frame");
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:55,代码来源:ImageDisplay.java

示例6: grabImage

import com.jogamp.opengl.GLAutoDrawable; //导入方法依赖的package包/类
void grabImage(final GLAutoDrawable d) {
    final GL2 gl = d.getGL().getGL2();
    final int width = d.getSurfaceWidth();
    final int height = d.getSurfaceHeight();

    // Allocate a buffer for the pixels
    final ByteBuffer rgbData = Buffers.newDirectByteBuffer(width * height * 3);

    // Set up the OpenGL state.
    gl.glReadBuffer(GL.GL_FRONT);
    gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, 1);

    // Read the pixels into the ByteBuffer
    gl.glReadPixels(0, 0, width, height, GL.GL_RGB, GL.GL_UNSIGNED_BYTE, rgbData);

    // Allocate space for the converted pixels
    final int[] pixelInts = new int[width * height];

    // Convert RGB bytes to ARGB ints with no transparency. Flip
    // imageOpenGL vertically by reading the rows of pixels in the byte
    // buffer in reverse - (0,0) is at bottom left in OpenGL.
    int p = width * height * 3; // Points to first byte (red) in each row.
    int q; // Index into ByteBuffer
    int i = 0; // Index into target int[]
    final int bytesPerRow = width * 3; // Number of bytes in each row

    for (int row = height - 1; row >= 0; row--) {
        p = row * bytesPerRow;
        q = p;
        for (int col = 0; col < width; col++) {
            final int iR = rgbData.get(q++);
            final int iG = rgbData.get(q++);
            final int iB = rgbData.get(q++);

            pixelInts[i++] = ((0xFF000000) | ((iR & 0xFF) << 16) | ((iG & 0xFF) << 8) | (iB & 0xFF));
        }
    }

    // Set the data for the BufferedImage
    if ((getImageOpenGL() == null) || (getImageOpenGL().getWidth() != width)
            || (getImageOpenGL().getHeight() != height)) {
        imageOpenGL = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    }
    getImageOpenGL().setRGB(0, 0, width, height, pixelInts, 0, width);
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:46,代码来源:ChipCanvas.java


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