當前位置: 首頁>>代碼示例>>Java>>正文


Java GL2.glDisable方法代碼示例

本文整理匯總了Java中javax.media.opengl.GL2.glDisable方法的典型用法代碼示例。如果您正苦於以下問題:Java GL2.glDisable方法的具體用法?Java GL2.glDisable怎麽用?Java GL2.glDisable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.media.opengl.GL2的用法示例。


在下文中一共展示了GL2.glDisable方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: drawLine

import javax.media.opengl.GL2; //導入方法依賴的package包/類
protected void drawLine(DrawContext dc, Vec4 screenPoint, Vec4 projectedPoint, DetailedOrderedIcon uIcon) {
	//GL gl = dc.getGL();
	GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
	
	gl.glLoadIdentity();
	
	double opacity = uIcon.getOpacity();
	
	opacity = Math.min(opacity, .5f);
	
	gl.glDisable(GL.GL_TEXTURE_2D);
	gl.glColor4d(.2,.2,.2, opacity);
	
	gl.glBegin(GL.GL_LINES);
		gl.glVertex2d(screenPoint.x, screenPoint.y);
		gl.glVertex2d(projectedPoint.x, projectedPoint.y);
	gl.glEnd();
	gl.glEnable(GL.GL_TEXTURE_2D);
	
	gl.glColor4f(1,1,1,1);
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:22,代碼來源:DetailedIconRenderer.java

示例2: drawVertex

import javax.media.opengl.GL2; //導入方法依賴的package包/類
private Vector3f drawVertex(Vector3f vert, double size, float[] color, GL2 gl, GLUT glut) {
    gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL2.GL_AMBIENT, color, 0);
    gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, color, 0);
    gl.glMaterialf(GL.GL_FRONT_AND_BACK, GL2.GL_SHININESS, 10);

    gl.glPushAttrib(GL2.GL_LIGHTING_BIT);
    gl.glDisable(GL2.GL_TEXTURE_2D);
    gl.glEnable(GL2.GL_LIGHTING);

    gl.glPushMatrix();
    gl.glTranslatef(vert.getX(), vert.getY(), vert.getZ());

    glut.glutSolidSphere(size, 20, 20);
    gl.glPopMatrix();

    gl.glEnable(GL2.GL_TEXTURE_2D);
    gl.glDisable(GL2.GL_LIGHTING);
    gl.glPopAttrib();

    return vert;
}
 
開發者ID:Fidentis,項目名稱:Analyst,代碼行數:22,代碼來源:PApainting.java

示例3: drawWithoutTextures

import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
 *
 * @param gl
 * @param dropFaces faces to be hidden when rendering model.
 */
public void drawWithoutTextures(GL2 gl, ArrayList<Integer> dropFaces) {

    gl.glPushMatrix();
    gl.glPushAttrib(GL2.GL_LIGHTING_BIT);
    for (int i = 0; i < faces.getNumFaces(); i++) {

        gl.glDisable(GL2.GL_TEXTURE_2D);
        gl.glEnable(GL2.GL_LIGHTING);

        faces.renderFace(i, flipTexCoords, gl);

        gl.glEnable(GL2.GL_TEXTURE_2D);
        gl.glDisable(GL2.GL_LIGHTING);

    }
    gl.glPopAttrib();
    gl.glPopMatrix();

}
 
開發者ID:Fidentis,項目名稱:Analyst,代碼行數:25,代碼來源:Model.java

示例4: draw

import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
 * Draws the terrain.
 *
 * @param gl       The instance of GL2 responsible for drawing the body.
 * @param glut     An instance of GLUT that can be optionally used to assist
 *                 in drawing.
 * @param camPos   The position of the camera in world coordinates.
 * @param lighting The Lighting instance responsible for calculating the
 *                 lighting in this scene. Can be used to set the colours of
 *                 bodies before drawing them.
 */
