本文整理匯總了Java中javax.media.opengl.GL.glViewport方法的典型用法代碼示例。如果您正苦於以下問題:Java GL.glViewport方法的具體用法?Java GL.glViewport怎麽用?Java GL.glViewport使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.GL
的用法示例。
在下文中一共展示了GL.glViewport方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: reshape
import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
* Needed implementation of method when you change the size of the main window
* @param drawable
* @param x
* @param y
* @param width
* @param height
*/
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
if (height <= 0) { // avoid a divide by zero error!
height = 1;
}
final float aspect = (float) width / (float) height;
GL gl = drawable.getGL();
gl.getGL2().glMatrixMode(GL2.GL_PROJECTION);
gl.getGL2().glLoadIdentity();
glu.gluPerspective(0, aspect, 0.1f, 1);
// Set the view port (display area) to cover the entire window
gl.glViewport(0, 0, width, height);
glu.gluOrtho2D(0, 1, 0, 1);
gl.getGL2().glMatrixMode(GL2.GL_MODELVIEW);
gl.getGL2().glLoadIdentity();
}
示例2: setProjection
import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
* Set projection, viewpoinbt and so on. Used every rendered frame.
*/
private synchronized void setProjection(GL gl, int x, int y, int width, int height) {
if (height <= 0) { // avoid a divide by zero error!
height = 1;
}
float h = (float) width / (float) height;
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(viewpoint.getViewAngle(), h, 10.0, 100000.0);
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
}
示例3: reshape
import javax.media.opengl.GL; //導入方法依賴的package包/類
@Override
public void reshape(GLAutoDrawable drawable,int x, int y, int width, int height) {
GL gl = drawable.getGL();
gl.glViewport(0, 0, width, height);
}