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


Java GL2.glBlendFunc方法代码示例

本文整理汇总了Java中com.jogamp.opengl.GL2.glBlendFunc方法的典型用法代码示例。如果您正苦于以下问题:Java GL2.glBlendFunc方法的具体用法?Java GL2.glBlendFunc怎么用?Java GL2.glBlendFunc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jogamp.opengl.GL2的用法示例。


在下文中一共展示了GL2.glBlendFunc方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: annotate

import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
@Override
public void annotate(final GLAutoDrawable drawable) {
	if (!showHotPixels) {
		return;
	}
	final GL2 gl = drawable.getGL().getGL2();
	try {
		gl.glEnable(GL.GL_BLEND);
		gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
		gl.glBlendEquation(GL.GL_FUNC_ADD);
	}
	catch (final GLException e) {
		e.printStackTrace();
		showHotPixels = false;
	}
	gl.glColor4f(.1f, .1f, 1f, .25f);
	gl.glLineWidth(1f);
	for (final HotPixel p : hotPixelSet) {
		gl.glRectf(p.x - 1, p.y - 1, p.x + 2, p.y + 2);
	}
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:22,代码来源:HotPixelFilter.java

示例2: drawPolygon

import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
private void drawPolygon(final GL2 gl, final int xLowerLeft, final int yLowerLeft, final int width, final int height) {
    gl.glPushMatrix();
    gl.glDisable(GL.GL_DEPTH_TEST);
    gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
    gl.glEnable(GL.GL_BLEND);
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL2.GL_CLAMP);
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL2.GL_CLAMP);
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST);
    final double xRatio = (double) chip.getSizeX() / (double) width;
    final double yRatio = (double) chip.getSizeY() / (double) height;
    gl.glBegin(GL2.GL_POLYGON);

    gl.glTexCoord2d(0, 0);
    gl.glVertex2d(xLowerLeft, yLowerLeft);
    gl.glTexCoord2d(xRatio, 0);
    gl.glVertex2d(xRatio * width + xLowerLeft, yLowerLeft);
    gl.glTexCoord2d(xRatio, yRatio);
    gl.glVertex2d(xRatio * width + xLowerLeft, yRatio * height + yLowerLeft);
    gl.glTexCoord2d(0, yRatio);
    gl.glVertex2d(+xLowerLeft, yRatio * height + yLowerLeft);

    gl.glEnd();
    gl.glPopMatrix();
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:26,代码来源:RoShamBoCNN.java

示例3: checkBlend

import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/** Convenience method to check if blending in OpenGL is available, and if so, to turn it on.
 * 
 * @param gl the GL2 context
 */
protected void checkBlend(GL2 gl) {
    if (!hasBlendChecked) {
        hasBlendChecked = true;
        String glExt = gl.glGetString(GL.GL_EXTENSIONS);
        if (glExt.indexOf("GL_EXT_blend_color") != -1) {
            hasBlend = true;
        }
    }
    if (hasBlend) {
        try {
            gl.glEnable(GL.GL_BLEND);
            gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE);
            gl.glBlendEquation(GL.GL_FUNC_ADD);
        } catch (GLException e) {
            log.warning("tried to use glBlend which is supposed to be available but got following exception");
            gl.glDisable(GL.GL_BLEND);
            e.printStackTrace();
            hasBlend = false;
        }
    }
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:26,代码来源:EventFilter.java

示例4: drawDecisionOutput

import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
private void drawDecisionOutput(int third, GL2 gl, int sy, AbstractDavisCNN net, Color color) {

        System.out.printf("max heat value is: %f\n", outputProbVal);
        try {
                gl.glEnable(GL.GL_BLEND);
                gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
                gl.glBlendEquation(GL.GL_FUNC_ADD);
        }
        catch (final GLException e) {
                e.printStackTrace();
        }
        gl.glColor4f(1f, .1f, .1f, .25f);
        gl.glLineWidth(1f);
        gl.glRectf((int)outputX - 10, (int)outputY - 10, (int)outputX + 12, (int)outputY + 12);
    }
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:16,代码来源:HeatMapCNN.java

示例5: annotate