public void draw(GL2 gl, GLUT glut, Vector camPos, Lighting lighting) {
    gl.glPushMatrix();
    {
        gl.glTranslated(TERRAIN_LEVEL.x(), TERRAIN_LEVEL.y(), TERRAIN_LEVEL.z());
        gl.glEnable(GL_CULL_FACE);
        lighting.setMaterial(gl, Material.DIRT, true);
        terrainBody.draw(gl);
        lighting.setMaterial(gl, Material.WATER);
        waterBody.draw(gl);
        gl.glDisable(GL_CULL_FACE);
        final Vector camPosRelativeToTerrain = camPos.subtract(TERRAIN_LEVEL);
        trees.stream().forEach((tree) -> tree.draw(gl, camPosRelativeToTerrain, lighting));
    }
    gl.glPopMatrix();
}
 
開發者ID:ABoschman,項目名稱:2IV60_RobotRace,代碼行數:27,代碼來源:Terrain.java

示例5: renderPatchBoundary

import javax.media.opengl.GL2; //導入方法依賴的package包/類
protected void renderPatchBoundary(DrawContext dc, RectTile tile)
{
   // GL gl = dc.getGL();
	GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
    OGLStackHandler ogsh = new OGLStackHandler();

    ogsh.pushAttrib(gl, GL2.GL_ENABLE_BIT | GL2.GL_CURRENT_BIT | GL2.GL_POLYGON_BIT);
    try
    {
        gl.glDisable(GL.GL_BLEND);

        // Don't perform depth clipping but turn on backface culling
        gl.glDisable(GL.GL_DEPTH_TEST);
        gl.glEnable(GL.GL_CULL_FACE);
        gl.glCullFace(GL.GL_BACK);
        gl.glPolygonMode(GL.GL_FRONT, GL2.GL_LINE);

        Vec4[] corners = tile.sector.computeCornerPoints(dc.getGlobe(), dc.getVerticalExaggeration());

        gl.glColor4d(1d, 0, 0, 1d);
        gl.glBegin(javax.media.opengl.GL2.GL_QUADS);
        gl.glVertex3d(corners[0].x, corners[0].y, corners[0].z);
        gl.glVertex3d(corners[1].x, corners[1].y, corners[1].z);
        gl.glVertex3d(corners[2].x, corners[2].y, corners[2].z);
        gl.glVertex3d(corners[3].x, corners[3].y, corners[3].z);
        gl.glEnd();
    }
    finally
    {
        ogsh.pop(gl);
    }
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:33,代碼來源:MYEBSRectangularTessellator.java

示例6: drawArrow

import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void drawArrow(Vector3f from, Vector3f to, float[] color, GL2 gl, GLUT glut) {
    Vector3f zAxis = new Vector3f(0, 0, 1);
    Vector3f vector = new Vector3f(to.x - from.x, to.y - from.y, to.z - from.z);
    float length = vector.length();
    vector.normalize();
    float angle = zAxis.angle(vector);
    Vector3f axis = new Vector3f();
    axis.cross(zAxis, vector);
    float convert = (float) (180f / Math.PI);

    gl.glPushAttrib(GL2.GL_LIGHTING_BIT);
    gl.glDisable(GL2.GL_TEXTURE_2D);
    gl.glEnable(GL2.GL_LIGHTING);

    gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL2.GL_AMBIENT, color, 0);
    gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, color, 0);
    gl.glMaterialf(GL.GL_FRONT_AND_BACK, GL2.GL_SHININESS, 10);

    gl.glPushMatrix();

    gl.glTranslatef(from.x, from.y, from.z);
    gl.glRotatef(angle * convert, axis.x, axis.y, axis.z);
    glut.glutSolidCylinder(info.getPointSize() / 3, length - info.getPointSize(), 20, 20);
    gl.glTranslatef(0, 0, length - info.getPointSize());
    glut.glutSolidCone(info.getPointSize(), info.getPointSize(), 20, 20);

    gl.glPopMatrix();

    gl.glEnable(GL2.GL_TEXTURE_2D);
    gl.glDisable(GL2.GL_LIGHTING);
    gl.glPopAttrib();
}
 
