Question

I am rendering points using Java OpenGL to be overlayed ontop of a video stream.

I'm stuck trying to make the background of the Java OpenGL canvas window transparent, so only the rendered points are visible when overlayed ontop of the video stream layer?

This is the code I'm using to setup the canvas.

 
public void init(GLAutoDrawable drawable) {

GL gl = drawable.getGL(); System.err.println("INIT GL IS: " + gl.getClass().getName()); // Enable VSync gl.setSwapInterval(1); // Setup the drawing area and shading mode gl.glEnable(GL_BLEND); gl.glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl.glShadeModel(GL.GL_SMOOTH); gl.glClearColor(0.0f, 0.4f, 0.0f, 0.0f); }

Cheers for any ideas on how to do this. J

Was it helpful?

Solution

The process you need to do inside of your app should be something like this :

  • Get the RGB buffer from the video stream
  • Save this buffer into a texture
  • Render this texture into a quad on the screen
  • Render your points on top of the quad.

OpenGL needs to know in the process who's on top of what (due to the rendering pipeline it needs to know what fragments are rendered and which are rejected).

If you have an OpenGL view and a something-else-view, then OpenGL cannot make this decision.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top