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

  • SEARCH
  • Home
  • 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 8635821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:04:07+00:00 2026-06-12T10:04:07+00:00

Do there is any special emulator settings needed to run OpenGL Apps? I already

  • 0

Do there is any special emulator settings needed to run OpenGL Apps?

I already set “GPU emulation” property to “yes”.

I am trying to run an Android sample live wallpaper, using the sample source found from this link, The desired output is a rotating triangle.

After a little effort I got the app running but it doesn’t draw anything in emulator but when I tested in device it works, But in the emulator it still just shows a green screen, I found a discussion on it in Google groups here. I tried to set view port as said in it. But still it doesn’t show any result, on surface changed I had added this line

gl.glViewport(0, 0, width, height);

Do this is the correct way to set view port?

This is my render class,

 public class MyRenderer implements GLWallpaperService.Renderer {
    GLTriangle mTriangle;

    public void onDrawFrame(GL10 gl) {


        gl.glClearColor(0.2f, 0.4f, 0.2f, 1f);
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

        gl.glMatrixMode(GL10.GL_MODELVIEW);
        autoRotate(gl);
        gl.glColor4f(.2f, 0f, .5f, 1f);

        mTriangle.draw(gl);
    }

    public void onSurfaceChanged(GL10 gl, int width, int height) {

        gl.glViewport(0, 0, width, height);
        gl.glMatrixMode(GL10.GL_PROJECTION);
        gl.glLoadIdentity();
        GLU.gluPerspective(gl, 60f, (float)width/(float)height, 1f, 100f);

        gl.glMatrixMode(GL10.GL_MODELVIEW);
        gl.glLoadIdentity();
        gl.glTranslatef(0, 0, -5);
    }

    public void onSurfaceCreated(GL10 gl, EGLConfig config) {
        mTriangle = new GLTriangle();



        gl.glClearDepthf(1f);
        gl.glEnable(GL10.GL_DEPTH_TEST);
        gl.glDepthFunc(GL10.GL_LEQUAL);
    }

    /**
     * Called when the engine is destroyed. Do any necessary clean up because
     * at this point your renderer instance is now done for.
     */
    public void release() {

    }

    private void autoRotate(GL10 gl) {
        gl.glRotatef(1, 0, 1, 0);
        gl.glRotatef(0.5f, 1, 0, 0);
    }
}

Herse is GLTriangle class

import java.nio.FloatBuffer;
import java.nio.ShortBuffer;

import javax.microedition.khronos.opengles.GL10;

public class GLTriangle {
    private FloatBuffer _vertexBuffer;
    private final int _nrOfVertices = 3;

    private ShortBuffer _indexBuffer;

    public GLTriangle() {
        init();
    }

    private void init() {
        // We use ByteBuffer.allocateDirect() to get memory outside of
        // the normal, garbage collected heap. I think this is done
        // because the buffer is subject to native I/O.
        // See http://download.oracle.com/javase/1.4.2/docs/api/java/nio/ByteBuffer.html#direct

        // 3 is the number of coordinates to each vertex.
        _vertexBuffer = BufferFactory.createFloatBuffer(_nrOfVertices * 3);

        _indexBuffer = BufferFactory.createShortBuffer(_nrOfVertices);

        // Coordinates for the vertexes of the triangle.
        float[] coords = {
                -1f, -1f,  0f,  // (x1, y1, z1)
                 1f, -1f,  0f,  // (x2, y2, z2)
                 0f,  1f,  0f   // (x3, y3, z3)
        };

        short[] _indicesArray = {0, 1, 2};

        _vertexBuffer.put(coords);
        _indexBuffer.put(_indicesArray);

        _vertexBuffer.position(0);
        _indexBuffer.position(0);
    }

    public void draw(GL10 gl) {
        // 3 coordinates in each vertex
        // 0 is the space between each vertex. They are densely packed
        //   in the array, so the value is 0
        gl.glVertexPointer(3, GL10.GL_FLOAT, 0, getVertexBuffer());

        // Draw the primitives, in this case, triangles.
        gl.glDrawElements(GL10.GL_TRIANGLES, _nrOfVertices, GL10.GL_UNSIGNED_SHORT, _indexBuffer);
    }

    private FloatBuffer getVertexBuffer() {
        return _vertexBuffer;
    }
}

What’s going wrong here? Is there a better sample code for Open GL live wallpaper?

  • 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-12T10:04:08+00:00Added an answer on June 12, 2026 at 10:04 am

    AT LAST I FOUND IT..

    What I need to do is just add

    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    

    to onSurfaceCreated method along with the code line

    gl.glViewport(0, 0, width, height);
    

    in the onSurfaceChanged method in MyRenderer Class

    I found a similar question in stack itself [ But Solution worked for me is not marked as correct 🙁 ]

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

Sidebar

Related Questions

Are there any special requirements to upload Apps that use Native C/C++ code wrapped
Is there any special function to parse a .conf file in php like parse_ini_file()
Can anyone please tell me is there any special requirement to use either EXTERN
i want that during marshelling special character should escape, is there any way to
Is there any way I can set a formatter on models that will convert
Is there any special significance to defining constant data inside a structure as shown.
Is there any special C standard for microcontrollers? I ask because so far when
I am curious to know is there any special GAS syntax to achieve the
I have a doubt Why Should we use temporary table is there any special
Are there any special methods to make swapping elements in an NSMutableArray easier or

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.