開發者ID:Fidentis,項目名稱:Analyst,代碼行數:33,代碼來源:PApainting.java

示例7: draw

import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
 *
 * @param gl
 */
public void draw(GL2 gl) {
    gl.glPushMatrix();
    gl.glPushAttrib(GL2.GL_LIGHTING_BIT);

    gl.glEnable(GL2.GL_LIGHTING);
    gl.glEnable(GL2.GL_TEXTURE_2D);

    if (materials != null) {
        materials.clearUsedMaterials();
    }
    // render the model face-by-face
    String faceMat;

    for (int i = 0; i < faces.getNumFaces(); i++) {

        faceMat = faces.findMaterial(i);      // get material used by face i
        if (faceMat != null && materials != null) {
            flipTexCoords = materials.renderWithMaterial(faceMat, gl);
        }  // render using that material

        faces.renderFace(i, flipTexCoords, gl);                  // draw face i
    }

    gl.glDisable(GL2.GL_TEXTURE_2D);
    gl.glEnable(GL2.GL_LIGHTING);

    gl.glPopAttrib();
    gl.glPopMatrix();

}
 
開發者ID:Fidentis,項目名稱:Analyst,代碼行數:35,代碼來源:Model.java

示例8: resetBlending

import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void resetBlending(Map<String, Object> params) {
  GL2 gl = drawable.getGL().getGL2();
  IntBuffer sourceFactor = (IntBuffer) params.get("sourceFactor");
  IntBuffer destinationFactor = (IntBuffer) params.get("destinationFactor");
  gl.glBlendFunc(sourceFactor.get(0), destinationFactor.get(0));

  IntBuffer equation = (IntBuffer) params.get("equation");
  gl.glBlendEquation(equation.get(0));

  boolean enabled = (boolean) params.get("enabled");
  if (enabled == false) {
    gl.glDisable(GL_BLEND);
  }
}
 
開發者ID:StefanoaicaLucian,項目名稱:ParticleEffectsAPI,代碼行數:15,代碼來源:DefaultPEL.java

示例9: begin

import javax.media.opengl.GL2; //導入方法依賴的package包/類
protected void begin(DrawContext dc)
	{
		GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
		//GL gl = dc.getGL();

		gl.glPushAttrib(
			GL2.GL_TEXTURE_BIT | 
			GL2.GL_ENABLE_BIT | 
			GL2.GL_CURRENT_BIT | 
			GL2.GL_LIGHTING_BIT | 
			GL2.GL_TRANSFORM_BIT |
			GL.GL_DEPTH_FUNC);
		
		
		gl.glDisable(GL.GL_TEXTURE_2D);
		gl.glDisable(GL2.GL_LIGHTING);
		
		if (dc.isPickingMode())
			pickSupport.beginPicking(dc);
		else
		{
			gl.glEnable(GL.GL_BLEND);
			gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
		}	

//		gl.glDisable(GL.GL_DEPTH_TEST);
//		gl.glDepthFunc(GL.GL_ALWAYS);
		
//		gl.glDisable(GL.GL_COLOR_MATERIAL);

//		gl.glLightfv(GL.GL_LIGHT1, GL.GL_POSITION, lightPosition, 0);
//		gl.glLightfv(GL.GL_LIGHT1, GL.GL_DIFFUSE, lightDiffuse, 0);
//		gl.glLightfv(GL.GL_LIGHT1, GL.GL_AMBIENT, lightAmbient, 0);
//		gl.glLightfv(GL.GL_LIGHT1, GL.GL_SPECULAR, lightSpecular, 0);
//
//		gl.glDisable(GL.GL_LIGHT0);
//		gl.glEnable(GL.GL_LIGHT1);
//		gl.glEnable(GL.GL_LIGHTING);
//		gl.glEnable(GL.GL_NORMALIZE);


		gl.glMatrixMode(GL2.GL_MODELVIEW);
		gl.glPushMatrix();
		
	}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:46,代碼來源:FMSRenderer.java