import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
@Override
public void annotate(GLAutoDrawable drawable) {
    final GL2 gl = drawable.getGL().getGL2();
    try {
            gl.glEnable(GL.GL_BLEND);
            gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
            gl.glBlendEquation(GL.GL_FUNC_ADD);
    }
    catch (final GLException e) {
            e.printStackTrace();
    }        
    gl.glColor4f(1f, .1f, .1f, .25f);
    gl.glLineWidth(1f);
    
    if(displayParticles) {
        gl.glColor4f(.1f, 1f, .1f, .25f);

        for(int i = 0; i < filter.getParticleCount(); i ++) {            
            gl.glRectd(filter.get(i).getX() - 0.5, filter.get(i).getY() - 0.5, filter.get(i).getX() + 0.5, filter.get(i).getY() + 0.5);
        }            
    }
    
    gl.glColor4f(.1f, .1f, 1f, .25f);

    gl.glRectf((int)outputX - 10, (int)outputY - 10, (int)outputX + 12, (int)outputY + 12);

    // }    
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:29,代码来源:ParticleFilterTracking.java

示例6: draw

import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
public void draw(GL2 gl) {
    if (rgba == null) {
        return;
    }
    float maxActivation = 0;
    int maxActivatedUnit = -1;
    for (int i = 0; i < rgba.length; i++) {
        if (rgba[i] > maxActivation) {
            maxActivation = rgba[i];
            maxActivatedUnit = i;
        }
    }
    if (maxActivation < decisionThreshold) {
        return;
    }
    final int dt = lastTimestampUs - lastDecisionTimestampUs;
    if (dt < 0 || (dt) >>> 10 >= getDecisionLifetimeMs()) {
        return;
    }
    try {
        gl.glEnable(GL2.GL_BLEND);
        gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_CONSTANT_ALPHA);
        gl.glBlendEquation(GL2.GL_FUNC_ADD); // use additive color here to just brighten the pixels already there
        gl.glBlendColor(1, 1, 1, 1);
    } catch (final GLException e) {
        e.printStackTrace();
    }
    gl.glColor4fv(rgba, 0);

    gl.glRectf(xLeft, yBot, xRight < chip.getSizeX() ? xRight : chip.getSizeX(), yTop < chip.getSizeY() ? yTop : chip.getSizeY());
    if (roiLastUpdated == this) {
        // mark it
        gl.glColor4f(1, 1, 1, 0.25f);
        gl.glPushMatrix();
        DrawGL.drawBox(gl, xCenter, yCenter, getWidth() << scale, getHeight() << scale, 0);
        gl.glPopMatrix();
    }
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:39,代码来源:DvsFramerROIGenerator.java

示例7: display

import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
@Override
public void display(Graphics3D graphics) {
	AWTGraphics3D g = (AWTGraphics3D) graphics;
	GL2 gl = g.getGL2();  // get the OpenGL 2 graphics context
	gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); // clear color and depth buffers
	gl.glLoadIdentity();  // reset the model-view matrix
	gl.glClearColor(1f,1f,1f,1f);
	
	g.setColor(Color.WHITE);
	gl.glTranslatef(0.0f, 0.0f, -15.0f); // translate into the screen
	//gl.glScaled(150, 150, 150);
	gl.glRotated(angleY, 0, 1, 0);
	
	//Draw Models
	//Start batch
	gl.glEnable(GL.GL_DEPTH_TEST);

	gl.glPushMatrix();
	stone.renderTextured(gl);
	gl.glPopMatrix();
	
	gl.glPushMatrix();
	gl.glDisable(GL.GL_CULL_FACE);
	gl.glEnable(GL.GL_BLEND);
	gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
	
	tree.renderTextured(gl);
	gl.glPopMatrix();
	
	//End batch
	gl.glDisable(GL.GL_DEPTH_TEST);
	
	//Rotate Models
	if(rotate) {
		angleY += 1;
	}
}
 
开发者ID:Harium,项目名称:propan-jogl-examples,代码行数:38,代码来源:MeshExample.java

示例8: enableBlend

