当前位置: 首页>>代码示例>>Java>>正文


Java GL2.glViewport方法代码示例

本文整理汇总了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();
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:19,代码来源:Triangulation3DViewer.java

示例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
}
 
开发者ID:Harium,项目名称:propan-jogl-examples,代码行数:23,代码来源:Example2.java

示例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
}
 
开发者ID:Harium,项目名称:propan-jogl-examples,代码行数:23,代码来源:AnimationApplication.java

示例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
}
 
开发者ID:Harium,项目名称:propan-jogl-examples,代码行数:23,代码来源:LogoShowApplication.java

示例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();
}
 
开发者ID:Harium,项目名称:propan-jogl-examples,代码行数:18,代码来源:StandardExample.java

示例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);
}
 
开发者ID:Harium,项目名称:propan-jogl-examples,代码行数:12,代码来源:PyramidExample.java

示例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();
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:45,代码来源:ChipCanvas.java

示例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();
}
 
开发者ID:Harium,项目名称:propan-jogl-examples,代码行数:19,代码来源:StampApplication.java

示例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);
}
 
开发者ID:asiermarzo,项目名称:Ultraino,代码行数:7,代码来源:Renderer.java

示例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();

}
 
开发者ID:Harium,项目名称:propan-jogl-examples,代码行数:22,代码来源:RotateAroundExample.java

示例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();
}
 
开发者ID:Harium,项目名称:propan-jogl-examples,代码行数:19,代码来源:PositionAxis.java

示例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();

}
 
开发者ID:Harium,项目名称:propan-jogl-examples,代码行数:22,代码来源:GridMenuApplication.java

示例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();

}
 
开发者ID:Harium,项目名称:propan-jogl-examples,代码行数:20,代码来源:Perspective.java

示例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();

}
 
开发者ID:Harium,项目名称:propan-jogl-examples,代码行数:20,代码来源:SkyboxExample.java


注:本文中的com.jogamp.opengl.GL2.glViewport方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。