示例10: compileFMS

import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void compileFMS(DrawContext dc, float strike, float dip, float rake, float strike2, float dip2, float rake2) 
{
	GLU glu = dc.getGLU(); 
	//GL gl = dc.getGL();
	GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
	
	double[] a = {0,0,1, 0};
	double[] b = {0,0,-1, 0};
	
	double radius = .95;
	int slices = 36;
	int stacks = 18;
	
	double[][][] planes 
		= new double[][][] { {a,a}, {b,a}, {a,b}, {b,b}};
	
	for (int i = 0; i < 4; i++)
	{
		gl.glNewList(glListId + i, GL2.GL_COMPILE);
		
		gl.glPushMatrix();
		gl.glRotatef(strike, 0, 0, -1);
		gl.glRotatef(dip, 0, -1, 0);
		
		gl.glClipPlane(GL2.GL_CLIP_PLANE0, planes[i][0], 0);
		gl.glPopMatrix();
		
		gl.glPushMatrix();
		gl.glRotatef(strike2, 0, 0, -1);
		gl.glRotatef(dip2, 0, -1, 0);
		
		gl.glClipPlane(GL2.GL_CLIP_PLANE1, planes[i][1], 0);
		gl.glPopMatrix();

		gl.glEnable(GL2.GL_CLIP_PLANE0);
		gl.glEnable(GL2.GL_CLIP_PLANE1);
		
		glu.gluSphere(quadric, radius, slices, stacks);

		gl.glDisable(GL2.GL_CLIP_PLANE0);
		gl.glDisable(GL2.GL_CLIP_PLANE1);
		
		gl.glEndList();
	}
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:46,代碼來源:FMSRenderer.java

示例11: render

import javax.media.opengl.GL2; //導入方法依賴的package包/類
@SuppressWarnings("static-access")
protected void render(GL2 gl2) {
    if (use_draw_pixels_ || view_width_ == 0 || view_height_ == 0) {
        return;
    }

    assert (initialized_context_ != null);

    final float[] vertex_data = {
            //tu,   tv,     x,     y,    z
            0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, 0.0f };
    FloatBuffer vertices = FloatBuffer.wrap(vertex_data);

    gl2.glClear(gl2.GL_COLOR_BUFFER_BIT | gl2.GL_DEPTH_BUFFER_BIT);

    gl2.glMatrixMode(gl2.GL_MODELVIEW);
    gl2.glLoadIdentity();

    // Match GL units to screen coordinates.
    gl2.glViewport(0, 0, view_width_, view_height_);
    gl2.glMatrixMode(gl2.GL_PROJECTION);
    gl2.glLoadIdentity();

    // Draw the background gradient.
    gl2.glPushAttrib(gl2.GL_ALL_ATTRIB_BITS);
    gl2.glBegin(gl2.GL_QUADS);
    gl2.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);  // red
    gl2.glVertex2f(-1.0f, -1.0f);
    gl2.glVertex2f(1.0f, -1.0f);
    gl2.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);  // blue
    gl2.glVertex2f(1.0f, 1.0f);
    gl2.glVertex2f(-1.0f, 1.0f);
    gl2.glEnd();
    gl2.glPopAttrib();

    // Rotate the view based on the mouse spin.
    if (spin_x_ != 0) {
        gl2.glRotatef(-spin_x_, 1.0f, 0.0f, 0.0f);
    }
    if (spin_y_ != 0) {
        gl2.glRotatef(-spin_y_, 0.0f, 1.0f, 0.0f);
    }

    if (transparent_) {
        // Alpha blending style. Texture values have premultiplied alpha.
        gl2.glBlendFunc(gl2.GL_ONE, gl2.GL_ONE_MINUS_SRC_ALPHA);

        // Enable alpha blending.
        gl2.glEnable(gl2.GL_BLEND);
    }

    // Enable 2D textures.
    gl2.glEnable(gl2.GL_TEXTURE_2D);

    // Draw the facets with the texture.
    assert (texture_id_[0] != 0);
    gl2.glBindTexture(gl2.GL_TEXTURE_2D, texture_id_[0]);
    gl2.glInterleavedArrays(gl2.GL_T2F_V3F, 0, vertices);
    gl2.glDrawArrays(gl2.GL_QUADS, 0, 4);

    // Disable 2D textures.
    gl2.glDisable(gl2.GL_TEXTURE_2D);

    if (transparent_) {
        // Disable alpha blending.
        gl2.glDisable(gl2.GL_BLEND);
    }
}
 
