[英]GlSurfaceView Renderer not being called
I'm learning OpenGL on Android. 我正在Android上学习OpenGL。 I've written an app where the GlSurfaceView is declared in the layout XML (fragment...) 我编写了一个应用程序,其中在布局XML(片段...)中声明了GlSurfaceView
<FrameLayout
android:id="@+id/framelay"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.nelsondev.myha3ogl.M3View
android:id="@+id/m3SurfView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</FrameLayout>
... and in its constructor the renderer is being set: ...,并在其构造函数中设置了渲染器:
public M3View(Context context, AttributeSet attrs) {
super(context, attrs);
renderer = new M3Renderer(context);
setRenderer(renderer);
}
When the activity receives onResume/onPause it is properly calling the GlSurfaceView methods. 当活动接收到onResume / onPause时,它正在正确调用GlSurfaceView方法。 But the renderer is never being started! 但是渲染器永远不会启动! Breakpoints in onSurfaceCreated() and other methods in the renderer are never being hit and nothing is rendered. onSurfaceCreated()中的断点以及渲染器中的其他方法永远不会被击中,因此不会渲染任何内容。 How do I figure out what's happening here? 我如何弄清楚这里发生了什么?
(This answer comes from your other question : Trying to start renderer from GLSurfaceView declared in layout ) (此答案来自您的另一个问题: 尝试从布局中声明的GLSurfaceView启动渲染器 )
You didn't specify your LinearLayout orientation, so it is set to horizontal
by default. 您没有指定LinearLayout方向,因此默认情况下将其设置为horizontal
。 This means your GLSurfaceView is outside of the screen (because you set your button width to fill_parent
). 这意味着您的GLSurfaceView在屏幕之外(因为您将按钮的宽度设置为fill_parent
)。
Just add the following attribute to your LinearLayout : 只需将以下属性添加到LinearLayout中:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.