What is the easiest way to draw line using OpenGL-ES (android)

前端 未结 2 1354
清歌不尽
清歌不尽 2020-12-07 19:21

If I have custom renderer in opengl-es prepared:

public void onDrawFrame(GL10 gl)
{
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
             


        
2条回答
  •  醉梦人生
    2020-12-07 20:02

    Thanks Rodney Lambert for the Line class you´ve provided. However it also would be nice to provide a simpler call in onDrawFrame, something like:

    Line vertLine = new Line();
    vertLine.SetVerts(-0.5f, 0.5f, 0f, -0.5f, -0.5f, 0f);
    vertLine.SetColor(.8f, .8f, 0f, 1.0f);
    vertLine.draw(mMVPMatrix);
    

    vertLine.SetVerts(-0.5f, 0.5f, 0f, -0.5f, -0.5f, 0f);

    creates definitely a line visible inside the viewport

提交回复
热议问题