開發者ID:Panda-Programming-Language,項目名稱:Pandomium,代碼行數:69,代碼來源:CefRenderer.java

示例12: drawFaceShape

import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void drawFaceShape(List<Vector3f> fps, float[] color, GL2 gl, GLUT glut) {

        gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL2.GL_AMBIENT, color, 0);
        gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, color, 0);
        gl.glMaterialf(GL.GL_FRONT_AND_BACK, GL2.GL_SHININESS, 10);

        //gl.glPushAttrib(GL2.GL_LIGHTING_BIT);
        gl.glDisable(GL2.GL_TEXTURE_2D);
        gl.glDisable(GL2.GL_LIGHTING);
        gl.glEnable(GL2.GL_LIGHTING);
        gl.glEnable(GL2.GL_NORMALIZE);

        
        //celo nos
        drawCylinder(fps.get(4), fps.get(8), gl, glut);
        drawCylinder(fps.get(8), fps.get(9), gl, glut);
        drawCylinder(fps.get(4), fps.get(10), gl, glut);

        //brada
        drawCylinder(fps.get(11), fps.get(12), gl, glut);
        drawCylinder(fps.get(12), fps.get(13), gl, glut);

        //usta
        drawCylinder(fps.get(6), fps.get(5), gl, glut);
        drawCylinder(fps.get(5), fps.get(7), gl, glut);

        drawCylinder(fps.get(6), fps.get(10), gl, glut);
        drawCylinder(fps.get(10), fps.get(7), gl, glut);

        drawCylinder(fps.get(6), fps.get(11), gl, glut);
        drawCylinder(fps.get(11), fps.get(7), gl, glut);

        drawCylinder(fps.get(10), fps.get(5), gl, glut);
        drawCylinder(fps.get(5), fps.get(11), gl, glut);
        //oci -- zanedbava nespecifikovane body v strede oka
        /*drawCylinder(fps.get(1), fps.get(14), gl, glut);
        drawCylinder(fps.get(14), fps.get(3), gl, glut);*/
        
        drawCylinder(fps.get(1), fps.get(3), gl, glut);
        //drawCylinder(fps.get(3), fps.get(8), gl, glut);

        /*drawCylinder(fps.get(0), fps.get(15), gl, glut);
        drawCylinder(fps.get(15), fps.get(2), gl, glut);*/
        drawCylinder(fps.get(0), fps.get(2), gl, glut);
        //drawCylinder(fps.get(2), fps.get(8), gl, glut);

        gl.glEnable(GL2.GL_TEXTURE_2D);
        gl.glDisable(GL2.GL_LIGHTING);
        gl.glPopAttrib();
    }
 
開發者ID:Fidentis,項目名稱:Analyst,代碼行數:51,代碼來源:PApainting.java

示例13: paintNormals

