本文整理匯總了Java中javax.media.opengl.glu.GLU類的典型用法代碼示例。如果您正苦於以下問題:Java GLU類的具體用法?Java GLU怎麽用?Java GLU使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
GLU類屬於javax.media.opengl.glu包,在下文中一共展示了GLU類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import javax.media.opengl.glu.GLU; //導入依賴的package包/類
public void init(GLAutoDrawable drawable) {
System.out.println("--init--");
GL2 gl = drawable.getGL().getGL2();
glu = new GLU();
System.out.println("INIT GL IS: " + gl.getClass().getName());
if (!bDoNurbs) {
gl.glMap2f(GL2.GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, ctlarray, 0);
}
gl.glEnable(GL2.GL_MAP2_VERTEX_3);
gl.glEnable(GL2.GL_AUTO_NORMAL);
gl.glMapGrid2f(20, 0.0f, 1.0f, 20, 0.0f, 1.0f);
setupLighting(drawable, gl);
float fovy=40.f;
float aspect=1.f;
float znear=1.f;
float zfar=20f;
glu.gluPerspective(fovy, aspect, znear, zfar);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
glu.gluLookAt(cameraLoc.x, cameraLoc.y, cameraLoc.z,
lookAtPt.x, lookAtPt.y, lookAtPt.z,
cameraUpDirection.x, cameraUpDirection.y, cameraUpDirection.z);
}
示例2: drawChair
import javax.media.opengl.glu.GLU; //導入依賴的package包/類
public void drawChair(GL2 gl, GLU glu, float lx, float lz){
gl.glEnable(GL2.GL_TEXTURE_2D);
chairTex.bind(gl);
gl.glPushMatrix();
gl.glTranslatef(lx, 0, lz);
gl.glRotatef(-90f, 1f, 0f, 0f);
glu.gluCylinder(quadric, 0.5f, 0f, 2f, 10, 10);
gl.glPopMatrix();
gl.glPushMatrix();
gl.glTranslatef(lx, 2f, lz);
gl.glRotatef(-90f, 1f, 0f, 0f);
glu.gluDisk(quadric, 1f, 0f, 10, 10);
gl.glPopMatrix();
gl.glDisable(GL2.GL_TEXTURE_2D);
}
示例3: init
import javax.media.opengl.glu.GLU; //導入依賴的package包/類
@Override
public void init(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
glu = new GLU();
/* select clearing color (background) color */
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
/* initialize viewing values */
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
// Start animator (which should be a field).
animator = new FPSAnimator(drawable, 60);
animator.start();
}
示例4: initialize
import javax.media.opengl.glu.GLU; //導入依賴的package包/類
protected void initialize(DrawContext dc)
{
GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
this.glListId = gl.glGenLists(4);
if (quadric == null)
{
quadric = dc.getGLU().gluNewQuadric();
dc.getGLU().gluQuadricDrawStyle(quadric, GLU.GLU_FILL);
dc.getGLU().gluQuadricNormals(quadric, GLU.GLU_SMOOTH);
dc.getGLU().gluQuadricOrientation(quadric, GLU.GLU_OUTSIDE);
dc.getGLU().gluQuadricTexture(quadric, false);
}
compileFMS(dc, strike, dip, rake, strike2, dip2, rake2);
// drawFMS(dc, strike, dip, rake, strike2, dip2, rake2);
this.isInitialized = true;
}
示例5: VertexRenderer
import javax.media.opengl.glu.GLU; //導入依賴的package包/類
public VertexRenderer(GLAutoDrawable drawable,
NetworkRenderer networkRenderer) {
super(drawable, networkRenderer);
this.DLIST_DISK = getDisplayListIndex(Constants.SHAPE_DISK);
this.DLIST_SQUARE = getDisplayListIndex(Constants.SHAPE_SQUARE);
glu = new GLU();
quadric = glu.gluNewQuadric();
// Display List initialization
gl.glNewList(DLIST_DISK, GL2.GL_COMPILE);
glu.gluDisk(quadric, 0, 1, DISK_SLICES, DISK_RINGS);
gl.glEndList();
gl.glNewList(DLIST_SQUARE, GL2.GL_COMPILE);
gl.glRectd(-1, -1, 1, 1);
gl.glEndList();
}
示例6: init
import javax.media.opengl.glu.GLU; //導入依賴的package包/類
@Override
public void init(GLAutoDrawable glad) {
this.gl = (GL2) glad.getGL();
glu = new GLU();
gl.setSwapInterval(1);
gl.glEnable(GL2.GL_LIGHTING);
gl.glEnable(GL2.GL_LIGHT0);
float[] lightpos = {0, 0, 1000, 0};
gl.glLightfv(GL_LIGHT0, GL_POSITION, lightpos, 0);
initShaders();
initBuffers();
gl.glEnable(GL2.GL_DEPTH_TEST);
gl.glClearColor(backgroundColor[0], backgroundColor[1], backgroundColor[2], 1); // background for GLCanvas
gl.glShadeModel(GL2.GL_SMOOTH); // use smooth shading
gl.glDepthFunc(GL2.GL_LESS);
gl.glDepthRange(0.0, 1.0);
gl.glEnable(GL2.GL_NORMALIZE);
gl.glDisable(GL2.GL_CULL_FACE);
gl.glDisable(GL.GL_BLEND);
}
示例7: init
import javax.media.opengl.glu.GLU; //導入依賴的package包/類
/**
*
* @param glad
*/
@Override
public void init(GLAutoDrawable glad) {
this.gl = (GL2) glad.getGL();
glu = new GLU();
gl.setSwapInterval(1);
gl.glEnable(GL2.GL_LIGHTING);
gl.glEnable(GL2.GL_LIGHT0);
gl.glEnable(GL2.GL_DEPTH_TEST);
gl.glClearColor(backgroundColor[0],backgroundColor[1],backgroundColor[2],1); // background for GLCanvas
gl.glShadeModel(GL2.GL_SMOOTH); // use smooth shading
gl.glDepthFunc(GL2.GL_LESS);
gl.glDepthRange(0.0, 1.0);
gl.glEnable(GL2.GL_NORMALIZE);
gl.glDisable(GL2.GL_CULL_FACE);
}
示例8: setView
import javax.media.opengl.glu.GLU; //導入依賴的package包/類
public void setView(GL2 gl, GLU glu, GlobalState gs) {
// Select part of window.
gl.glViewport(0, 0, gs.w, gs.h);
// Set projection matrix.
gl.glMatrixMode(GL_PROJECTION);
//Load the identity matrix.
gl.glLoadIdentity();
glu.gluPerspective(fovAngle, (float) gs.w / gs.h, planeNear, planeFar);
// Set camera.
gl.glMatrixMode(GL_MODELVIEW);
//Load the identity matrix.
gl.glLoadIdentity();
glu.gluLookAt(eye.x(), eye.y(), eye.z(),
center.x(), center.y(), center.z(),
up.x(), up.y(), up.z());
}
示例9: update
import javax.media.opengl.glu.GLU; //導入依賴的package包/類
/**
* Updates the camera viewpoint and direction based on the selected camera
* mode.
*
* @param gl
* @param glu
* @param gs
* @param robots
*/
public void update(GL2 gl, GLU glu, GlobalState gs, List<Robot> robots) {
final double deltaTime = gs.tAnim - tPrevious;
tPrevious = gs.tAnim;
tAutoSwitch += deltaTime;
if ((tAutoSwitch >= SWITCH_TIME) || (gs.camMode != camModePrevious)) {
tAutoSwitch = 0d;
camModePrevious = gs.camMode;
viewPrevious = viewNext;
viewNext = generateCameraView(gs, robots);
}
viewPrevious.update(gs, robots);
viewNext.update(gs, robots);
if (tAutoSwitch <= SWITCH_TRANSIT_TIME) {
final double transit = tAutoSwitch / SWITCH_TRANSIT_TIME;
modeCurrent = CameraMode.interpolateMode(viewPrevious.getCameraMode(), viewNext.getCameraMode(), transit);
} else {
modeCurrent = viewNext.getCameraMode();
}
modeCurrent.setView(gl, glu, gs);
}
示例10: draw
import javax.media.opengl.glu.GLU; //導入依賴的package包/類
/**
* Invokes all layers to draw.
*/
public void draw(GL2 gl) {
super.draw(gl);
if (state != null && gl != null && drawableLayer != null) {
GaiaCanvas canvas = GaiaCanvas.getInstance();
// Clear the color-buffer to white:
gl.glClearColor(0xFF, 0xFF, 0xFF, 0);
gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
// Set camera.
float currentZoom = state.getZoom();
setupCamera(gl, new GLU(), state.getPosition().getX(), state
.getPosition().getY(), currentZoom, canvas.getWidth(),
canvas.getHeight());
// Draw all layers beginning with the lowest:
drawableLayer.draw(gl, 0);
}
}
示例11: loadTexture
import javax.media.opengl.glu.GLU; //導入依賴的package包/類
/**
* Load a texture into OpenGL from a image reference on
* disk.
*
* @param resourceName The location of the resource to load
* @param target The GL target to load the texture against
* @param dstPixelFormat The pixel format of the screen
* @param minFilter The minimising filter
* @param magFilter The magnification filter
* @return The loaded texture
* @throws IOException Indicates a failure to access the resource
*/
private static Texture loadTexture(BufferedImage bufferedImage, int dstPixelFormat )
{
GL gl = GLContext.getCurrent().getGL();
int srcPixelFormat = 0;
int textureID = createTextureID();
Texture texture = new Texture(textureID);
gl.glBindTexture( GL.GL_TEXTURE_2D, textureID);
texture.width = bufferedImage.getWidth();
texture.height = bufferedImage.getHeight();
if (bufferedImage.getColorModel().hasAlpha())
srcPixelFormat = GL.GL_RGBA;
else
srcPixelFormat = GL.GL_RGB;
ByteBuffer textureBuffer = convertImageData(bufferedImage,texture);
new GLU().gluBuild2DMipmaps( GL.GL_TEXTURE_2D, dstPixelFormat, get2Fold( bufferedImage.getWidth()), get2Fold( bufferedImage.getHeight()), srcPixelFormat, GL.GL_UNSIGNED_BYTE, textureBuffer);
Log.println( "[Texture] created texture " + bufferedImage.getWidth() + "x" + bufferedImage.getHeight() );
texture_count ++;
return texture;
}
示例12: reshape
import javax.media.opengl.glu.GLU; //導入依賴的package包/類
/**
* Reshape method
*/
public void reshape(GLAutoDrawable GLAutoDrawable, int x, int y, int width, int height)
{
final GL gl = GLAutoDrawable.getGL();
final GLU glu = new GLU();
if(height <= 0) height = 1;
//set the viewport
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(
60.0, // fov
(float)width / (float)height, // aspect
0.1, // near
500.0 // far
);
gl.glMatrixMode(GL.GL_MODELVIEW); //select The Modelview Matrix
gl.glLoadIdentity(); //set the ModalView matrix to identity
}
示例13: reshape
import javax.media.opengl.glu.GLU; //導入依賴的package包/類
@Override
public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4) {
GL2 gl2 = arg0.getGL().getGL2();
gl2.glMatrixMode(GL2.GL_PROJECTION);
gl2.glLoadIdentity();
// coordinate system origin at lower left with width and height same as the window
GLU glu = new GLU();
glu.gluOrtho2D(0.0f, getWidth(), 0.0f, getHeight());
gl2.glMatrixMode(GL2.GL_MODELVIEW);
gl2.glLoadIdentity();
gl2.glViewport(0, 0, getWidth(), getHeight());
controller.updateExtents(arg3 / 2, arg4 / 2);
}
示例14: set
import javax.media.opengl.glu.GLU; //導入依賴的package包/類
public void set(GL2 g, MapPanel panel) {
int width = panel.getWidth();
int height = panel.getHeight();
GLU glu = GLU.createGLU(g);
g.glViewport(0, 0, width, height);
g.glMatrixMode(GL2.GL_PROJECTION);
g.glLoadIdentity();
float fwidth = width;
float fheight = height;
glu.gluPerspective(70, fwidth / fheight, 0.1f, 600.0f);
g.glMatrixMode(GL2.GL_MODELVIEW);
g.glLoadIdentity();
glu.gluLookAt((float) posx, (float) posy, (float) posz, (float) posx + dirx, (float) posy + diry, (float) posz + dirz, 0, 1, 0);
g.glMultMatrixf(matrix);
}
示例15: init
import javax.media.opengl.glu.GLU; //導入依賴的package包/類
@Override
public void init(GLAutoDrawable drawable) {
gl = drawable.getGL().getGL2();
glu = new GLU();
System.err.println("INIT GL IS: " + gl.getClass().getName());
System.err.println("Chosen GLCapabilities: "
+ drawable.getChosenGLCapabilities());
gl.setSwapInterval(1);
// gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
// gl.glClearDepth(1.0f);
gl.glEnable(GL_DEPTH_TEST);
gl.glDepthFunc(GL_LEQUAL);
gl.glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
gl.glShadeModel(GL_SMOOTH);
}