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


Java GL2.glBlendFunc方法代碼示例

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


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

示例1: setBlending

import javax.media.opengl.GL2; //導入方法依賴的package包/類
private Map<String, Object> setBlending() {
  Map<String, Object> result = new HashMap<>();
  GL2 gl = drawable.getGL().getGL2();

  IntBuffer equation = Buffers.newDirectIntBuffer(1);
  gl.glGetIntegerv(GL_BLEND_EQUATION, equation);
  result.put("equation", equation);

  IntBuffer sourceFactor = Buffers.newDirectIntBuffer(1);
  gl.glGetIntegerv(GL_BLEND_SRC, sourceFactor);
  result.put("sourceFactor", sourceFactor);

  IntBuffer destinationFactor = Buffers.newDirectIntBuffer(1);
  gl.glGetIntegerv(GL_BLEND_DST, destinationFactor);
  result.put("destinationFactor", destinationFactor);

  boolean enabled = gl.glIsEnabled(GL_BLEND);
  result.put("enabled", enabled);

  gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE);
  gl.glBlendEquation(GL_FUNC_ADD);
  gl.glEnable(GL_BLEND);

  return result;
}
 
開發者ID:StefanoaicaLucian,項目名稱:ParticleEffectsAPI,代碼行數:26,代碼來源:DefaultPEL.java

示例2: setBlendingFunction

import javax.media.opengl.GL2; //導入方法依賴的package包/類
protected void setBlendingFunction(DrawContext dc)
{
	// Set up a premultiplied-alpha blending function. Any texture read by JOGL will have alpha-premultiplied color
	// components, as will any DDS file created by World Wind or the World Wind WMS. We'll also set up the base
	// color as a premultiplied color, so that any incoming premultiplied color will be properly combined with the
	// base color.

	//GL gl = dc.getGL();
	GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

	double alpha = this.getOpacity();
	gl.glColor4d(alpha, alpha, alpha, alpha);
	gl.glEnable(GL.GL_BLEND);
	gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE_MINUS_SRC_ALPHA);
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:16,代碼來源:ScalingTiledImageLayer.java

示例3: init

import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void init(GLAutoDrawable drawable) {
	GL2 gl = drawable.getGL().getGL2();
	this.drawable = drawable;

	if (AA_SMOOTHING) {
		// Anti-aliasing using Smoothing
		if (AA_SMOOTH_LINES) {
			gl.glEnable(GL2.GL_LINE_SMOOTH);
			gl.glHint(GL2.GL_LINE_SMOOTH_HINT, GL2.GL_NICEST);
		}

		// TODO: This AA method creates "transparency" in GLU polygons
		if (AA_SMOOTH_POLYGONS) {
			gl.glEnable(GL2.GL_POLYGON_SMOOTH);
			gl.glHint(GL2.GL_POLYGON_SMOOTH_HINT, GL2.GL_NICEST);
		}

		if (AA_SMOOTH_POINTS) {
			gl.glEnable(GL2.GL_POINT_SMOOTH);
			gl.glHint(GL2.GL_POINT_SMOOTH_HINT, GL2.GL_NICEST);
		}

		gl.glEnable(GL2.GL_BLEND);
		gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);

	} else if (AA_MULTISAMPLING) {
		// Anti-aliasing using Multisampling
		gl.glEnable(GL2.GL_MULTISAMPLE);
	}

	gl.glClearColor(1.0f, 1.0f, 1.0f, 0.0f);

	// Renderers
	this.vertexRenderer = new VertexRenderer(drawable, this);
	this.edgeRenderer = new EdgeRenderer(drawable, this);
	this.labelRenderer = new LabelRenderer(drawable, this);
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:38,代碼來源:NetworkRenderer.java

示例4: 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

示例5: draw

