本文整理汇总了Java中com.jogamp.opengl.GLAutoDrawable.getSurfaceWidth方法的典型用法代码示例。如果您正苦于以下问题:Java GLAutoDrawable.getSurfaceWidth方法的具体用法?Java GLAutoDrawable.getSurfaceWidth怎么用?Java GLAutoDrawable.getSurfaceWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jogamp.opengl.GLAutoDrawable
的用法示例。
在下文中一共展示了GLAutoDrawable.getSurfaceWidth方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: annotate
import com.jogamp.opengl.GLAutoDrawable; //导入方法依赖的package包/类
@Override
public void annotate(GLAutoDrawable drawable) { //shows the class in the jAER window
if ((drawable == null) || (chip.getCanvas() == null) || !classifyEvents || model == null) {
return;
}
titleRenderer = new TextRenderer(new Font("Helvetica", Font.PLAIN, 40));
Rectangle2D bounds = titleRenderer.getBounds("Unkown");
titleArea = new Rectangle((int) bounds.getWidth(), (int) bounds.getHeight());
GL2 gl = drawable.getGL().getGL2();
gl.glColor3f(1, 1, 1);
gl.glRasterPos3f(10, 10, 0);
titleRenderer.beginRendering(drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
titleRenderer.setColor(Color.WHITE);
titleRenderer.draw(String.format("Class: %d", labeledClass), titleArea.x, titleArea.y);
titleRenderer.endRendering();
gl.glPushMatrix();
gl.glLoadIdentity();
gl.glTranslatef(drawable.getSurfaceWidth() / 2, drawable.getSurfaceHeight() / 2, 0);
gl.glColor3f(1, 1, 1);
float w = drawable.getSurfaceWidth() * lastdot * 5;
gl.glRectf(0, -10, w, 10);
gl.glPopMatrix();
}
示例2: 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);
}
示例3: 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();
}
示例4: annotate
import com.jogamp.opengl.GLAutoDrawable; //导入方法依赖的package包/类
@Override
public void annotate (GLAutoDrawable drawable){
GL2 gl = drawable.getGL().getGL2();
// gl.glColor3f(1,1,1);
// gl.glRasterPos3f(10,10,0);
// glut.glutBitmapString(GLUT.BITMAP_HELVETICA_18,gender.toString());
// title
titleRenderer.beginRendering(drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
switch (gender) {
case Male:
titleRenderer.setColor(Color.RED);
break;
case Female:
titleRenderer.setColor(Color.GREEN);
break;
case Unknown:
titleRenderer.setColor(Color.WHITE);
break;
}
titleRenderer.draw(String.format("%10s %-6.2f", gender.toString(), SCALE * genderDotProduct), titleArea.width / 2, titleArea.height / 2);
titleRenderer.endRendering();
gl.glPushMatrix();
gl.glLoadIdentity();
gl.glTranslatef(drawable.getSurfaceWidth() / 2,drawable.getSurfaceHeight() / 2,0);
switch ( gender ){
case Male:
gl.glColor3f(1,0,0);
break;
case Female:
gl.glColor3f(0,1,0);
break;
case Unknown:
gl.glColor3f(1,1,1);
break;
}
float w = drawable.getSurfaceWidth() * genderDotProduct*5;
gl.glRectf(0,-10,w,10);
gl.glPopMatrix();
}
示例5: drawEventRateBars
import com.jogamp.opengl.GLAutoDrawable; //导入方法依赖的package包/类
private void drawEventRateBars(GLAutoDrawable drawable) {
if (!isEventRate()) {
return;
}
GL2 gl = drawable.getGL().getGL2();
// positioning of rate bars depends on num types and display size
ChipCanvas.Borders borders = chip.getCanvas().getBorders();
// get screen width in screen pixels, subtract borders in screen pixels to find width of drawn chip area in screen pixels
float /*h = drawable.getHeight(), */ w = drawable.getSurfaceWidth() - (2 * borders.leftRight * chip.getCanvas().getScale());
int ntypes = eventRateFilter.getNumCellTypes();
final int sx = chip.getSizeX(), sy = chip.getSizeY();
final float yorig = .9f * sy, xpos = 0, ystep = Math.max(.03f * sy, 6), barh = .03f * sy;
gl.glPushMatrix();
// gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
// gl.glLoadIdentity();
gl.glColor3f(1, 1, 1);
int font = GLUT.BITMAP_9_BY_15;
GLUT glut = chip.getCanvas().getGlut();
int nbars = eventRateFilter.isMeasureIndividualTypesEnabled() ? ntypes : 1;
for (int i = 0; i < nbars; i++) {
final float rate = eventRateFilter.getFilteredEventRate(i);
float bary = yorig - (ystep * i);
gl.glRasterPos3f(xpos, bary, 0);
String s = null;
if (eventRateFilter.isMeasureIndividualTypesEnabled()) {
s = String.format("Type %d: %10s", i, engFmt.format(rate) + " Hz");
} else {
s = String.format("All %d types: %10s", ntypes, engFmt.format(rate) + " Hz");
}
// get the string length in screen pixels , divide by chip array in screen pixels,
// and multiply by number of pixels to get string length in screen pixels.
float sw = (glut.glutBitmapLength(font, s) / w) * sx;
glut.glutBitmapString(font, s);
gl.glRectf(xpos + sw, bary + barh, xpos + sw + ((rate * sx) / getEventRateScaleMax()), bary);
}
gl.glPopMatrix();
}
示例6: 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();
}
示例7: 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");
}
示例8: draw
import com.jogamp.opengl.GLAutoDrawable; //导入方法依赖的package包/类
synchronized private void draw(GLAutoDrawable drawable) {
int n = rateSamples.size();
if ((n < 2) || ((endTimeMs - startTimeMs) == 0)) {
return;
}
GL2 gl = drawable.getGL().getGL2();
gl.glColor3f(.8f, .8f, .8f);
gl.glLineWidth(1.5f);
// draw xaxis
gl.glBegin(GL.GL_LINES);
float x0 = 0;
final int ypos = chip.getSizeY() / 3; // where graph starts along y axis of chip
gl.glVertex2f(x0, ypos);
gl.glVertex2f(chip.getSizeX(), ypos);
gl.glEnd();
// draw y axis
gl.glBegin(GL.GL_LINE_STRIP);
gl.glVertex2f(x0, ypos);
gl.glVertex2f(x0, ypos + (chip.getSizeY() * .2f));
gl.glEnd();
gl.glPushMatrix();
gl.glColor3f(1, 1, .8f);
gl.glLineWidth(1.5f);
gl.glTranslatef(0.5f, ypos, 0);
// gl.glRotatef(90, 0, 0, 1);
// gl.glRotatef(-90, 0, 0, 1);
gl.glScalef((float) (chip.getSizeX() - 1) / (endTimeMs - startTimeMs), (chip.getSizeY() * .2f) / (maxRate), 1);
gl.glBegin(GL.GL_LINE_STRIP);
for (RateSample s : rateSamples) {
gl.glVertex2f(s.time - startTimeMs, s.rate);
}
gl.glEnd();
gl.glPopMatrix();
gl.glPushMatrix();
maxRateString = String.format("max %s eps", engFmt.format(maxRate));
maxTimeString = String.format("%s s", engFmt.format((endTimeMs - startTimeMs) * .001f));
GLUT glut = chip.getCanvas().getGlut();
int font = GLUT.BITMAP_9_BY_15;
ChipCanvas.Borders borders = chip.getCanvas().getBorders();
float w = drawable.getSurfaceWidth() - (2 * borders.leftRight * chip.getCanvas().getScale());
int ntypes = eventRateFilter.getNumCellTypes();
final int sx = chip.getSizeX(), sy = chip.getSizeY();
float sw = (glut.glutBitmapLength(font, maxRateString) / w) * sx;
gl.glRasterPos3f(0, sy / 2, 0);
glut.glutBitmapString(font, maxRateString);
sw = (glut.glutBitmapLength(font, maxTimeString) / w) * sx;
gl.glRasterPos3f(sx - sw, sy * .3f, 0);
glut.glutBitmapString(font, maxTimeString);
gl.glPopMatrix();
}
示例9: 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");
}
示例10: 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);
}