[Tut-Sequence] Android GL - Learning OpenGL from Scratch

Tutorials concerning the OpenGL® ES cross-platform API for full-function 2D and 3D graphics on the Google-Android platform.

[Tut-Sequence] Android GL - Learning OpenGL from Scratch

Postby plusminus » Thu Dec 06, 2007 10:07 pm

Hello Community,

We proudly present the Android-(Open)-GL Tutorials.

[align=right]powered by brendan.d.burns[/align]

We will Heavily comment and explain the tutorial-code about OpenGL ES brendan produced under the free&open GPL license and officialy granted permission to use his tutorials here :!:

:idea: His original codes can be loaded from the Android-GL Google-Code Project.

But the commented versions will only be available here.


List of Tutorials worked out so far:


Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Postby BackwardsDown » Thu Jan 03, 2008 7:09 pm

If I want to create a tetris game for android, would it be smart to first create one for a PC (in a QT window) and when it's finished port it to the android platform? I think testing the game everytime in the virtual machine takes up a lot of time.

Or would I run into problems very fast, is opengl on a computer very different than in android? For example, load pictures/files, reading keyboard input, etc?
BackwardsDown
Freshman
Freshman
 
Posts: 5
Joined: Wed Dec 19, 2007 9:09 am

Postby plusminus » Thu Jan 03, 2008 8:31 pm

Hello BackwardsDown,

as OpenGL is a Standard the functions are at least almost the same :!:
As starting a Activity on the Emulator takes not too long (5 to 10 seconds with me) I would develop already on it.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

GL Tutorials

Postby E.Jyothsna » Mon Mar 10, 2008 7:22 am

i tried your GL tutorial and i tried this example.but iin this code it shows error in "this.myGLContext.waitNative(canvas, this);"suggests me

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package edu.union;
  2.  
  3.  
  4.  
  5. import javax.microedition.khronos.opengles.GL10;
  6.  
  7.  
  8.  
  9. import android.content.Context;
  10.  
  11. import android.graphics.Canvas;
  12.  
  13. import android.graphics.OpenGLContext;
  14.  
  15. import android.view.View;
  16.  
  17.  
  18.  
  19. public class GLTutorialOne extends View {
  20.  
  21.      protected OpenGLContext myGLContext;
  22.  
  23.      protected GL10 myGL;
  24.  
  25.      
  26.  
  27.      public GLTutorialOne(Context c) {
  28.  
  29.           super(c);
  30.  
  31.           /* Create a OpenGLContext
  32.  
  33.            * In this case there is no
  34.  
  35.            * need to save it, but in other
  36.  
  37.            * cases it will be reused. */
  38.  
  39.           this.myGLContext = new OpenGLContext(0);
  40.  
  41.           /* Store the GL interface that will handle  
  42.  
  43.            * the actual graphical operations */
  44.  
  45.           this.myGL = (GL10)this.myGLContext.getGL();
  46.  
  47.          
  48.  
  49.           /* Set the color to be uses when clearing
  50.  
  51.            * Params: Red, Green, Blue, Alpha
  52.  
  53.            * All from (0.0f up to 1.0f)
  54.  
  55.            * Below we use a android-green =) */
  56.  
  57.           this.myGL.glClearColor(0.0f, 0.8f, 0.0f, 0.0f);
  58.  
  59.      }
  60.  
  61.      
  62.  
  63.      protected void onDraw(Canvas canvas) {      
  64.  
  65.           /* waitNative() makes sure all pending
  66.  
  67.            * native drawing calls  have completed
  68.  
  69.            * and binds this passed canvas to
  70.  
  71.            * the specified context(here: this). */
  72.  
  73.           this.myGLContext.waitNative(canvas, this);
  74.  
  75.          
  76.  
  77.           /* This call will finally cause our
  78.  
  79.            * canvas to be cleared to the color
  80.  
  81.            * we passed in the constructor */
  82.  
  83.           this.myGL.glClear(GL10.GL_COLOR_BUFFER_BIT);
  84.  
  85.      }
  86.  
  87. }
Parsed in 0.035 seconds, using GeSHi 1.0.8.4
E.Jyothsna
Junior Developer
Junior Developer
 
Posts: 22
Joined: Thu Feb 28, 2008 12:25 pm
Location: chennai

Re: GL Tutorials

Postby errun » Thu Mar 13, 2008 10:58 am

This code is can run on m3.The OPENGL in android have some change in M5. u can find the change in http://code.google.com/android/migratin ... anges.html.

