本文整理汇总了Java中com.jogamp.opengl.GL2类的典型用法代码示例。如果您正苦于以下问题:Java GL2类的具体用法?Java GL2怎么用?Java GL2使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GL2类属于com.jogamp.opengl包,在下文中一共展示了GL2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showActivations
import com.jogamp.opengl.GL2; //导入依赖的package包/类
/**
* Annotates the frame with the activations of the softmax layer as a bar
* chart
*
* @param gl
* @param width
* @param height
*/
public void showActivations(GL2 gl, int width, int height) {
if (this.networkOutput == null) {
} else {
float dx = (float) (width) / this.networkOutput.length;
float dy = 0.8f * (height);
gl.glBegin(GL.GL_LINE_STRIP);
for (int i = 0; i < this.networkOutput.length; i++) {
float tmpOutput = this.networkOutput[i];
float tmpOutputMax = RNNfilterExpFeatures.maxValue(this.networkOutput);
float y_end = 1 + ((dy * tmpOutput) / tmpOutputMax); // draws the relative activations of the neurons in
// the layer
float x_start = 1 + (dx * i);
float x_end = x_start + dx;
gl.glVertex2f(x_start, 1);
gl.glVertex2f(x_start, y_end);
gl.glVertex2f(x_end, y_end);
gl.glVertex2f(x_end, 1);
}
gl.glEnd();
}
}
示例2: setCamera
import com.jogamp.opengl.GL2; //导入依赖的package包/类
private void setCamera(GL2 gl, GLU glu)
{
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(75, 1, 0.01, 1000);
//look at the player from 1.5 units directly above the player
glu.gluLookAt(
inst.player.pos.x, inst.player.pos.y, 1.5,
inst.player.pos.x, inst.player.pos.y, 0,
0, 1, 0);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
}
示例3: draw
import com.jogamp.opengl.GL2; //导入依赖的package包/类
public void draw(GL2 gl) {
if ((maxvalue <= 0) || Float.isNaN(ballX) || Float.isNaN(ballY)) {
return;
}
gl.glColor4f(0, .4f, 0, .2f);
if (quad == null) {
quad = glu.gluNewQuadric();
}
gl.glPushMatrix();
gl.glTranslatef(ballX, ballY, 0);
glu.gluQuadricDrawStyle(quad, GLU.GLU_FILL);
gl.glLineWidth(2f);
glu.gluDisk(quad, 0, ballRadiusPixels, 16, 1);
gl.glPopMatrix();
}
示例4: reshape
import com.jogamp.opengl.GL2; //导入依赖的package包/类
@Override
public void reshape(Graphics3D graphics, int x, int y, int width, int height) {
AWTGraphics3D g = (AWTGraphics3D) graphics;
GL2 gl = g.getGL2(); // get the OpenGL graphics context
GLU glu = g.getGLU();
if (height == 0) height = 1; // prevent divide by zero
float aspect = (float)width / height;
// Set the view port (display area) to cover the entire window
gl.glViewport(0, 0, width, height);
// Setup perspective projection, with aspect ratio matches viewport
gl.glMatrixMode(GL2.GL_PROJECTION); // choose projection matrix
gl.glLoadIdentity(); // reset projection matrix
glu.gluPerspective(45.0, aspect, 0.1, 100.0); // fovy, aspect, zNear, zFar
// Enable the model-view transform
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity(); // reset
}
示例5: init
import com.jogamp.opengl.GL2; //导入依赖的package包/类
@Override
public void init(GLAutoDrawable drawable) {
context = drawable.getContext();
GL3 gl = drawable.getGL().getGL3();
gl.setSwapInterval(0);
gl.glEnable(GL.GL_DEPTH_TEST);
log.info("GL Vendor: " + gl.glGetString(GL.GL_VENDOR));
log.info("GL Renderer: " + gl.glGetString(GL.GL_RENDERER));
log.info("GL Version: " + gl.glGetString(GL.GL_VERSION));
log.info("GLSL Version: " + gl.glGetString(GL2.GL_SHADING_LANGUAGE_VERSION));
log.debug("Changed context: " + context.getGLVersion());
ogl.setOgl(gl);
synchronized (contextWait) {
contextWait.notify();
}
}
示例6: setSamplerType
import com.jogamp.opengl.GL2; //导入依赖的package包/类
public void setSamplerType(int samplerType) throws TextureException {
String errorString;
if(unitState!=TEXTURE_UNIT_IDLE) {
errorString = "";
throw new TextureException(errorString);
}
if(!(samplerType==SAMPLER_1D||samplerType==SAMPLER_2D)) {
errorString ="Invalid texture (sampler) type";
throw new TextureException(errorString);
}
this.samplerType=samplerType;
if(this.samplerType==SAMPLER_1D) {
oglTextureType = GL2.GL_TEXTURE_1D;
}
else {
oglTextureType = GL2.GL_TEXTURE_2D;
}
}
示例7: displayStats
import com.jogamp.opengl.GL2; //导入依赖的package包/类
public void displayStats(GLAutoDrawable drawable) {
if ((drawable == null) || (selection == null) || (chip.getCanvas() == null)) {
return;
}
canvas = chip.getCanvas();
glCanvas = (GLCanvas) canvas.getCanvas();
int sx = chip.getSizeX(), sy = chip.getSizeY();
Rectangle chipRect = new Rectangle(sx, sy);
GL2 gl = drawable.getGL().getGL2();
if (!chipRect.intersects(selection)) {
return;
}
drawSelection(gl, selection, SELECT_COLOR);
stats.drawStats(drawable);
stats.play();
}
示例8: display
import com.jogamp.opengl.GL2; //导入依赖的package包/类
@Override
public void display(Graphics3D graphics) {
AWTGraphics3D g = (AWTGraphics3D) graphics;
GL2 gl = g.getGL().getGL2();
g.setColor(Color.WHITE);
//Transform by Camera
g.updateCamera(camera);
//Draw Billboard
texture.enable(gl);
texture.bind(gl);
g.drawBillboard(billboard);
texture.disable(gl);
gl.glFlush();
}
示例9: createComponents
import com.jogamp.opengl.GL2; //导入依赖的package包/类
/**
* Create the components.
*/
@Override
protected void createComponents(GL2 gl) {
axisLabelRenderer = new TextRenderer(new Font("Helvetica", Font.PLAIN, 12));
textRenderer = new TextRenderer(new Font("Helvetica", Font.PLAIN, 10));
axesLabels = new String[2];
axisLabelAreas = new Rectangle[axesLabels.length];
for (int i = 0; i < axesLabels.length; i++) {
StringBuilder buf = new StringBuilder();
// for(Category s : categories) {
Category s = categories[0];
buf.append(s.axes[i].title);
if (s.axes[i].unit != null) {
buf.append(" [" + s.axes[i].unit + "]");
}
buf.append('\n');
// }
String str = buf.toString();
axesLabels[i] = str.substring(0, str.length() - 1);
Rectangle2D bounds = axisLabelRenderer.getBounds(axesLabels[i]);
axisLabelAreas[i] = new Rectangle((int) bounds.getWidth(), (int) bounds.getHeight());
}
}
示例10: drawOrientationVector
import com.jogamp.opengl.GL2; //导入依赖的package包/类
protected void drawOrientationVector(GL2 gl, OrientationEventInterface e) {
if (!e.isHasOrientation()) {
return;
}
byte ori = e.getOrientation();
OrientationEventInterface.UnitVector d = OrientationEventInterface.unitVectors[ori];
float jx = 0, jy = 0;
if (jitterVectorLocations) {
jx = (random.nextFloat() - .5f) * jitterAmountPixels;
jy = (random.nextFloat() - .5f) * jitterAmountPixels;
}
gl.glLineWidth(3f);
float[] c = chip.getRenderer().makeTypeColors(e.getNumCellTypes())[ori];
gl.glColor3fv(c, 0);
gl.glBegin(GL.GL_LINES);
gl.glVertex2f((e.getX() - (d.x * length)) + jx, (e.getY() - (d.y * length)) + jy);
gl.glVertex2f((e.getX() + (d.x * length)) + jx, (e.getY() + (d.y * length)) + jy);
gl.glEnd();
}
示例11: annotate
import com.jogamp.opengl.GL2; //导入依赖的package包/类
@Override
public void annotate(GLAutoDrawable drawable) {
super.annotate(drawable);
// if (targetLabeler != null) {
// targetLabeler.annotate(drawable);
// }
if (hideOutput) {
return;
}
GL2 gl = drawable.getGL().getGL2();
checkBlend(gl);
int sy = chip.getSizeY();
if ((apsDvsNet != null) && (apsDvsNet.getOutputLayer() != null) && (apsDvsNet.getOutputLayer().getActivations()!= null)) {
drawDecisionOutput(gl, sy, Color.GREEN);
}
error.draw(gl);
}
示例12: reshape
import com.jogamp.opengl.GL2; //导入依赖的package包/类
@Override
public void reshape(Graphics3D graphics, int x, int y, int width, int height) {
AWTGraphics3D g = (AWTGraphics3D) graphics;
GL2 gl = g.getGL2(); // get the OpenGL graphics context
GLU glu = g.getGLU();
if (height == 0) height = 1; // prevent divide by zero
float aspect = (float) width / height;
// Set the view port (display area) to cover the entire window
gl.glViewport(0, 0, width, height);
// Setup perspective projection, with aspect ratio matches viewport
gl.glMatrixMode(GL2.GL_PROJECTION); // choose projection matrix
gl.glLoadIdentity(); // reset projection matrix
glu.gluPerspective(45.0, aspect, 0.1, 100.0); // fovy, aspect, zNear, zFar
// Enable the model-view transform
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity(); // reset
}
示例13: draw
import com.jogamp.opengl.GL2; //导入依赖的package包/类
synchronized void draw(GL2 gl) {
gl.glPushAttrib(GL2.GL_ENABLE_BIT);
gl.glLineStipple(1, (short) 0x7777);
gl.glLineWidth(9);
gl.glColor4f(0, 1, 1, .9f);
// textRenderer.begin3DRendering();
// textRenderer.draw3D("laser line", 5, 5, 0, textScale);
// textRenderer.end3DRendering();
gl.glEnable(GL2.GL_LINE_STIPPLE);
gl.glBegin(GL.GL_LINE_STRIP);
for (int i = 0; i < mapSizeX; i++) {
if (!ys[i].isNaN()) { // skip over columns without valid score
gl.glVertex2f(i, ys[i]);
} else { // interrupt lines at NaN
gl.glEnd();
gl.glBegin(GL.GL_LINE_STRIP);
}
}
gl.glEnd();
gl.glPopAttrib();
}
示例14: Light
import com.jogamp.opengl.GL2; //导入依赖的package包/类
public Light(Color ambient, Color diffuse, Color specular, PointF3 position, VectorF3 direction,
float spot_exponent, float spot_cut_off, float attenuation, int attenuation_type, Color light_model_ambient, float light_model_two_side, int lightID){
this.ambient = toArray(ambient);
this.diffuse = toArray(diffuse);
this.specular= toArray(specular);
this.position=toArray(position,1);
this.direction=toArray(direction);
this.spot_exponent=new float[]{spot_exponent};
this.spot_cut_off=new float[]{spot_cut_off};
this.attenuation=new float[]{attenuation};
this.light_model_ambient=toArray(light_model_ambient);
this.light_model_two_side=new float[]{light_model_two_side};
this.attenuation_type = attenuation_type;
this.light_nr = lightID+ GL2.GL_LIGHT0;
}
示例15: checkGLError
import com.jogamp.opengl.GL2; //导入依赖的package包/类
/**
* Utility method to check for GL errors. Prints stacked up errors up to a
* limit.
*
* @param g the GL context
* @param glu the GLU used to obtain the error strings
* @param msg an error message to log to e.g., show the context
*/
private void checkGLError(GL2 g, String msg) {
int error = g.glGetError();
int nerrors = 3;
while ((error != GL.GL_NO_ERROR) && (nerrors-- != 0)) {
StackTraceElement[] trace = Thread.currentThread().getStackTrace();
if (trace.length > 1) {
String className = trace[2].getClassName();
String methodName = trace[2].getMethodName();
int lineNumber = trace[2].getLineNumber();
log.warning("GL error number " + error + " " + glu.gluErrorString(error) + " : " + msg + " at " + className + "." + methodName + " (line " + lineNumber + ")");
} else {
log.warning("GL error number " + error + " " + glu.gluErrorString(error) + " : " + msg);
}
error = g.glGetError();
}
}