import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
void enableBlend(GL2 gl, boolean enabled){
    if (enabled != blend){
        if (enabled){
            gl.glEnable(GL2.GL_BLEND);
            gl.glBlendFunc (GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
        }else{
            gl.glDisable(GL2.GL_BLEND);
        }
        blend = enabled;
    }
}
 
开发者ID:asiermarzo,项目名称:Ultraino,代码行数:12,代码来源:Renderer.java

示例9: init

import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
@Override
public void init(GLAutoDrawable drawable)
{
	GL2 gl = drawable.getGL().getGL2();
	gl.glPointSize(5.0f);
	gl.glLineWidth(1.0f);

	gl.glEnable(GL2.GL_BLEND);
	
	gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
	
	
	
	gl.glMatrixMode(GL2.GL_PROJECTION);
	gl.glLoadIdentity();
	gl.glOrtho(-1, 1, -1, 1, 0.01, 1000);
	//gl.glMatrixMode(GL2.GL_MODELVIEW);
	
	
	gl.glEnable(GL2.GL_DEPTH_TEST);
	gl.glDepthFunc(GL2.GL_LEQUAL);

	
	// Enable smooth shading.
	gl.glShadeModel(GL2.GL_SMOOTH);
	gl.glEnable(GL2.GL_BLEND);
	gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);

	// Define "clear" color.
	gl.glClearColor(0f, 0f, 0f, 0f);

	// We want a nice perspective.
	gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL2.GL_NICEST);

	float[] pos = {1,-1,1,0};
	float[] diff = {1,1,1,1};

	gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_DIFFUSE, diff, 0);
	gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, pos, 0);
	gl.glEnable(GL2.GL_LIGHT0);
	gl.glEnable(GL2.GL_LIGHTING);
	gl.glEnable(GL2.GL_COLOR_MATERIAL);
	
	if(Shoot.DEBUG)
		drawable.getAnimator().setUpdateFPSFrames(25, System.out);

}
 
开发者ID:ben-j-c,项目名称:TopDownGame,代码行数:48,代码来源:Display.java

示例10: annotate