import javax.media.opengl.GL2; //導入方法依賴的package包/類
protected void draw(DrawContext dc)
{
    this.referencePoint = this.computeReferencePoint(dc);

    Position pos = dc.getView().getEyePosition();
    this.centerPoint = new LatLon(pos.getLatitude(), pos.getLongitude());
    
    this.assembleTiles(dc); // Determine the tiles to draw.

    if (this.currentTiles.size() >= 1)
    {
        TextureTile[] sortedTiles = new TextureTile[this.currentTiles.size()];
        sortedTiles = this.currentTiles.toArray(sortedTiles);
        Arrays.sort(sortedTiles, levelComparer);

        //GL gl = dc.getGL();
        GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

        if (this.isUseTransparentTextures() || this.getOpacity() < 1)
        {
            gl.glPushAttrib(GL.GL_COLOR_BUFFER_BIT | GL2.GL_POLYGON_BIT | GL2.GL_CURRENT_BIT);
            gl.glColor4d(1d, 1d, 1d, this.getOpacity());
            gl.glEnable(GL.GL_BLEND);
            gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
        }
        else
        {
            gl.glPushAttrib(GL.GL_COLOR_BUFFER_BIT | GL2.GL_POLYGON_BIT);
        }

        gl.glPolygonMode(GL.GL_FRONT, GL2.GL_FILL);
        gl.glEnable(GL.GL_CULL_FACE);
        gl.glCullFace(GL.GL_BACK);

        dc.setPerFrameStatistic(PerformanceStatistic.IMAGE_TILE_COUNT, this.tileCountName,
            this.currentTiles.size());
        dc.getGeographicSurfaceTileRenderer().renderTiles(dc, this.currentTiles);

        gl.glPopAttrib();

        if (this.drawTileIDs)
            this.drawTileIDs(dc, this.currentTiles);

        if (this.drawBoundingVolumes)
            this.drawBoundingVolumes(dc, this.currentTiles);

        this.currentTiles.clear();
    }

    this.sendRequests();
    this.requestQ.clear();
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:53,代碼來源:DynamicImageTileLayer.java

示例6: beginDrawIcons

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

	this.oglStackHandler.clear();

	int attributeMask =
		GL.GL_DEPTH_BUFFER_BIT // for depth test, depth mask and depth func
			| GL2.GL_TRANSFORM_BIT // for modelview and perspective
			| GL2.GL_VIEWPORT_BIT // for depth range
			| GL2.GL_CURRENT_BIT // for current color
			| GL.GL_COLOR_BUFFER_BIT // for alpha test func and ref, and blend
			| GL2.GL_TEXTURE_BIT // for texture env
			| GL.GL_DEPTH_BUFFER_BIT // for depth func
			| GL2.GL_ENABLE_BIT; // for enable/disable changes
	this.oglStackHandler.pushAttrib(gl, attributeMask);

	// Apply the depth buffer but don't change it.
	if ((!dc.isDeepPickingEnabled())) {
		gl.glEnable(GL.GL_DEPTH_TEST);
	}
	gl.glDepthMask(false);

	// Suppress any fully transparent image pixels
	gl.glEnable(GL2.GL_ALPHA_TEST);
	gl.glAlphaFunc(GL.GL_GREATER, 0.001f);

	// Load a parallel projection with dimensions (viewportWidth, viewportHeight)
	this.oglStackHandler.pushProjectionIdentity(gl);
	gl.glOrtho(0d, dc.getView().getViewport().width, 0d, dc.getView().getViewport().height, -16d, 16d);

	this.oglStackHandler.pushModelview(gl);
	this.oglStackHandler.pushTexture(gl);

	if (dc.isPickingMode())
	{
		this.pickSupport.beginPicking(dc);

		// Set up to replace the non-transparent texture colors with the single pick color.
		gl.glEnable(GL.GL_TEXTURE_2D);
		gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_COMBINE);
		gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_SRC0_RGB, GL2.GL_PREVIOUS);
		gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_COMBINE_RGB, GL2.GL_REPLACE);
	}
	else
	{
		gl.glEnable(GL.GL_TEXTURE_2D);
		gl.glEnable(GL.GL_BLEND);
		gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
	}

	//Only calculate pitch / heading once **
	heading = this.computeHeading(dc.getView());
	pitch = this.computePitch(dc.getView());
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:56,代碼來源:DetailedIconRenderer.java

示例7: 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

示例8: 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

示例9: 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

示例10: render

