How to draw my own graphics within the JME's GLSurfaceView

I have a 3D wave that’s made by rewrited GLSurfaceView.Renderer , and I want it to be the background of my JME program, how should I do? :thinking:
I thought about there’s 2 ways,one is draw my 3D wave in JME program’s GLSurfaceView ,the other is draw JME’s things in my 3D wave‘s GLSurfaceView.(I think the former might be a little simpler :joy:
I’m new to both JME and OpenGL ES,hope big master could come to help me, thanks a lot !!! :heart:

A third option is to adapt the code to use one of JME’s built in constructs… but I don’t know how complicated the wave code is. Even so, it’s probably the easiest route in the long run.

1 Like

Thank you for your reply. :heart:

This is the core class of the wave code:

   public static final class WaveRender implements GLSurfaceView.Renderer {}

then i create a GLSurfaceView in MainAcitivity,and use these functions:

    GLSurfaceView gl_surface=(findViewById(;
    gl_surface.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
    gl_surface.setRenderer(new WavePoint.WaveRender());//render

And it uses Shader to draw the wave:

public static final class WaveRender implements GLSurfaceView.Renderer {

  public void onSurfaceCreated(GL10 gl10, EGLConfig eglConfig) {

        int vertexShader = ShaderHelper.compileVertexShader(VERTEX);
        int fragmentShader = ShaderHelper

        program = ShaderHelper.linkProgram(vertexShader, fragmentShader);


Probably the easiest way, as Paul already said, would be to adapt the shaders into a jme material and then use a quad with the said material as your background inside jme.

1 Like

Thank you for your reply.:heart:

Sorry, I forgot to say something. My waves are dynamic. Input an increasing time value to the Shader through public void ondrawframe (gl10 gl10),and then make it fluctuate through Fourier transform.

In this case, can the JME material import method make it fluctuate dynamically?

Yes, you can pass uniforms to the shader using material.setFloat(), .setColor() and other methods. That said, if time elapsed is all you need, jme already provides a global uniform g_Time, which is used precisely for such animations.


Oh, I see. I was so careless that I didn’t think of it.
Thank you very much! Then, I will try to realize it. :smile:

1 Like

By doing this you are not going to use jme, you will continue your code using plain android native, if you want to use jme then either use JmeSurfaceView or ActivityHarness and draw your waves using custom meshes in some appstate, by using jmesurfaceview you can set jme game as a background to your activity layout.

1 Like

Thank you for your reply :heart:

I already have a JME game. I want to use my wave as the background of the game.

Another question, my wave has 90000 points. I use VBO to store it in GPU‘s memory. I don’t want to occupy too much CPU resources.

I want to know if I use custom grid, will it occupy a lot of CPU resouces?Can VBO be used for Custom Grid?

When browsing in the forum, I noticed that it seems that VBO has been used in JME custom grid. Is that right?

Oh!I’ve found it: