Java Code Examples for com.jogamp.opengl.GL#glEnable()

The following examples show how to use com.jogamp.opengl.GL#glEnable() . 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: JCudaDriverVolumeRendererJOGL.java    From jcuda-samples with MIT License 6 votes vote down vote up
@Override
public void init(GLAutoDrawable drawable)
{
    // Perform the default GL initialization
    GL gl = drawable.getGL();
    gl.setSwapInterval(0);
    gl.glEnable(GL.GL_DEPTH_TEST);
    gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    setupView(drawable);
    
    // Initialize CUDA with the current volume data
    initCuda();

    // Initialize the OpenGL pixel buffer object
    initPBO(gl);
}
 
Example 2
Source File: BoxOverlay.java    From clearvolume with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 3
Source File: OpenGLUtil.java    From haxademic with MIT License 5 votes vote down vote up
public static void setBlending(PGraphics pg, boolean isBlending) {
	GL gl = ((PJOGL)pg.beginPGL()).gl.getGL();
	if( isBlending == true ) 
		gl.glEnable( GL.GL_BLEND );
	else 
		gl.glDisable( GL.GL_BLEND );
}
 
Example 4
Source File: CursorOverlay.java    From clearvolume with GNU Lesser General Public License v3.0 4 votes vote down vote up
@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 5
Source File: PathOverlay.java    From clearvolume with GNU Lesser General Public License v3.0 4 votes vote down vote up
@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());
	}
}