import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
@Override
public void annotate(GLAutoDrawable drawable) {
    super.annotate(drawable);
    GL2 gl = drawable.getGL().getGL2();
    gl.glEnable(GL.GL_BLEND);
    gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
    gl.glBlendEquation(GL.GL_FUNC_ADD);
    //gl.glPushMatrix();
    // Green background to show where the inhibition is
    gl.glPushMatrix();
    gl.glColor4f(0, 1, 0, 0.1f);
    gl.glRectf((0 << subsample),
            (0 << subsample),
            ((nxmax) << subsample),
            ((nymax) << subsample));
    gl.glPopMatrix();
    // Red squares to show where the cells are

    if (spikeRateHz[lastSpikedOMC[0]][lastSpikedOMC[1]] >= minSpikeRateHz) {
        gl.glPushMatrix();
        gl.glColor4f(1, 0, 0, 0.5f); //4 side centers
        float radius = (chip.getMaxSize() * subunitActivityBlobRadiusScale * spikeRateHz[lastSpikedOMC[0]][lastSpikedOMC[1]]) / maxSpikeRateHz / 2;
        gl.glRectf((((lastSpikedOMC[0] + 1) << subsample) - radius),
                (((lastSpikedOMC[1] + 1) << subsample) - radius),
                (((lastSpikedOMC[0] + 1) << subsample) + radius),
                (((lastSpikedOMC[1] + 1) << subsample) + radius));
        gl.glPopMatrix();
        //                        gl.glPushMatrix();
        // spikeRateHz[lastSpikedOMC[0]][lastSpikedOMC[1]] = 0;
    }

    if (counter < (2 - 1)) {
        counter++;
    } else {
        counter = 0;
    }
    if (counter == 0) {
        lastIndex = 2 - 1;
    } else {
        lastIndex = counter - 1;
    }

    if ((lastCheckTimestampUs - lastOMCTimeStamp) > (1000 * 50)) {//reset if long wait
        for (int index = 0; index < 2; index++) {
            for (int i = 0; i < 3; i++) {
                if (i == 0) { //store x
                    lastSpikedOMCArray[i][index] = lastSpikedOMC[0];
                }
                if (i == 1) { //store y
                    lastSpikedOMCArray[i][index] = lastSpikedOMC[1];
                }
                if (i == 2) { //store timestamp
                    lastSpikedOMCArray[i][index] = lastOMCTimeStamp;
                }
            }
        }
    }
    counterP = counter;
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:60,代码来源:OmcodFpgaVisualizer.java

示例11: draw

import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
public void draw(GL2 gl) {
            if (!displayMotionField || velocities == null) {
                return;
            }
            try {
                gl.glEnable(GL.GL_BLEND);
                gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
                gl.glBlendEquation(GL.GL_FUNC_ADD);
            } catch (GLException e) {
                e.printStackTrace();
            }
            float shift = ((1 << motionFieldSubsamplingShift) * .5f);
            final float saturationSpeedScaleInversePixels = ppsScale * 0.1f; // this length of vector in pixels makes full brightness
            for (int ix = 0; ix < sx; ix++) {
                float x = (ix << motionFieldSubsamplingShift) + shift;
                for (int iy = 0; iy < sy; iy++) {
                    final float y = (iy << motionFieldSubsamplingShift) + shift;
                    final int dt = ts - lastTs[ix][iy]; // use last timestamp of any event that is processed by extractEventInfo
                    gl.glColor4f(0, 0, 1, 1f);
                    final float dotRadius = .75f;
                    gl.glRectf(x - dotRadius, y - dotRadius, x + dotRadius, y + dotRadius);
                    if (dt > maxAgeUs || dt < 0) {
                        continue;
                    }
                    final float speed = velocities[ix][iy].getValue3D().z;
                    if (speed < minSpeedPpsToDrawMotionField) {
                        continue;
                    }
                    final Point3D p = velocities[ix][iy].getValue3D();
                    final float vx = p.x, vy = p.y;
                    float brightness = p.z * saturationSpeedScaleInversePixels;
                    if (brightness > 1) {
                        brightness = 1;
                    }
                    // TODO use motionColor()
                    float[] rgb;
                    if (displayMotionFieldUsingColor) {
                        rgb = motionColor(vx, vy, 1, 1);
                    } else {
                        rgb = new float[]{0, 0, 1};
                    }

                    gl.glColor4f(rgb[0], rgb[1], rgb[2], 1f);
                    gl.glLineWidth(motionVectorLineWidthPixels);
//                    gl.glColor4f(angle, 1 - angle, 1 / (1 + 10 * angle), .5f);
                    gl.glPushMatrix();
                    DrawGL.drawVector(gl, x, y, vx * ppsScale, vy * ppsScale, motionVectorLineWidthPixels, 1);
                    gl.glPopMatrix();
                    if (displayMotionFieldColorBlobs) {
                        gl.glColor4f(rgb[0], rgb[1], rgb[2], .01f);
                        final float s = shift / 4;
                        // draw a blurred square showing motion field direction
                        // TODO add brightness to show magnitude somehow
                        for (float dxx = -shift; dxx < shift; dxx += s) {
                            for (float dyy = -shift; dyy < shift; dyy += s) {
                                gl.glRectf(x - shift + dxx, y - shift + dyy, x + shift + dxx, y + shift + dyy);
                            }
                        }
                    }
                }
            }

        }
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:64,代码来源:AbstractMotionFlowIMU.java

示例12: draw

import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
public void draw(GL2 gl) {
    if (pxlScore == null) {
        return;
    }
    try {
        gl.glEnable(GL.GL_BLEND);
        gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
        gl.glBlendEquation(GL.GL_FUNC_ADD);
    } catch (GLException e) {
        e.printStackTrace();
    }
    float max = Float.NEGATIVE_INFINITY, min = Float.POSITIVE_INFINITY;
    for (int x = 0; x < mapSizeX; x++) {
        for (int y = 0; y < mapSizeY; y++) {
            float v = pxlScore[x][y];
            if (Float.isNaN(v)) {
                continue;
            }
            if (v > max) {
                max = v;
            } else if (v < min) {
                min = v;
            }
        }
    }
    if ((max > 0) && ((max - min) > 0)) {
        float diff = max - min;
        if (diff <= 0) {
            diff = 1;
        }
        final float displayTransparency = .9f;
        for (int x = 0; x < mapSizeX; x++) {
            for (int y = 0; y < mapSizeY; y++) {
                final float s = pxlScore[x][y];
                if (Float.isNaN(s)) {
                    continue;
                }
                float b = (s - min) / diff;
                gl.glColor4f(b, b, 0, displayTransparency);
                gl.glRectf(x, y, x + 1, y + 1);
            }
        }
    }
    textRenderer.begin3DRendering();
    textRenderer.setColor(1, 1, 0, 1);
    textRenderer.draw3D(String.format("max score=%.2f, min score=%.2f", max, min), 5, 5, 0, textScale); // x,y,z, scale factor
    textRenderer.end3DRendering();

}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:50,代码来源:FilterLaserline.java


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