本文整理汇总了Java中com.jogamp.opengl.GL2.glViewport方法的典型用法代码示例。如果您正苦于以下问题:Java GL2.glViewport方法的具体用法?Java GL2.glViewport怎么用?Java GL2.glViewport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jogamp.opengl.GL2
的用法示例。
在下文中一共展示了GL2.glViewport方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reshape
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
@Override
public void reshape( GLAutoDrawable drawable, int x, int y, int width, int height ) {
GL2 gl = drawable.getGL().getGL2();
if( height <= 0 ) {
height = 1;
}
final float h = ( float ) width / ( float ) height;
gl.glViewport( 0, 0, width, height );
gl.glMatrixMode( GLMatrixFunc.GL_PROJECTION );
gl.glLoadIdentity();
glu.gluPerspective( 45.0f, h, 1.0, 20.0 );
gl.glMatrixMode( GLMatrixFunc.GL_MODELVIEW );
gl.glLoadIdentity();
}
示例2: 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
}
示例3: 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
}
示例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, 1000.0); // fovy, aspect, zNear, zFar
// Enable the model-view transform
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity(); // reset
}
示例5: standardScene
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
public static void standardScene(Graphics3D graphics, int x, int y, int w, int h) {
AWTGraphics3D g = (AWTGraphics3D) graphics;
GL2 gl = g.getGL2();
GLU glu = g.getGLU();
gl.glViewport(x, y, w, h);
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
double aspect = (double)w/(double)h;
glu.gluPerspective(60.0, aspect, 0.1, 500.0);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
}
示例6: 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
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL2.GL_PROJECTION); // choose projection matrix
gl.glLoadIdentity(); // reset projection matrix
gl.glFrustum(-1.0, 1.0, -1.0, 1.0, 1.5, 20.0);
gl.glMatrixMode(GL2.GL_MODELVIEW);
}
示例7: reshape
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/**
* Called on reshape of canvas. Determines which way the chip fits into the
* display area optimally and calls for a new orthographic projection to
* achieve this filling. Finally sets the viewport to the entire drawable
* area.
*/
@Override
public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width,
final int height) {
final GL2 gl = drawable.getGL().getGL2();
checkGLError(gl, glu, "at start of reshape");
gl.glLoadIdentity();
final int chipSizeX = chip.getSizeX();
final int chipSizeY = chip.getSizeY();
float newscale;
final float border = 0; // getBorderSpacePixels()*(float)height/width;
if (chipSizeY > chipSizeX) {
// chip is tall and skinny, so set scaleChipPixels2ScreenPixels by frame height/chip height
newscale = (height - border) / chipSizeY;
fillsVertically = true;
fillsHorizontally = false;
if ((newscale * chipSizeX) > width) { // unless it runs into left/right, then set to fill width
newscale = (width - border) / chipSizeX;
fillsHorizontally = true;
fillsVertically = false;
}
} else {
// chip is square or squat, so set scaleChipPixels2ScreenPixels by frame width / chip width
newscale = (width - border) / chipSizeX;
fillsHorizontally = true;
fillsVertically = false;
if ((newscale * chipSizeY) > height) {// unless it runs into top/bottom, then set to fill height
newscale = (height - border) / chipSizeY;
fillsVertically = true;
fillsHorizontally = false;
}
}
checkGLError(gl, glu, "before setDefaultProjection in reshape");
setDefaultProjection(gl, drawable); // this sets orthographic projection so that chip pixels are scaled to the
// drawable area
gl.glViewport(0, 0, width, height);
repaint();
}
示例8: reshape
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
@Override
public void reshape(Graphics3D graphics, int x, int y, int w, int h) {
AWTGraphics3D g = (AWTGraphics3D) graphics;
GL2 gl = g.getGL2();
GLU glu = g.getGLU();
gl.glViewport(x, y, w, h);
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(60.0, (double) w / (double) h, 0.1, 500.0);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
}
示例9: reshape
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
public void reshape(GL2 gl, int w, int h){
gl.glViewport( 0, 0, w, h );
//set camera
scene.getCamera().updateProjection(w/(float)h);
}
示例10: 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();
GLU glu = g.getGLU();
gl.glViewport (x, y, width, height);
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
float aspect = (float)width / (float)height;
glu.gluPerspective(60, aspect, 1, 100);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
}
示例11: 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();
GLU glu = g.getGLU();
gl.glViewport((int)x, (int)y, (int)w, (int)h);
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(60.0, (double) w / (double) h, 0.1, 500.0);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
}
示例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();
GLU glu = g.getGLU();
gl.glViewport (x, y, width, height);
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
float aspect = (float)width / (float)height;
glu.gluPerspective(60, aspect, 1, 100);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
}
示例13: 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();
GLU glu = g.getGLU();
gl.glViewport((int)x, (int)y, (int)w, (int)h);
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(60.0, (double) w / (double) h, 0.1, 500.0);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
}
示例14: 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();
GLU glu = g.getGLU();
gl.glViewport((int)x, (int)y, (int)w, (int)h);
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(60.0, (double) w / (double) h, 0.1, farPlane);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
}