2011-12-14 5 views
0

私はAndroid上でOpenGLを学んでいます。私はGlSurfaceViewは、レイアウト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> 

を書いた...そしてそのコンストラクタにレンダラが設定されている:

public M3View(Context context, AttributeSet attrs) { 
     super(context, attrs); 
     renderer = new M3Renderer(context); 
     setRenderer(renderer); 
    } 

アクティビティがonResume/onPauseを受け取ると、GlSurfaceViewメソッドが正しく呼び出されています。 しかし、レンダラは決して開始されていません!のブレークポイントonSurfaceCreated()などのレンダラー内の他のメソッドはヒットせず、何もレンダリングされません。ここで何が起こっているのかをどうやって把握するのですか?

+0

実は、私はちょうどチェックして、私はあなたの前の質問に対する私の答えは間違っていたと思うし、それは実際に、(スタート)GLSurfaceViewに呼び出されたときにそれを'setRenderer'が呼び出されたときではなく、GLSurfaceViewをframelayの子として/ graphics.xml内の' setContentView(framelay) 'または' setContentView(R.layout.graphics) 'と呼ぶとき) –

+0

コンストラクタが呼び出されていますか? – Jave

+0

GLSurfaceViewで 'requestRender()'を呼び出して描画するかどうか確認できますか? – Jasoneer

答えて

3

(この答えはあなたの他の質問から来ている:Trying to start renderer from GLSurfaceView declared in layout

それはデフォルトでhorizontalに設定されているので、あなたは、あなたのLinearLayoutの向きを指定していませんでした。つまり、ボタンの幅をfill_parentに設定しているため、GLSurfaceViewが画面外にあることを意味します。

ちょうどあなたのLinearLayoutに次の属性を追加します。

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
関連する問題