多个OpenGL ES 2 Android渲染器

多个OpenGL ES 2 Android渲染器,第1张

概述屏幕上可以一次显示多个渲染吗?像将android屏幕拆分为4个象限,并在每个象限上显示一个立方体?我认为它可能适用于OpenGL,但这是GLUT,并且基于Windows.我正在研究如何为android做它,但是我还没有遇到任何描述它的东西.这是创建渲染的主要活动.publicclassMainActivityextendsAct

屏幕上可以一次显示多个渲染吗?像将android屏幕拆分为4个象限,并在每个象限上显示一个立方体?我认为它可能适用于OpenGL,但这是gluT,并且基于Windows.我正在研究如何为androID做它,但是我还没有遇到任何描述它的东西.这是创建渲染的主要活动.

public class MainActivity extends Activity{    private MyGLSurfaceVIEw mGLVIEw;    @OverrIDe    public voID onCreate(Bundle savedInstanceState)    {        super.onCreate(savedInstanceState);        // Create a GLSurfaceVIEw instance and set it        // as the ContentVIEw for this Activity        // "this" is the reference to activity        mGLVIEw = new MyGLSurfaceVIEw(this);        setContentVIEw(mGLVIEw);    }    @OverrIDe    protected voID onPause()    {        super.onPause();        // The following call pauses the rendering thread.        // If your OpenGL application is memory intensive,        // you should consIDer de-allocating objects that        // consume significant memory here.        mGLVIEw.onPause();    }    @OverrIDe    protected voID onResume()    {        super.onResume();        // The following call resumes a paused rendering thread.        // If you de-allocated graphic objects for onPause()        // this is a good place to re-allocate them.        mGLVIEw.onResume();    }}class MyGLSurfaceVIEw extends GLSurfaceVIEw{    private final Myglrenderer mRenderer;    Context context;    public MyGLSurfaceVIEw(Context context)    {        super(context);        this.context = context;        // Create an OpenGL ES 2.0 context.        setEGLContextClIEntVersion(2);        // Set the Renderer for drawing on the GLSurfaceVIEw        Log.d("Test", "GL initialized");        mRenderer = new Myglrenderer(context);        setRenderer(mRenderer);        // Render the vIEw only when there is a change in the drawing data        setRenderMode(GLSurfaceVIEw.RENDERMODE_WHEN_DIRTY);    }}

解决方法:

我不明白为什么只有一个GLSurfaceVIEw无法做到这一点.通过调用glVIEwport将场景映射到该象限,可以将屏幕划分为四个象限.然后,您可以调用绘制函数,然后对每个后续象限重复此 *** 作.

例:

glVIEwport(0, 0, wIDth/2, height/2);< render first quadrant >glVIEwport(wIDth / 2, 0, wIDth / 2, height / 2);< render second quadrant >

等等…

总结

以上是内存溢出为你收集整理的多个OpenGL ES 2 Android渲染器全部内容,希望文章能够帮你解决多个OpenGL ES 2 Android渲染器所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1087661.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存