import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void render(GL2 gl) {
	
	// Create the credits texture if not done yet:
	if(creditsTexture == null) {
		createTexture();
	}
	
	if(creditsTexture != null) {
		// Activate alpha:
		gl.glEnable(GL2.GL_BLEND);
		gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
		
		// Bind the texture for use:
		creditsTexture.bind(gl);
		
		// The textures 2D-coordinates:
		TextureCoords texCoords = creditsTexture.getImageTexCoords();
		
		// Backup current matrix:
		gl.glPushMatrix();
		gl.glLoadIdentity();
		
		// Apply transformation:
		gl.glRotatef(rotation, 1, 0, 0);
		gl.glTranslatef(0, -2, position);
		gl.glRotatef(-90, 1, 0, 0);
		
		// Draw vertices and pass uv-coords.
		gl.glBegin(GL2.GL_QUADS);
		gl.glTexCoord2f(texCoords.right(), texCoords.top());
		gl.glVertex3f(CREDITS_PANE_WIDTH/2, CREDITS_PANE_HEIGHT/2, 0);
		gl.glTexCoord2f(texCoords.left(), texCoords.top());
		gl.glVertex3f(-CREDITS_PANE_WIDTH/2, CREDITS_PANE_HEIGHT/2, 0);
		gl.glTexCoord2f(texCoords.left(), texCoords.bottom());
		gl.glVertex3f(-CREDITS_PANE_WIDTH/2, -CREDITS_PANE_HEIGHT/2, 0);
		gl.glTexCoord2f(texCoords.right(), texCoords.bottom());
		gl.glVertex3f(CREDITS_PANE_WIDTH/2, -CREDITS_PANE_HEIGHT/2, 0);
		gl.glEnd();
		
		// Restore matrix:
		gl.glPopMatrix();
	}
}
 
開發者ID:johb,項目名稱:GAIA,代碼行數:44,代碼來源:Credits.java

示例11: 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

示例12: draw

