OpenGL in GLSurfaceview partialy on screen

Problems with Canvas, OpenGL, etc...

OpenGL in GLSurfaceview partialy on screen

Postby Dhex » Wed May 26, 2010 3:09 pm

Hi everyone

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 )

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.example.android.apis.graphics;
  2.  
  3. import javax.microedition.khronos.egl.EGLConfig;
  4. import javax.microedition.khronos.opengles.GL10;
  5.  
  6. import android.app.Activity;
  7. import android.opengl.GLSurfaceView;
  8. import android.os.Bundle;
  9.  
  10. public class ClearActivity extends Activity {
  11.     @Override
  12.     protected void onCreate(Bundle savedInstanceState) {
  13.         super.onCreate(savedInstanceState);
  14.         mGLView = new GLSurfaceView(this);
  15.         mGLView.setRenderer(new ClearRenderer());
  16.         setContentView(mGLView);
  17.     }
  18.  
  19.     @Override
  20.     protected void onPause() {
  21.         super.onPause();
  22.         mGLView.onPause();
  23.     }
  24.  
  25.     @Override
  26.     protected void onResume() {
  27.         super.onResume();
  28.         mGLView.onResume();
  29.     }
  30.  
  31.     private GLSurfaceView mGLView;
  32. }
  33.  
  34. class ClearRenderer implements GLSurfaceView.Renderer {
  35.     public void onSurfaceCreated(GL10 gl, EGLConfig config) {
  36.         // Do nothing special.
  37.     }
  38.  
  39.     public void onSurfaceChanged(GL10 gl, int w, int h) {
  40.         gl.glViewport(0, 0, w, h);
  41.     }
  42.  
  43.     public void onDrawFrame(GL10 gl) {
  44.         gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
  45.     }
  46. }
  47.  
  48.  
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


inside this:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. android:orientation="vertical"
  3. android:layout_width="fill_parent"
  4. android:layout_height="fill_parent"
  5. android:gravity="bottom">
  6.        
  7.    <LinearLayout
  8.   xmlns:android="http://schemas.android.com/apk/res/android"
  9.   android:orientation="vertical"
  10.   android:layout_width="fill_parent"
  11.   android:layout_weight="1" android:layout_height="fill_parent">
  12.    
  13.       <FrameLayout
  14.      xmlns:android="http://schemas.android.com/apk/res/android"
  15.      android:layout_width="fill_parent"
  16.      android:layout_height="fill_parent">
  17.            
  18.          <view
  19.         xmlns:android="http://schemas.android.com/apk/res/android"
  20.          class = "testground.cdev.test.GLSurfaceView"
  21.          android:id="@+id/gfx"
  22.         android:layout_width="fill_parent"
  23.         android:layout_height="fill_parent"/>
  24.    
  25.          <TextView
  26.          android:layout_weight="1"
  27.          android:textSize="5pt"
  28.         android:id="@+id/text1"
  29.         android:background="#00ffffff"
  30.         android:layout_height="fill_parent"
  31.          android:layout_width="wrap_content">  
  32.          </TextView>
  33.                                
  34.       </FrameLayout>
  35.  
  36.    </LinearLayout>
  37.        
  38.    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  39.   android:orientation="horizontal"
  40.   android:layout_width="fill_parent"
  41.   android:layout_weight="0"
  42.   android:layout_height="wrap_content"
  43.   android:layout_margin="0px"
  44.   android:baselineAligned="false"
  45.   android:gravity="bottom">
  46.  
  47.       <EditText
  48.      android:id="@+id/Edit1"
  49.      android:layout_width="fill_parent"
  50.      android:layout_weight="1"
  51.      android:text="prueba"
  52.      android:textSize="12sp"
  53.      android:layout_marginBottom="0px"
  54.      android:layout_height="34px"
  55.      android:layout_gravity="bottom"
  56.      android:layout_margin="0px"
  57.      android:layout_marginTop="20px">
  58.       </EditText>
  59.                
  60.       <Button
  61.      android:layout_width="wrap_content"
  62.      android:text="Send"
  63.      android:id="@+id/send"
  64.      android:layout_marginBottom="0px"
  65.      android:layout_height="34px"
  66.      android:layout_gravity="bottom"
  67.      android:layout_margin="0px"
  68.      android:layout_marginTop="2px">
  69.       </Button>
  70.  
  71.    </LinearLayout>
  72.  
  73. </LinearLayout>
  74.  
Parsed in 0.008 seconds, using GeSHi 1.0.8.4


im attaching an image of how the xml to looks like.
Attachments
opengl.jpg
opengl.jpg (5.57 KiB) Viewed 1007 times
Dhex
Freshman
Freshman
 
Posts: 2
Joined: Tue May 25, 2010 4:03 pm

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 5 guests