Im new at this, what im trying to do is find the most basic example in placing a OpenGL instance on only part of the screen. This is, making it run in a glsurface view placed on a linear layout on the XML...
Can someone tell me how to get this.. (example taken from here )
Using java Syntax Highlighting
- package com.example.android.apis.graphics;
- import javax.microedition.khronos.egl.EGLConfig;
- import javax.microedition.khronos.opengles.GL10;
- import android.app.Activity;
- import android.opengl.GLSurfaceView;
- import android.os.Bundle;
- public class ClearActivity extends Activity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- mGLView = new GLSurfaceView(this);
- mGLView.setRenderer(new ClearRenderer());
- setContentView(mGLView);
- }
- @Override
- protected void onPause() {
- super.onPause();
- mGLView.onPause();
- }
- @Override
- protected void onResume() {
- super.onResume();
- mGLView.onResume();
- }
- private GLSurfaceView mGLView;
- }
- class ClearRenderer implements GLSurfaceView.Renderer {
- public void onSurfaceCreated(GL10 gl, EGLConfig config) {
- // Do nothing special.
- }
- public void onSurfaceChanged(GL10 gl, int w, int h) {
- gl.glViewport(0, 0, w, h);
- }
- public void onDrawFrame(GL10 gl) {
- gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
- }
- }
Parsed in 0.035 seconds, using GeSHi 1.0.8.4
inside this:
Using xml Syntax Highlighting
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:gravity="bottom">
- <LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_weight="1" android:layout_height="fill_parent">
- <FrameLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <view
- xmlns:android="http://schemas.android.com/apk/res/android"
- class = "testground.cdev.test.GLSurfaceView"
- android:id="@+id/gfx"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"/>
- <TextView
- android:layout_weight="1"
- android:textSize="5pt"
- android:id="@+id/text1"
- android:background="#00ffffff"
- android:layout_height="fill_parent"
- android:layout_width="wrap_content">
- </TextView>
- </FrameLayout>
- </LinearLayout>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="horizontal"
- android:layout_width="fill_parent"
- android:layout_weight="0"
- android:layout_height="wrap_content"
- android:layout_margin="0px"
- android:baselineAligned="false"
- android:gravity="bottom">
- <EditText
- android:id="@+id/Edit1"
- android:layout_width="fill_parent"
- android:layout_weight="1"
- android:text="prueba"
- android:textSize="12sp"
- android:layout_marginBottom="0px"
- android:layout_height="34px"
- android:layout_gravity="bottom"
- android:layout_margin="0px"
- android:layout_marginTop="20px">
- </EditText>
- <Button
- android:layout_width="wrap_content"
- android:text="Send"
- android:id="@+id/send"
- android:layout_marginBottom="0px"
- android:layout_height="34px"
- android:layout_gravity="bottom"
- android:layout_margin="0px"
- android:layout_marginTop="2px">
- </Button>
- </LinearLayout>
- </LinearLayout>
Parsed in 0.007 seconds, using GeSHi 1.0.8.4
im attaching an image of how the xml to looks like.