import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void draw(GL2 gl, float height) {
	
	// If not done yet, invoke the adapters initialization:
	if(!adapterInitialized) {
		adapter.performGLInit(gl);
		adapterInitialized = true;
	}
	
	// Perform all the necessary OpenGL-stuff:
	adapter.performGLCalls(gl);
	
	// Update and fetch texture.
	Texture tex = adapter.getTexture(CopyrightAdapter.COPYRIGHT_TEXTURE_KEY);
	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();
		if(box != null) {
			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 (this.hasNextLayer()) {
		this.getNextLayer().draw(gl, height + HEIGHT_GAP);
	}
}
 
開發者ID:johb,項目名稱:GAIA,代碼行數:60,代碼來源:CopyrightLayer.java

示例13: draw

import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
 * Draws all Wikipedia-POIs available for the current view. Also all
 * OpenGL-specific work in the adapter must be performed here.
 */
@Override
public void draw(GL2 gl, float height) {
	WikipediaManager wikiManager = (WikipediaManager) ResourceMaster.getInstance().getResourceManager("Wikipedia");
	
	if (wikiManager.isEnabled() && adapter != null && gl != null) {
		// Check if the adapter was already initialized.
		// This must be done from the OpenGl-thread:
		if (!adapterInitialized) {
			adapter.performGLInit(gl);
		}

		// Do further processing in the OpenGL-context:
		adapter.performGLCalls(gl);

		// Get the texture querying with the default key:
		Texture texture = adapter
				.getTexture(WikipediaAdapter.WIKIPEDIA_TEXTURE_KEY);

		if (texture != null) {

			// The textures 2D-coordinates:
			TextureCoords texCoords = texture.getImageTexCoords();

			gl.glEnable(GL2.GL_BLEND);
			gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
			// Bind the texture for use with every marker to draw:
			texture.bind(gl);

			// Iterate all markers already converted into GL-coordinates:
			Collection<GLResource> glResources = adapter.getGLResources();
			for (GLResource current : glResources) {

				// Vertices to draw:
				FloatBoundingBox box = current.getBox();
				FloatVector3D[] vertices = box.getCornersCounterClockwise();

				// Backup the current Model-View-Matrix:
				gl.glPushMatrix();
				// Lift the x-y-pane up:
				gl.glTranslatef(0, 0, height);
				
				// Draw vertices and pass uv-coords.
				gl.glBegin(GL2.GL_QUADS);
				gl.glTexCoord2f(texCoords.right(), texCoords.top());
				gl.glVertex3f(vertices[0].getX(), vertices[0].getY(), 0);
				gl.glTexCoord2f(texCoords.left(), texCoords.top());
				gl.glVertex3f(vertices[1].getX(), vertices[1].getY(), 0);
				gl.glTexCoord2f(texCoords.left(), texCoords.bottom());
				gl.glVertex3f(vertices[2].getX(), vertices[2].getY(), 0);
				gl.glTexCoord2f(texCoords.right(), texCoords.bottom());
				gl.glVertex3f(vertices[3].getX(), vertices[3].getY(), 0);
				gl.glEnd();
				
				// Restore the old matrix:
				gl.glPopMatrix();
			}
		}
	}

	// Draw next layer.
	if (this.hasNextLayer()) {
		this.getNextLayer().draw(gl, height + HEIGHT_GAP);
	}
}
 
開發者ID:johb,項目名稱:GAIA,代碼行數:69,代碼來源:WikipediaLayer.java

示例14: draw

import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
 * Draws all POIs available for the current view. Also all OpenGL-specific
 * work in the adapter must be performed here.
 */
@Override
public void draw(GL2 gl, float height) {
	if (adapter != null && gl != null) {
		// Check if the adapter was already initialized.
		// This must be done from the OpenGl-thread:
		if (!adapterInitialized) {
			adapter.performGLInit(gl);
		}

		// Do further processing in the OpenGL-context:
		adapter.performGLCalls(gl);

		// Get the texture querying with the default key:
		Texture texture = adapter
				.getTexture(MarkerAdapter.MARKER_TEXTURE_KEY);

		if (texture != null) {

			// The textures 2D-coordinates:
			TextureCoords texCoords = texture.getImageTexCoords();

			gl.glEnable(GL2.GL_BLEND);
			gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
			// Bind the texture for use with every marker to draw:
			texture.bind(gl);

			// Iterate all markers already converted into GL-coordinates:
			Collection<GLResource> glResources = adapter.getGLResources();
			for (GLResource current : glResources) {

				// Vertices to draw:
				FloatBoundingBox box = current.getBox();
				FloatVector3D[] vertices = box.getCornersCounterClockwise();

				// Backup the current Model-View-Matrix:
				gl.glPushMatrix();
				// Lift the x-y-pane up:
				gl.glTranslatef(0, 0, height);
				
				// Draw vertices and pass uv-coords.
				gl.glBegin(GL2.GL_QUADS);
				gl.glTexCoord2f(texCoords.right(), texCoords.top());
				gl.glVertex3f(vertices[0].getX(), vertices[0].getY(), 0);
				gl.glTexCoord2f(texCoords.left(), texCoords.top());
				gl.glVertex3f(vertices[1].getX(), vertices[1].getY(), 0);
				gl.glTexCoord2f(texCoords.left(), texCoords.bottom());
				gl.glVertex3f(vertices[2].getX(), vertices[2].getY(), 0);
				gl.glTexCoord2f(texCoords.right(), texCoords.bottom());
				gl.glVertex3f(vertices[3].getX(), vertices[3].getY(), 0);
				gl.glEnd();
				
				// Restore the old matrix:
				gl.glPopMatrix();
			}
		}
	}

	// Draw next layer.
	if (this.hasNextLayer()) {
		this.getNextLayer().draw(gl, height + HEIGHT_GAP);
	}
}
 
開發者ID:johb,項目名稱:GAIA,代碼行數:67,代碼來源:MarkerLayer.java

示例15: draw

import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void draw(GL2 gl, float height) {
	
	// If not done yet, invoke the adapters initialization:
	if(!adapterInitialized) {
		adapter.performGLInit(gl);
	}
	
	// Perform all the necessary OpenGL-stuff:
	adapter.performGLCalls(gl);
	
	// Update and fetch texture.
	Texture tex = adapter.getTexture(CompassAdapter.COMPASS_TEXTURE_KEY);
	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 (this.hasNextLayer()) {
		this.getNextLayer().draw(gl, height + HEIGHT_GAP);
	}
}
 
開發者ID:johb,項目名稱:GAIA,代碼行數:57,代碼來源:CompassLayer.java


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