E.Jyothsna wrote:i tried your GL tutorial and i tried this example.but iin this code it shows error in "this.myGLContext.waitNative(canvas, this);"suggests me

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package edu.union;
  2.  
  3. import javax.microedition.khronos.opengles.GL10;
  4.  
  5. import android.content.Context;
  6. import android.graphics.Canvas;
  7. import android.graphics.OpenGLContext;
  8. import android.view.View;
  9.  
  10. public class GLTutorialOne extends View {
  11.      protected OpenGLContext myGLContext;
  12.      protected GL10 myGL;
  13.      
  14.      public GLTutorialOne(Context c) {
  15.           super(c);
  16.           /* Create a OpenGLContext
  17.            * In this case there is no
  18.            * need to save it, but in other
  19.            * cases it will be reused. */
  20.           this.myGLContext = new OpenGLContext(0);
  21.           /* Store the GL interface that will handle  
  22.            * the actual graphical operations */
  23.           this.myGL = (GL10)this.myGLContext.getGL();
  24.          
  25.           /* Set the color to be uses when clearing
  26.            * Params: Red, Green, Blue, Alpha
  27.            * All from (0.0f up to 1.0f)
  28.            * Below we use a android-green =) */
  29.           this.myGL.glClearColor(0.0f, 0.8f, 0.0f, 0.0f);
  30.      }
  31.      
  32.      protected void onDraw(Canvas canvas) {      
  33.           /* waitNative() makes sure all pending
  34.            * native drawing calls  have completed
  35.            * and binds this passed canvas to
  36.            * the specified context(here: this). */
  37.           this.myGLContext.waitNative(canvas, this);
  38.          
  39.           /* This call will finally cause our
  40.            * canvas to be cleared to the color
  41.            * we passed in the constructor */
  42.           this.myGL.glClear(GL10.GL_COLOR_BUFFER_BIT);
  43.      }
  44. }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
errun
Once Poster
Once Poster
 
Posts: 1
Joined: Thu Mar 13, 2008 10:47 am

Postby E.Jyothsna » Fri Mar 14, 2008 6:52 am

thank u for sending that link.but after clicking that it shows URL not found
E.Jyothsna
Junior Developer
Junior Developer
 
Posts: 22
Joined: Thu Feb 28, 2008 12:25 pm
Location: chennai

Top

Re: GL Tutorials

Postby Independent » Tue Oct 28, 2008 1:19 am

E.Jyothsna wrote:i tried your GL tutorial and i tried this example.but iin this code it shows error in "this.myGLContext.waitNative(canvas, this);"suggests me

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package edu.union;
  2.  
  3. import javax.microedition.khronos.opengles.GL10;
  4.  
  5. import android.content.Context;
  6. import android.graphics.Canvas;
  7. import android.graphics.OpenGLContext;
  8. import android.view.View;
  9.  
  10. public class GLTutorialOne extends View {
  11.      protected OpenGLContext myGLContext;
  12.      protected GL10 myGL;
  13.      
  14.      public GLTutorialOne(Context c) {
  15.           super(c);
  16.           /* Create a OpenGLContext
  17.            * In this case there is no
  18.            * need to save it, but in other
  19.            * cases it will be reused. */
  20.           this.myGLContext = new OpenGLContext(0);
  21.           /* Store the GL interface that will handle  
  22.            * the actual graphical operations */
  23.           this.myGL = (GL10)this.myGLContext.getGL();
  24.          
  25.           /* Set the color to be uses when clearing
  26.            * Params: Red, Green, Blue, Alpha
  27.            * All from (0.0f up to 1.0f)
  28.            * Below we use a android-green =) */
  29.           this.myGL.glClearColor(0.0f, 0.8f, 0.0f, 0.0f);
  30.      }
  31.      
  32.      protected void onDraw(Canvas canvas) {      
  33.           /* waitNative() makes sure all pending
  34.            * native drawing calls  have completed
  35.            * and binds this passed canvas to
  36.            * the specified context(here: this). */
  37.           this.myGLContext.waitNative(canvas, this);
  38.          
  39.           /* This call will finally cause our
  40.            * canvas to be cleared to the color
  41.            * we passed in the constructor */
  42.           this.myGL.glClear(GL10.GL_COLOR_BUFFER_BIT);
  43.      }
  44. }
Parsed in 0.038 seconds, using GeSHi 1.0.8.4



For some reason when i import android.graphics.OpenGLContext I'm getting an error that says it cannot resolve the issue. I assume that my development environment isn't set up correctly. Is there something I'm forgetting. Its asking me if i wish to create that class... and I assume thats incorrect lol.
Independent
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Oct 28, 2008 1:13 am
Location: Winter Park FL

Postby alpesh_harsoda » Tue Nov 18, 2008 7:23 am

hi,
i m new in android.
i have the same error in openglcontext in sdk 1.0 can anybody help me?
i found that this class is removed from sdk but i m not getting which class is added
in place of this class.
thnks, :)
Alpesh
User avatar
alpesh_harsoda
Senior Developer
Senior Developer
 
Posts: 106
Joined: Sat Sep 20, 2008 12:35 pm
Location: Rajkot,Gujarat(India)

Postby DeveloperAmit » Mon Apr 06, 2009 8:24 am

