Java Code Examples for com.jogamp.opengl.GL#glBlendFunc()
The following examples show how to use
com.jogamp.opengl.GL#glBlendFunc() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BoxOverlay.java From clearvolume with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void render3D( ClearGLVolumeRenderer pClearGLVolumeRenderer, GL pGL, int pWidth, int pHeight, GLMatrix pProjectionMatrix, GLMatrix pModelViewMatrix) { if (isDisplayed()) { // if this flag is set, the box should be drawn with the clip box, // otherwise the full range -1,1 is used if (mAlignToClipBox) { float[] lClipBox = pClearGLVolumeRenderer.getClipBox(); if (!Arrays.equals(mClipBox, lClipBox)) updateClipBox(lClipBox); } mClearGeometryObject.setModelView(pModelViewMatrix); mClearGeometryObject.setProjection(pProjectionMatrix); pGL.glDisable(GL.GL_DEPTH_TEST); pGL.glEnable(GL.GL_CULL_FACE); pGL.glEnable(GL.GL_BLEND); pGL.glBlendFunc(GL.GL_ONE, GL.GL_ONE); pGL.glBlendEquation(GL2ES3.GL_MAX); pGL.glFrontFace(GL.GL_CW); mBoxGLProgram.use(pGL); mClearGeometryObject.draw(); mHasChanged = false; } }
Example 2
Source File: OpenGLUtil.java From haxademic with MIT License | 5 votes |
public static void setBlendMode(PGraphics pg, Blend blendMode) { GL gl = ((PJOGL)pg.beginPGL()).gl.getGL(); switch ( blendMode ) { case DEFAULT : gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); gl.glBlendEquation(GL.GL_FUNC_ADD); break; case ADD_SATURATE : gl.glBlendFunc(GL.GL_SRC_COLOR, GL.GL_SRC_COLOR); gl.glBlendEquation(GL.GL_FUNC_ADD); break; case ADDITIVE : gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE); gl.glBlendEquation(GL.GL_FUNC_ADD); break; case ALPHA_REVEAL : gl.glBlendFunc(GL.GL_SRC_COLOR, GL.GL_ONE_MINUS_SRC_COLOR); gl.glBlendEquation(GL.GL_FUNC_ADD); break; case DARK_INVERSE : gl.glBlendFunc(GL.GL_ONE_MINUS_DST_COLOR, GL.GL_ONE_MINUS_DST_COLOR); gl.glBlendEquation(GL.GL_FUNC_SUBTRACT); break; case LIGHT_ADD : gl.glBlendFunc(GL.GL_SRC_COLOR, GL.GL_SRC_ALPHA); gl.glBlendEquation(GL.GL_FUNC_ADD); break; case SATURATE : gl.glBlendFunc(GL.GL_SRC_COLOR, GL.GL_DST_ALPHA); gl.glBlendEquation(GL.GL_FUNC_ADD); break; } }
Example 3
Source File: CursorOverlay.java From clearvolume with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void render3D( ClearGLVolumeRenderer pClearGLVolumeRenderer, GL pGL, int pWidth, int pHeight, GLMatrix pProjectionMatrix, GLMatrix pModelViewMatrix) { if (isDisplayed()) { mPlaneX.setModelView(pModelViewMatrix); mPlaneY.setModelView(pModelViewMatrix); mPlaneZ.setModelView(pModelViewMatrix); mPlaneX.setProjection(pProjectionMatrix); mPlaneY.setProjection(pProjectionMatrix); mPlaneZ.setProjection(pProjectionMatrix); pGL.glDisable(GL.GL_DEPTH_TEST); pGL.glDisable(GL.GL_CULL_FACE); pGL.glEnable(GL.GL_BLEND); pGL.glBlendFunc(GL.GL_ONE, GL.GL_ONE); pGL.glBlendEquation(GL2ES3.GL_MAX); mBoxGLProgram.use(pGL); setPlanesVertices(); mPlaneX.updateVertices(mVerticesFloatArrayPlaneX.getFloatBuffer()); mPlaneY.updateVertices(mVerticesFloatArrayPlaneY.getFloatBuffer()); mPlaneZ.updateVertices(mVerticesFloatArrayPlaneZ.getFloatBuffer()); mBoxGLProgram.getUniform("alpha").setFloat(getAlpha()); mBoxGLProgram.getUniform("linethick") .setFloat(1.f / getLineThickness()); mBoxGLProgram.getUniform("linelength") .setFloat(1.f / getLineLength()); mBoxGLProgram.getUniform("lineperiod") .setFloat(getLinePeriod()); mBoxGLProgram.getUniform("boxlinesalpha") .setFloat(getBoxLinesAlpha()); mBoxGLProgram.getUniform("color").setFloatVector4(mColor); mBoxGLProgram.getUniform("linepos").setFloatVector2(y, z); mPlaneX.draw(); mBoxGLProgram.getUniform("linepos").setFloatVector2(x, z); mPlaneY.draw(); mBoxGLProgram.getUniform("linepos").setFloatVector2(x, y); mPlaneZ.draw(); mHasChanged = false; final float[] lProject = project( new float[] { 2 * x - 1, 2 * y - 1, 2 * z - 1, 1 }, pModelViewMatrix, pProjectionMatrix); px = pWidth * (0.5f * lProject[0] + 0.5f); py = pHeight * (1 - (0.5f * lProject[1] + 0.5f)); // System.out.format("px=%g py=%g \n", px, py); } }
Example 4
Source File: PathOverlay.java From clearvolume with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void render3D( ClearGLVolumeRenderer pClearGLVolumeRenderer, GL pGL, int pWidth, int pHeight, GLMatrix pProjectionMatrix, GLMatrix pModelViewMatrix) { if (isDisplayed()) { // mPath.getProgram().use(pGL); mBoxGLProgram.use(pGL); mPath.getProgram() .getUniform("vertexCount") .setInt((mPathPoints.getFloatBuffer().capacity() / 3)); mPath.getProgram() .getUniform("startColor") .setFloatVector4(mStartColor); mPath.getProgram() .getUniform("endColor") .setFloatVector4(mEndColor); mPath.setModelView(pModelViewMatrix); mPath.setProjection(pProjectionMatrix); pGL.glDisable(GL.GL_BLEND); pGL.glDisable(GL.GL_CULL_FACE); pGL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); pGL.glBlendEquation(GL.GL_FUNC_ADD); mPath.draw(); pGL.glEnable(GL.GL_BLEND); // mPathPoints.add(-0.2f + (float) Math.random() * ((0.2f - (-0.2f)) // + // 0.4f), -0.2f + (float)Math.random()* ((0.2f - (-0.2f)) + 0.4f), // -0.2f + // (float)Math.random()* ((0.2f - (-0.2f)) + 0.4f)); mPath.updateVertices(mPathPoints.getFloatBuffer()); } }
Example 5
Source File: GLBlendModes.java From haxademic with MIT License | 4 votes |
public static void setBlendModeFromPreset(PGraphics pg, int presetIndex) { int[] preset = presets[presetIndex]; GL gl = ((PJOGL)pg.beginPGL()).gl.getGL(); gl.glBlendFunc(GLBlendModes.blendFunctions[preset[0]], GLBlendModes.blendFunctions[preset[1]]); gl.glBlendEquation(GLBlendModes.blendEquations[preset[2]]); }
Example 6
Source File: GLBlendModes.java From haxademic with MIT License | 4 votes |
public static void setBlendModeFromPresetNoAlpha(PGraphics pg, int presetIndex) { int[] preset = presetsNoAlpha[presetIndex]; GL gl = ((PJOGL)pg.beginPGL()).gl.getGL(); gl.glBlendFunc(GLBlendModes.blendFunctions[preset[0]], GLBlendModes.blendFunctions[preset[1]]); gl.glBlendEquation(GLBlendModes.blendEquations[preset[2]]); }
Example 7
Source File: OpenGLUtil.java From haxademic with MIT License | 4 votes |
public static void setBlendModeCustom(PGraphics pg, int blendSrc, int blendDest, int blendEquation) { GL gl = ((PJOGL)pg.beginPGL()).gl.getGL(); gl.glBlendFunc(blendSrc, blendDest); gl.glBlendEquation(blendEquation); }