本文整理匯總了Java中javax.media.opengl.GL2.glGetIntegerv方法的典型用法代碼示例。如果您正苦於以下問題:Java GL2.glGetIntegerv方法的具體用法?Java GL2.glGetIntegerv怎麽用?Java GL2.glGetIntegerv使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.GL2
的用法示例。
在下文中一共展示了GL2.glGetIntegerv方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: reshape
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void reshape(GLAutoDrawable drawable, int x, int y, int width,
int height) {
GL2 gl = drawable.getGL().getGL2();
this.drawable = drawable;
this.width = width;
this.height = height;
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrtho(0, width, height, 0, -1, 1);
gl.glViewport(0, 0, width, height);
gl.glGetDoublev(GL2.GL_MODELVIEW_MATRIX, modelview);
gl.glGetDoublev(GL2.GL_PROJECTION_MATRIX, projection);
gl.glGetIntegerv(GL2.GL_VIEWPORT, viewport);
}
示例2: setBlending
import javax.media.opengl.GL2; //導入方法依賴的package包/類
private Map<String, Object> setBlending() {
Map<String, Object> result = new HashMap<>();
GL2 gl = drawable.getGL().getGL2();
IntBuffer equation = Buffers.newDirectIntBuffer(1);
gl.glGetIntegerv(GL_BLEND_EQUATION, equation);
result.put("equation", equation);
IntBuffer sourceFactor = Buffers.newDirectIntBuffer(1);
gl.glGetIntegerv(GL_BLEND_SRC, sourceFactor);
result.put("sourceFactor", sourceFactor);
IntBuffer destinationFactor = Buffers.newDirectIntBuffer(1);
gl.glGetIntegerv(GL_BLEND_DST, destinationFactor);
result.put("destinationFactor", destinationFactor);
boolean enabled = gl.glIsEnabled(GL_BLEND);
result.put("enabled", enabled);
gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE);
gl.glBlendEquation(GL_FUNC_ADD);
gl.glEnable(GL_BLEND);
return result;
}
示例3: apply
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
* Apply the camera to a GL context.
*
* @param gl GL context.
*/
public void apply(GL2 gl) {
// 3D projection
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
// Perspective.
glu.gluPerspective(35, ratio, 1, 1000);
glu.gluLookAt(distance * sinZ, distance * -cosZ, height, // pos
0, 0, .5, // center
0, 0, 1 // up
);
// Change back to model view matrix.
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
// Store the matrixes for reference.
gl.glGetIntegerv(GL.GL_VIEWPORT, viewp, 0);
gl.glGetDoublev(GLMatrixFunc.GL_MODELVIEW_MATRIX, modelview, 0);
gl.glGetDoublev(GLMatrixFunc.GL_PROJECTION_MATRIX, projection, 0);
}
示例4: logStack
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
* Dumps the current modelview and perspective.
*/
public static void logStack(final DrawContext dc, final String logId) {
final GL2 gl = dc.getGL().getGL2();
final IntBuffer depthModel = IntBuffer.allocate(1);
final IntBuffer depthPerspective = IntBuffer.allocate(1);
gl.glGetIntegerv(GL2.GL_MODELVIEW_STACK_DEPTH, depthModel);
gl.glGetIntegerv(GL2.GL_PROJECTION_STACK_DEPTH, depthPerspective);
System.out.println((UI.timeStampNano() + " [" + logId + "]\t") //$NON-NLS-1$ //$NON-NLS-2$
+ ("GL_MODELVIEW_STACK_DEPTH:\t" + depthModel.get(0)) //$NON-NLS-1$
+ "\t\t" //$NON-NLS-1$
+ ("GL_PROJECTION_STACK_DEPTH:\t" + depthPerspective.get(0)) //$NON-NLS-1$
+ "\t" //$NON-NLS-1$
+ getGLErrors(dc)
//
);
}
示例5: get2dPoint
import javax.media.opengl.GL2; //導入方法依賴的package包/類
protected DoubleBuffer get2dPoint( final GL2 gl, final double x, final double y, final double z )
{
final DoubleBuffer model = DoubleBuffer.allocate(16);
gl.glGetDoublev( GLMatrixFunc.GL_MODELVIEW_MATRIX, model );
final DoubleBuffer proj = DoubleBuffer.allocate(16);
gl.glGetDoublev( GLMatrixFunc.GL_PROJECTION_MATRIX, proj );
final IntBuffer view = IntBuffer.allocate(4);
gl.glGetIntegerv( GL.GL_VIEWPORT, view );
final DoubleBuffer winPos = DoubleBuffer.allocate(3);
final boolean b = this.glu.gluProject( x, y, z, model, proj, view, winPos );
if( !b ) System.out.println( "FAIL ");
return winPos;
}
示例6: display
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void display(GLAutoDrawable drawable)
{
GL2 gl = drawable.getGL().getGL2();
switch(cmd)
{
case UPDATE:
drawScene(gl);
break;
case SELECT:
int buffsize = 512;
double x = (double) mouse_x, y = (double) mouse_y;
int[] viewPort = new int[4];
IntBuffer selectBuffer = Buffers.newDirectIntBuffer(buffsize);
int hits = 0;
gl.glGetIntegerv(GL2.GL_VIEWPORT, viewPort, 0);
gl.glSelectBuffer(buffsize, selectBuffer);
gl.glRenderMode(GL2.GL_SELECT);
gl.glInitNames();
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glPushMatrix();
gl.glLoadIdentity();
glu.gluPickMatrix(x, (double) viewPort[3] - y, 5.0d, 5.0d, viewPort, 0);
glu.gluOrtho2D(0.0d, 1.0d, 0.0d, 1.0d);
drawScene(gl);
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glPopMatrix();
gl.glFlush();
hits = gl.glRenderMode(GL2.GL_RENDER);
processHits(hits, selectBuffer);
cmd = UPDATE;
break;
}
}
示例7: beginDrawLasso
import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void beginDrawLasso(DrawContext dc) {
//GL gl = dc.getGL();
GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
int attributeMask =
GL.GL_DEPTH_BUFFER_BIT // for depth test, depth mask and depth func
| GL2.GL_TRANSFORM_BIT // for modelview and perspective
| GL2.GL_VIEWPORT_BIT // for depth range
| GL2.GL_CURRENT_BIT // for current color
| GL2.GL_COLOR_BUFFER_BIT // for alpha test func and ref, and blend
| GL2.GL_DEPTH_BUFFER_BIT // for depth func
| GL2.GL_ENABLE_BIT; // for enable/disable changes
gl.glPushAttrib(attributeMask);
// Apply the depth buffer but don't change it.
gl.glEnable(GL.GL_DEPTH_TEST);
gl.glDepthFunc(GL.GL_ALWAYS);
gl.glDepthMask(false);
// Load a parallel projection with dimensions (viewportWidth, viewportHeight)
int[] viewport = new int[4];
gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0);
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glPushMatrix();
gl.glLoadIdentity();
gl.glOrtho(0d, viewport[2], 0d, viewport[3], -1d, 1d);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glPushMatrix();
}
示例8: display
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void display(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
this.drawable = drawable;
// Apply transformations
double transx = -origin.getX(), transy = -origin.getY();
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrtho(0, width, height, 0, -1, 1);
gl.glViewport(0, 0, width, height);
gl.glTranslated(transx + zoomPos.getX(), transy + zoomPos.getY(), 0);
gl.glScaled(scaleFactor, scaleFactor, 1);
gl.glTranslated(-zoomPos.getX(), -zoomPos.getY(), 0);
gl.glGetDoublev(GL2.GL_MODELVIEW_MATRIX, modelview);
gl.glGetDoublev(GL2.GL_PROJECTION_MATRIX, projection);
gl.glGetIntegerv(GL2.GL_VIEWPORT, viewport);
gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
// Draw edges, arrows and vertices
edgeRenderer.transform(transx, transy, scaleFactor);
edgeRenderer.render();
if (animateLabels) {
labelRenderer.scale(scaleFactor);
labelRenderer.drawLabels();
}
vertexRenderer.transform(transx, transy, scaleFactor);
vertexRenderer.render();
}
示例9: viewPortWidth
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public int viewPortWidth(GL2 gl)
{
int[] viewPort = new int[4];
gl.glGetIntegerv(GL2.GL_VIEWPORT, viewPort, 0);
return viewPort[2];
}
示例10: viewPortHeight
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public int viewPortHeight(GL2 gl)
{
int[] viewPort = new int[4];
gl.glGetIntegerv(GL2.GL_VIEWPORT, viewPort, 0);
return viewPort[3];
}
示例11: screenshot
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
* Takes a "screenshot" (i.e. a snapshot of the current frame buffer) from
* the OpenGL context. The format is: 3 bytes, three channels (BGR).
*
* @param gl
* The OpenGL context to access the frame buffer.
*/
public static BufferedImage screenshot(GL2 gl) {
BufferedImage image;
int[] readBufferName = new int[1];
int[] pixelStoreSwapBytes = new int[1];
int[] pixelStoreLength = new int[1];
int[] pixelStoreRows = new int[1];
int[] pixelStorePixels = new int[1];
int[] pixelStoreAlignment = new int[1];
// There is no glPushAttrib() Argument which saves pixel store flags.
// All this flags must be saved/restored manually. I know,
// glReadBuffer()
// can be pushed (GL_PIXEL_MODE_BIT).
gl.glGetIntegerv(GL2.GL_READ_BUFFER, readBufferName, 0);
gl.glGetIntegerv(GL2.GL_PACK_ALIGNMENT, pixelStoreAlignment, 0);
gl.glGetIntegerv(GL2.GL_PACK_SKIP_ROWS, pixelStoreRows, 0);
gl.glGetIntegerv(GL2.GL_PACK_SKIP_PIXELS, pixelStorePixels, 0);
gl.glGetIntegerv(GL2.GL_PACK_SWAP_BYTES, pixelStoreSwapBytes, 0);
gl.glGetIntegerv(GL2.GL_PACK_ROW_LENGTH, pixelStoreLength, 0);
// Get size of viewport.
int[] viewport = new int[4];
gl.glGetIntegerv(GL2.GL_VIEWPORT, viewport, 0);
int width = viewport[2];
int height = viewport[3];
// Create the client side image.
// Reserve 3 bytes for each pixel (BGR). Pixel number: width * height.
int bytes = width * height * 3;
image = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
ByteBuffer data = ByteBuffer.allocate(bytes);
// Select buffer and set pixel storage parameters
gl.glReadBuffer(GL2.GL_FRONT);
gl.glPixelStorei(GL2.GL_PACK_ALIGNMENT, 1);
gl.glPixelStorei(GL2.GL_PACK_SKIP_ROWS, 0);
gl.glPixelStorei(GL2.GL_PACK_SKIP_PIXELS, 0);
gl.glPixelStorei(GL2.GL_PACK_SWAP_BYTES, GL2.GL_FALSE);
gl.glPixelStorei(GL2.GL_PACK_ROW_LENGTH, width);
// Read whole frame buffer data.
gl.glReadPixels(0, 0, width, height, GL2.GL_BGR, GL2.GL_UNSIGNED_BYTE,
data);
// Restore state changes.
gl.glPixelStorei(GL2.GL_PACK_ROW_LENGTH, pixelStoreLength[0]);
gl.glPixelStorei(GL2.GL_PACK_SWAP_BYTES, pixelStoreSwapBytes[0]);
gl.glPixelStorei(GL2.GL_PACK_SKIP_PIXELS, pixelStorePixels[0]);
gl.glPixelStorei(GL2.GL_PACK_SKIP_ROWS, pixelStoreRows[0]);
gl.glPixelStorei(GL2.GL_PACK_ALIGNMENT, pixelStoreAlignment[0]);
gl.glReadBuffer(readBufferName[0]);
// Copy the pixel data to a BufferedImage data buffer.
byte[] bufferedImageData = ((DataBufferByte) image.getRaster()
.getDataBuffer()).getData();
int srcOffset = 0;
int numOfBytesPerRow = width * 3;
int destOffset = numOfBytesPerRow * (height - 1);
for (int y = 0; y < height; y++) {
System.arraycopy(data.array(), srcOffset, bufferedImageData,
destOffset, numOfBytesPerRow);
srcOffset += numOfBytesPerRow;
destOffset -= numOfBytesPerRow;
}
Logger.getInstance().message("Toke Screenshot.");
return image;
}