Hi all
I am to facing the same problem in android SDK 1.1 release
Please suggest some solution over it
thnx
DeveloperAmit
Junior Developer
Junior Developer
 
Posts: 20
Joined: Wed Mar 04, 2009 1:26 pm

thnx for the tutorial

Postby rami.salsaa » Sat Jun 20, 2009 1:07 pm

Thank you for this! I hope to learn from it and find out the things i need to start with coding my stuff.

cheers!

Rami
User avatar
rami.salsaa
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Jun 16, 2009 7:35 pm

Other tutorials and libraries?

Postby arberg » Tue Oct 27, 2009 10:59 am

What tutorials and libraries are available which can help beginners to develop 2D and 3D games on Android using OpenGL-ES? I'm looking for tutorials which can help me learn OpenGL-ES, and I'm looking for OpenGL-ES libraries which can make life easier for beginners in OpenGL-ES. The tutorial part seems to be covered by the name of this topic, therefore I am posting this as a followup here.

Since Android is still small, I guess it may be help-full to read iPhone OpenGL-ES tutorials as well, as I suppose the OpenGL-ES functionality is much the same.

I have found useful information which I would have liked to share, but I am not yet allowed.
arberg
Freshman
Freshman
 
Posts: 2
Joined: Tue Oct 27, 2009 10:46 am

Using Brendan's .obj loader.

Postby PkL728 » Thu Mar 25, 2010 7:15 pm

I'm trying to use Brendan's object loader for wavefront objects. The problem I'm having is it looks like his load routine takes in a string name, and then checks the .obj's first line to see if it specifies a texture:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. protected static final String[] suffs = new String[] {".jpg", ".png", ".gif"};
  3.  
  4.  
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         public Model load(String file)  
  2.  
  3.          throws IOException
  4.  
  5.          {
  6.  
  7.                  Model m = load(new FileInputStream(file));
  8.  
  9.                  int ix = file.indexOf(".obj");
  10.  
  11.                  if (ix != -1) {
  12.  
  13.                          String texture = file.substring(0, ix);
  14.  
  15.                          for (int i=0;i<suffs.length;i++) {
  16.  
  17.                                  File f = new File(texture+suffs[i]);
  18.  
  19.                                  if (f.exists()) {
  20.  
  21.                                          m.getFrame(0).getMesh().setTextureFile(texture+suffs[i]);
  22.  
  23.                                          break;
  24.  
  25.                                  }
  26.  
  27.                          }
  28.  
  29.                  }
  30.  
  31.                  return m;
  32.  
  33.          }
  34.  
  35.  
Parsed in 0.038 seconds, using GeSHi 1.0.8.4


I have my .obj in the /src folder of my project as well as the texture, but it always fails when it tries to read the texture file. Where should I be storing these objects in my project for this code to work properly? Are there any examples for this code that are specificly using the WaveFront loader? Any help would be greatly appreciated.
PkL728
Junior Developer
Junior Developer
 
Posts: 11
Joined: Mon Feb 22, 2010 6:33 am

Re: [Tut-Sequence] Android GL - Learning OpenGL from Scratch

Postby jettimadhu » Tue May 17, 2011 7:27 am

Hi,

I am working on OpenGL2.0 in android.But I didn't find the way how to enable and disable OpenGL2.0 in andorid and Android Browser. If anyone knows please help me on this..

Thanx in advance..
jettimadhu
Junior Developer
Junior Developer
 
Posts: 17
Joined: Wed Sep 09, 2009 12:50 pm

Re: [Tut-Sequence] Android GL - Learning OpenGL from Scratch

Postby tan_dunming » Sat Jun 04, 2011 8:08 am

Hi, jettimadhu. You can refer to Android API Demos, there exsit an OpenGL ES 2.0 Demo.
You can new an android project from Eclipse, in the new project wizard, choose "Create project from exsisting sample and choose build target of Android 2.2. After creating the API Demo project. The source is under "src/com.example.android.apis.graphics.GLES20Activity"
tan_dunming
Once Poster
Once Poster
 
Posts: 1
Joined: Sat Jun 04, 2011 8:00 am

Re: [Tut-Sequence] Android GL - Learning OpenGL from Scratch

Postby jodroid » Wed Jun 15, 2011 7:24 pm

Tan,

This is exactly the link I was looking for thank you. As a novice developer I have found this forum to be a great source which leads me to another question I have been looking to ask. What other tutorials would you recommend, and what is the best way to get on the fast track to effective android application creation. I think it would be cool to develop a working IT staffing job search app. I have so many ideas, and a lot of passion, but I need to work on my technical skills quite a bit.
Last edited by jodroid on Fri Jan 20, 2012 11:00 pm, edited 1 time in total.
jodroid
Freshman
Freshman
 
Posts: 5
Joined: Tue Jun 14, 2011 8:09 pm

Top
Next

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

Who is online

Users browsing this forum: No registered users and 3 guests