import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void paintNormals(GL2 gl) {
    info.c.assignGl(gl);
    Faces faces = info.getModel().getFaces();
    
    List<Vector3f> mesh = info.getModel().getVerts();
    List<Vector3f> normals = info.getModel().getNormals();

    List<Float> distanceCopy = new ArrayList<>(info.getDistance().size());

    for (Float f : info.getDistance()) {
        if (!info.isUseRelative()) {
            distanceCopy.add(Math.abs(f));
        } else {
            distanceCopy.add(f);
        }
    }

    float[] color = new float[3];
    color[0] = 0.8667f;
    color[1] = 0.7176f;
    color[2] = 0.6275f;

    gl.glPushAttrib(GL_ALL_ATTRIB_BITS);

    Vector3f normal;

    gl.glDisable(GL2.GL_TEXTURE_2D);
    gl.glEnable(GL2.GL_LIGHTING);
    
    for (int i = 0; i < faces.getNumFaces(); i++) {

        int[] facesInd = faces.getFaceVertIdxs(i);
        int[] faceNormIndex = faces.getFaceNormalIdxs(i);

        gl.glBegin(GL.GL_TRIANGLES);
        for (int f = 0; f < facesInd.length; f++) {
            if (faceNormIndex[f] != 0) {  // if there are normals, render them
                normal = normals.get(faceNormIndex[f] - 1);
                gl.glNormal3d(normal.getX(), normal.getY(), normal.getZ());
            }

            float[] ambient = {0.1f, 0.1f, 0.1f, 0.0f};
            gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_AMBIENT, ambient, 0);
            gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, color, 0);
            gl.glMaterialf(GL2.GL_FRONT_AND_BACK, GL2.GL_SHININESS, 10);

            float[] colorKs = {0, 0, 0, 1.0f};
            gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_SPECULAR, colorKs, 0);
            gl.glVertex3f(mesh.get(facesInd[f] - 1).getX(), mesh.get(facesInd[f] - 1).getY(), mesh.get(facesInd[f] - 1).getZ());
        }
        gl.glEnd();
    }

    if (info.getRecompute()) {
        recomputeNormals(gl, info, distanceCopy);
        info.setRecompute(false);
    }
    gl.glEnableClientState(gl.GL_VERTEX_ARRAY);
        info.c.draw();
    gl.glDisableClientState(gl.GL_VERTEX_ARRAY);
 
    gl.glPopAttrib();
}
 
開發者ID:Fidentis,項目名稱:Analyst,代碼行數:64,代碼來源:HDpainting.java

示例14: render

import javax.media.opengl.GL2; //導入方法依賴的package包/類
@SuppressWarnings("static-access")
protected void render(GL2 gl2) {
  if (use_draw_pixels_ || view_width_ == 0 || view_height_ == 0)
    return;

  assert(initialized_context_ != null);

  final float[] vertex_data = {
      //tu,   tv,     x,     y,    z
      0.0f, 1.0f, -1.0f, -1.0f, 0.0f,
      1.0f, 1.0f,  1.0f, -1.0f, 0.0f,
      1.0f, 0.0f,  1.0f,  1.0f, 0.0f,
      0.0f, 0.0f, -1.0f,  1.0f, 0.0f
  };
  FloatBuffer vertices = FloatBuffer.wrap(vertex_data);

  gl2.glClear(gl2.GL_COLOR_BUFFER_BIT | gl2.GL_DEPTH_BUFFER_BIT);

  gl2.glMatrixMode(gl2.GL_MODELVIEW);
  gl2.glLoadIdentity();

  // Match GL units to screen coordinates.
  gl2.glViewport(0, 0, view_width_, view_height_);
  gl2.glMatrixMode(gl2.GL_PROJECTION);
  gl2.glLoadIdentity();
  gl2.glOrtho(0, 0, view_width_, view_height_, 0.1, 100.0);

  // Draw the background gradient.
  gl2.glPushAttrib(gl2.GL_ALL_ATTRIB_BITS);
  gl2.glBegin(gl2.GL_QUADS);
  gl2.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);  // red
  gl2.glVertex2f(-1.0f, -1.0f);
  gl2.glVertex2f(1.0f, -1.0f);
  gl2.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);  // blue
  gl2.glVertex2f(1.0f, 1.0f);
  gl2.glVertex2f(-1.0f, 1.0f);
  gl2.glEnd();
  gl2.glPopAttrib();

  // Rotate the view based on the mouse spin.
  if (spin_x_ != 0)
    gl2.glRotatef(-spin_x_, 1.0f, 0.0f, 0.0f);
  if (spin_y_ != 0)
    gl2.glRotatef(-spin_y_, 0.0f, 1.0f, 0.0f);

  if (transparent_) {
    // Alpha blending style. Texture values have premultiplied alpha.
    gl2.glBlendFunc(gl2.GL_ONE, gl2.GL_ONE_MINUS_SRC_ALPHA);

    // Enable alpha blending.
    gl2.glEnable(gl2.GL_BLEND);
  }

  // Enable 2D textures.
  gl2.glEnable(gl2.GL_TEXTURE_2D);

  // Draw the facets with the texture.
  assert(texture_id_[0] != 0);
  gl2.glBindTexture(gl2.GL_TEXTURE_2D, texture_id_[0]);
  gl2.glInterleavedArrays(gl2.GL_T2F_V3F, 0, vertices);
  gl2.glDrawArrays(gl2.GL_QUADS, 0, 4);

  // Disable 2D textures.
  gl2.glDisable(gl2.GL_TEXTURE_2D);

  if (transparent_) {
    // Disable alpha blending.
    gl2.glDisable(gl2.GL_BLEND);
  }
}
 
