Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7894701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:27:46+00:00 2026-06-03T07:27:46+00:00

i tried to do tutorial from http://developer.android.com/resources/tutorials/opengl/opengl-es20.html But what I wanted was to create

  • 0

i tried to do tutorial from http://developer.android.com/resources/tutorials/opengl/opengl-es20.html
But what I wanted was to create it in multiple classes for easier edit.
My problem is that eclipse does not show any kind of errors or problems, application runs but displays only white background (triangle is not shown) and logcat throws constantly errors ‘called unimplemented OpenGL ES API’.
I have no idea what I did wrong, and Eclipse don’t show me where can the error be, can somebody tell me what is wrong or at least put me on tracks for solution?

Edit: I run this app on htc desire with android 2.3.7. When I copy-pasted code from google tutorial everything ran perfectly.

My classes look like that:

Activity:

import android.app.Activity;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

public class Androdvlpr2Activity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(
        WindowManager.LayoutParams.FLAG_FULLSCREEN,
        WindowManager.LayoutParams.FLAG_FULLSCREEN); 

    GLSurfaceView View = new GLSurfaceView(this);
    View.setRenderer(new Renderer());
    setContentView(View);
}
}

Renderer:

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import android.opengl.GLES20;
import android.opengl.GLSurfaceView;

public class Renderer implements GLSurfaceView.Renderer {
Triangle triangle = new Triangle();
private int mProgram;
private int maPositionHandle;

public void onSurfaceCreated(GL10 unused, EGLConfig config) {
    GLES20.glClearColor(0.92f, 0.92f, 0.92f, 1.0f);

    Triangle.initTriangle();


    mProgram = GLES20.glCreateProgram();             // create empty OpenGL Program
    GLES20.glAttachShader(mProgram, Shader.vertexShader);   // add the vertex shader to program
    GLES20.glAttachShader(mProgram, Shader.fragmentShader); // add the fragment shader to program
    GLES20.glLinkProgram(mProgram);                  // creates OpenGL program executables

    // get handle to the vertex shader's vPosition member
    maPositionHandle = GLES20.glGetAttribLocation(mProgram, "vPosition");
}

public void onDrawFrame(GL10 unused) {
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);


    GLES20.glUseProgram(mProgram);
    // Prepare the triangle data
    GLES20.glVertexAttribPointer(maPositionHandle, 3, GLES20.GL_FLOAT, false, 12, Triangle.verticesBuffer);
    GLES20.glEnableVertexAttribArray(maPositionHandle);
    // Draw the triangle
    GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 3);
}

public void onSurfaceChanged(GL10 unused, int width, int height) {
}  
}

Triangle:

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;

public class Triangle {
static FloatBuffer verticesBuffer = null;

public static void initTriangle(){
    float triangleCoords[] = {
                // X, Y, Z
                -0.5f, -0.25f, 0,
                 0.5f, -0.25f, 0,
                 0.0f,  0.559016994f, 0
            }; 

    ByteBuffer vbb = ByteBuffer.allocateDirect(triangleCoords.length * 4);
    vbb.order(ByteOrder.nativeOrder());
    verticesBuffer = vbb.asFloatBuffer();
    verticesBuffer.put(triangleCoords);
    verticesBuffer.position(0);
}
}

Shader:

import android.opengl.GLES20;

public class Shader {
    private final static String vertexShaderCode = 
        "attribute vec4 vPosition; \n" +
        "void main(){              \n" +
        " gl_Position = vPosition; \n" +
        "}                         \n";

    private final static String fragmentShaderCode = 
        "precision mediump float;  \n" +
        "void main(){              \n" +
        " gl_FragColor = vec4 (0.63671875, 0.76953125, 0.22265625, 1.0); \n" +
        "}                         \n";

    final static int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexShaderCode);
    final static int fragmentShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentShaderCode);

private static int loadShader(int type, String shaderCode){

    // create a vertex shader type (GLES20.GL_VERTEX_SHADER)
    // or a fragment shader type (GLES20.GL_FRAGMENT_SHADER)
    int shader = GLES20.glCreateShader(type); 

    // add the source code to the shader and compile it
    GLES20.glShaderSource(shader, shaderCode);
    GLES20.glCompileShader(shader);

    return shader;
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:27:47+00:00Added an answer on June 3, 2026 at 7:27 am

    Inside onSurfaceChanged, the viewport must be set.

    Check for errors after each and every OpenGL call! I’ve seen some unimplemented warnings once with a custom ROM; you want to track down which calls exactly are raising these.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've implemented the Hello Gallery tutorial from the Android web: http://developer.android.com/resources/tutorials/views/hello-gallery.html The tutorial shows
I'm trying to make work this example from http://developer.android.com/resources/tutorials/views/hello-timepicker.html , no errors while compiling
I was working through a tutorial at http://fszlin.blogspot.com/2010/05/comsuming-wcf-services-with-android.html and am having a problem. The
New Android developer here. I'm following a tutorial at http://www.vogella.de/ . The first applications
I was reading this tutorial from the DNN website http://www.dotnetnuke.com/Community/Blogs/tabid/825/EntryId/2675/DotNetNuke-Skinning-101-Part-2.aspx I found the tutorial
Using JXTA 2.6 from http://jxse.kenai.com/ I want to create application that can run multiple
I am trying to follow the tutorial for JSP Templates at: http://java.sun.com/developer/technicalArticles/javaserverpages/jsp_templates/ I am
I am attempting to create a MapView application following the tutorial from the Android
while continuing to learn WCF I've completes the Getting Started Tutorial from http://msdn.microsoft.com/en-us/library/ms734712.aspx and
On this article: http://java.sun.com/developer/technicalArticles/tools/JavaSpaces/ is a tutorial how to run JavaSpaces client. I wrote

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.