本文整理汇总了Java中com.jogamp.opengl.GL2.glScalef方法的典型用法代码示例。如果您正苦于以下问题:Java GL2.glScalef方法的具体用法?Java GL2.glScalef怎么用?Java GL2.glScalef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jogamp.opengl.GL2
的用法示例。
在下文中一共展示了GL2.glScalef方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: glTransform
import com.jogamp.opengl.GL2; //导入方法依赖的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);
}
示例2: draw
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/** Draws the beat on the cluster location.
*
* @param drawable the GL drawable to draw on.
*/
public void draw(GLAutoDrawable drawable) {
if (isDoneRendering()) {
return;
}
GL2 gl = drawable.getGL().getGL2(); // when we get this we are already set up with scale 1=1 pixel, at LL corner
gl.glPushMatrix();
gl.glColor3f(0, 1, 0); // green
gl.glLineWidth(3); // will get scaled
final int pos = 10;
final String beatString = string;
// render string at location of cluster. size of string is sized to match cluster size
float sw = glut.glutStrokeLength(GLUT.STROKE_ROMAN, beatString); // length in model space
float cw = cluster.getRadius() ; // cluster size (actually radius, to make string half total width)
float scale = cw / sw; // scaling to make string come out size of cluster /2
// set origin to put string centered on cluster
gl.glTranslatef(location.x - (cw/2), location.y, 0);
gl.glScalef(scale, scale, 1); // scale transform to make string right size
glut.glutStrokeString(GLUT.STROKE_ROMAN, beatString); // stroke the string
gl.glPopMatrix();
framesLeftToRender--; // decrease counter for rendering
}
示例3: draw
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
public void draw(GL2 gl) {
gl.glPushMatrix();
gl.glTranslatef(chip.getSizeX() / 2, chip.getSizeY() / 2, 0);
float w = oscillator.maxx - oscillator.minx;
float h = oscillator.maxy - oscillator.miny;
gl.glScalef(chip.getSizeX() / w, chip.getSizeY() / h, 1);
if (isNearZeroCrossing()) {
gl.glColor3f(1, 0, 0);
} else {
gl.glColor3f(0, 1, 0);
}
final float r = .01f;
gl.glRectf(oscillator.x - (r * w), oscillator.y - (r * h), oscillator.x + (r * w), oscillator.y + (r * h));
gl.glPopMatrix();
}
示例4: annotate
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
@Override
public void annotate(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
gl.glPushMatrix();
String s = state.toString();
gl.glScalef(.1f, .1f, 1);
// float l=glut.glutStrokeLengthf(GLUT.STROKE_ROMAN,s);
gl.glTranslatef(0, chip.getSizeY() * .8f, 0);
gl.glLineWidth(3);
gl.glColor3f(1, 0, 0);
glut.glutStrokeString(GLUT.STROKE_ROMAN, s);
gl.glPopMatrix();
switch (state) {
case Replay:
// draw replay progress bar
gl.glPushMatrix();
gl.glColor3f(0, 0, 1);
gl.glRectf(1, 1, (chip.getSizeX() * (float) currentReplayPosition) / numEventsRecorded, 3);
gl.glPopMatrix();
break;
case Live:
case Init:
// info.annotate(drawable);
}
}
示例5: display
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
@Override
public void display(Graphics3D graphics) {
AWTGraphics3D g = (AWTGraphics3D) graphics;
GL2 gl = g.getGL2();
if(wireFrame) {
gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_LINE);
} else {
gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_FILL);
}
gl.glClear(GL2.GL_COLOR_BUFFER_BIT);
//gl.glColor3f(1.0f, 1.0f, 0f);
g.setColor(color);
gl.glLoadIdentity(); /* clear the matrix */
/* viewing transformation */
g.getGLU().gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
gl.glScalef(1.0f, 2.0f, 1.0f); /* modeling transformation */
g.drawCylinder(1, 2);
gl.glFlush();
}
示例6: display
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
@Override
public void display(Graphics3D graphics) {
AWTGraphics3D g = (AWTGraphics3D) graphics;
GL2 gl = g.getGL2();
if(wireFrame) {
gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_LINE);
} else {
gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_FILL);
}
angleY += 0.4;
gl.glClear(GL2.GL_COLOR_BUFFER_BIT);
//gl.glColor3f(1.0f, 1.0f, 0f);
g.setColor(color);
gl.glLoadIdentity(); /* clear the matrix */
/* viewing transformation */
g.getGLU().gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
gl.glRotated(angleY, 0,1,0);
gl.glScalef(1.0f, 2.0f, 1.0f); /* modeling transformation */
g.drawPyramid(1.0f);
gl.glFlush();
}
示例7: display
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
@Override
public void display(Graphics3D graphics) {
AWTGraphics3D g = (AWTGraphics3D) graphics;
GL2 gl = g.getGL2();
if(wireFrame) {
gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_LINE);
} else {
gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_FILL);
}
gl.glClear(GL2.GL_COLOR_BUFFER_BIT);
//gl.glColor3f(1.0f, 1.0f, 0f);
g.setColor(color);
gl.glLoadIdentity(); /* clear the matrix */
/* viewing transformation */
g.getGLU().gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
gl.glScalef(1.0f, 2.0f, 1.0f); /* modeling transformation */
g.drawCube(1.0);
gl.glFlush();
}
示例8: display
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
@Override
public void display(Graphics3D graphics) {
AWTGraphics3D g = (AWTGraphics3D) graphics;
GL2 gl = g.getGL2();
if(wireFrame) {
gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_LINE);
} else {
gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_FILL);
}
gl.glClear(GL2.GL_COLOR_BUFFER_BIT);
//gl.glColor3f(1.0f, 1.0f, 0f);
g.setColor(color);
gl.glLoadIdentity(); /* clear the matrix */
/* viewing transformation */
g.getGLU().gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
gl.glScalef(1.0f, 2.0f, 1.0f); /* modeling transformation */
g.drawSphere(1.0);
gl.glFlush();
}
示例9: glDrawTraces
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
protected void glDrawTraces(GL2 gl) {
if (!showTraces) {
return;
}
if (!broaderThanHigh) {
// highly unlikely; don't draw traces in this case
return;
}
gl.glPushMatrix();
// first move back to upper left corner
gl.glTranslatef(-(currentX()-x1), -(currentY()-y1), 0f);
// then move to the left to make place for the traces; also move
gl.glTranslatef( (-1.f *(drawableWidth-drawableHeight)*(y2-y1))/drawableHeight,
0f,0f);
int size= traces[0].SIZE;
// assume data range [-1..1]; indexed by sample [0..size]
gl.glScalef((1.7f*(x2-x1))/size, (y2-y1)/2f, 0);
// move to middle
gl.glTranslatef(0f,1f,0f);
// and finally use mathematical convention again
gl.glScalef(1f,-1f,1f);
// draw bounding box
gl.glColor3f(.3f,.3f,.3f);
gl.glLineWidth(2f);
gl.glBegin(GL.GL_LINE_LOOP);
gl.glVertex3f( 0f,-1f,0f);
gl.glVertex3f(size,-1f,0f);
gl.glVertex3f(size, 1f,0f);
gl.glVertex3f( 0f, 1f,0f);
gl.glEnd();
// draw graphs
for(GraphTrace g : traces) {
g.glDraw(gl);
}
gl.glPopMatrix();
}
示例10: annotate
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
@Override
public void annotate(GLAutoDrawable drawable) {
super.annotate(drawable);
GL2 gl = drawable.getGL().getGL2();
// draw slew-rate limited tilt values
final float size = .1f;
float sx = chip.getSizeX(), sy = chip.getSizeY();
{
gl.glPushMatrix();
gl.glTranslatef(-sx * size * 1.1f, .7f * sy, 0); // move outside chip array to lower left
gl.glScalef(sx * size, sx * size, sx * size); // scale everything so that when we draw 1 unit we cover this size*sx pixels
gl.glLineWidth(3f);
gl.glColor3f(1, 1, 1);
{
gl.glBegin(GL.GL_LINE_LOOP); // frame of slew-rate limited modelled controller output
gl.glVertex2f(0, 0);
gl.glVertex2f(1, 0);
gl.glVertex2f(1, 1);
gl.glVertex2f(0, 1);
gl.glEnd();
}
// draw tilt vector
float lim = controller.getTiltLimitRad() / 2;
float xlen = tiltsRadDelayed.x / lim;
float ylen = tiltsRadDelayed.y / lim;
gl.glLineWidth(4f);
if ((Math.abs(xlen) < .5f) && (Math.abs(ylen) < .5f)) {
gl.glColor4f(0, 1, 0, 1);
} else {
gl.glColor4f(1, 0, 0, 1);
}
gl.glPointSize(6f);
{
gl.glTranslatef(.5f, .5f, 0);
gl.glBegin(GL.GL_POINTS);
gl.glVertex2f(0, 0);
gl.glEnd();
}
gl.glLineWidth(4);
{
gl.glBegin(GL.GL_LINES);
gl.glVertex2f(0, 0);
gl.glVertex2f(xlen, ylen); // vector showing slew-rate limited controller output
gl.glEnd();
}
gl.glPopMatrix();
}
// draw virtual ball
// gl.glPointSize(44);
// gl.glColor4f(0,0,.5f,.5f);
// gl.glBegin(GL.GL_POINTS);
// gl.glVertex2f(ball.posPixels.x,ball.posPixels.y);
// gl.glEnd();
chip.getCanvas().checkGLError(gl, glu, "after virtual ball annotations");
ball.render(gl);
}
示例11: drawStats
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
synchronized private void drawStats(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
renderer.begin3DRendering();
// renderer.beginRendering(drawable.getWidth(), drawable.getHeight());
// optionally set the color
renderer.setColor(1, 1, 1, 1f);
if (rateEnabled) {
renderer.draw3D(toString(), -1 ,chip.getSizeY(), 0, .2f); // TODO fix string n lines
}
// ... more draw commands, color changes, etc.
renderer.end3DRendering();
// draw hist
if (isiHistEnabled) {
renderer.draw3D(String.format("%d", isiMinUs), -1, -5, 0, .2f);
renderer.draw3D(String.format("%d", isiMaxUs), chip.getSizeX()- (int) Math.floor(Math.log10(isiMaxUs)) -1, -5, 0, .2f);
renderer.draw3D(logISIEnabled ? "log" : "linear", -1, -7, 0, .2f);
if (individualISIsEnabled) {
if (showAverageISIHistogram) {
gl.glPushMatrix();
globalHist.draw(gl, lineWidth, GLOBAL_HIST_COLOR);
gl.glPopMatrix();
}
if (showIndividualISIHistograms) {
int n = histMap.size();
gl.glPushMatrix();
int k = 0;
gl.glLineWidth(lineWidth);
gl.glColor4fv(INDIV_HIST_COLOR, 0);
for (ISIHist h : histMap.values()) {
gl.glPushMatrix();
gl.glScalef(1, 1f / n, 1); // if n=10 and sy=128 then scale=1/10 scale so that all n fit in viewpoort of chip, each one is scaled to chip size y
boolean sel = false;
for (int a : currentAddress) {
if (a == h.address) {
sel = true;
}
}
if (!sel) {
h.draw(gl);
} else {
h.draw(gl, lineWidth, SELECT_COLOR);
}
gl.glPopMatrix();
gl.glTranslatef(0, (float) chip.getSizeY() / n, 0);
}
gl.glPopMatrix();
}
} else {
globalHist.draw(gl, lineWidth, GLOBAL_HIST_COLOR);
}
if (currentMousePoint != null) {
if (currentMousePoint.y <= 0) {
if (!logISIEnabled) {
binTime = (((float) currentMousePoint.x / chip.getSizeX()) * (stats.isiMaxUs - stats.isiMinUs)) + stats.isiMinUs;
} else {
binTime = (float) Math.exp((((float) currentMousePoint.x / chip.getSizeX()) * (stats.logIsiMax - stats.logIsiMin)) + stats.logIsiMin);
}
gl.glColor3fv(SELECT_COLOR, 0);
renderer.draw3D(String.format("%.0f us", binTime), currentMousePoint.x - .5f, -9, 0, .2f);
gl.glLineWidth(lineWidth);
gl.glColor3fv(SELECT_COLOR, 0);
gl.glBegin(GL2.GL_LINES);
gl.glVertex2f((currentMousePoint.x - .5f), -9);
gl.glVertex2f((currentMousePoint.x - .5f), chip.getSizeY());
gl.glEnd();
}
}
}
}
示例12: draw
import com.jogamp.opengl.GL2; //导入方法依赖的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();
}