gpt4 book ai didi

android - 多个 OpenGL ES 2 Android 渲染器

转载 作者:太空宇宙 更新时间:2023-11-03 13:26:55 24 4
gpt4 key购买 nike

是否可以在一个屏幕上同时显示多个渲染?就像将 android 屏幕分成 4 个象限并在每个象限上显示一个立方体?我认为 OpenGL 有可能,但那是 GLUT 并且是基于 Windows 的。我正在研究如何为 android 做这件事,但我还没有遇到任何描述。这是我创建渲染的主要 Activity 。

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 >

等等……

关于android - 多个 OpenGL ES 2 Android 渲染器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18283457/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com