開發者ID:viglucci,項目名稱:app-jcef-example,代碼行數:71,代碼來源:CefRenderer.java

示例15: draw

import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void draw(GL2 gl, float height) {
	// Update and fetch texture.
	if (adapter.toDraw()) {
		adapter.bindTexture(gl);
		Texture tex = adapter.getTexture();
		
		if (tex != null) {
			gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
			tex.bind(gl);
			
			TextureCoords texCoords = tex.getImageTexCoords();
			
			
			FloatBoundingBox box = adapter.getDrawBox();
			FloatVector3D upperLeft = box.getUpperLeft();
			FloatVector3D upperRight = box.getUpperRight();
			FloatVector3D lowerLeft = box.getLowerLeft();
			FloatVector3D lowerRight = box.getLowerRight();
			
			gl.glMatrixMode(GL2.GL_PROJECTION);
			gl.glLoadIdentity();
			gl.glOrthof(-1, 1, 
						-1, 1, 
						-10000, 10000);
			
			gl.glDisable(GL2.GL_DEPTH_TEST);
			
			gl.glMatrixMode(GL2.GL_MODELVIEW);
			
			// Lift the x-y-pane up:
			gl.glTranslatef(0, 0, height);
			
			// Draw texture.
			gl.glBegin(GL2.GL_QUADS);
			gl.glTexCoord2f(texCoords.left(), texCoords.top());
			gl.glVertex3f(upperLeft.getX(), upperLeft.getY(), 0.0f);
			gl.glTexCoord2f(texCoords.left(), texCoords.bottom());
			gl.glVertex3f(lowerLeft.getX(), lowerLeft.getY(), 0.0f);
			gl.glTexCoord2f(texCoords.right(), texCoords.bottom());
			gl.glVertex3f(lowerRight.getX(), lowerRight.getY(), 0.0f);
			gl.glTexCoord2f(texCoords.right(), texCoords.top());
			gl.glVertex3f(upperRight.getX(), upperRight.getY(), 0.0f);
			gl.glEnd();
		}
	}
	
	// Draw next layer if available.
	if (this.hasNextLayer()) {
		this.getNextLayer().draw(gl, height + HEIGHT_GAP);			
	}
}
 
開發者ID:johb,項目名稱:GAIA,代碼行數:53,代碼來源:WeatherLayer.java


注:本文中的javax.media.opengl.GL2.glDisable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。