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 8085157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:01:41+00:00 2026-06-05T18:01:41+00:00

I have a problem with OpenGl ES 2.0. I’ve designed a very simple framework

  • 0

I have a problem with OpenGl ES 2.0. I’ve designed a very simple framework to help me load OBJ files and draw them on my Android phone, but I have 2 bugs that I haven’t been able to fix:

  1. My app doesn’t show anything until I change the orientation and the Activity gets scraped and reloaded. Until it reloads only GLES20.glClear() can be seen(I’ve set it to a grayish color).

  2. Sometimes when I load an OBJ and do the orientation trick, half of my faces are missing and I see gaps, but the problem might be with the OBJ files I’ve used.

package com.ideas.opengl;

import java.io.IOException;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import android.opengl.GLES20;
import android.opengl.GLSurfaceView.Renderer;
import android.opengl.Matrix;

public class DemoRenderer implements Renderer {
    public static int mProgramHandle;
    private int mMVPMatrixHandle;
    private float[] mModelMatrix = new float[16];
    private float[] mViewMatrix = new float[16];
    private float[] mProjectionMatrix = new float[16];
    private float[] mMVPMatrix = new float[16];

    public Object banana;

    private OpenGLDemoActivity activity;

    private int angle;

    public DemoRenderer(OpenGLDemoActivity activity) throws IOException {
        this.activity = activity;
    }



    @Override
    public void onSurfaceCreated(GL10 gl, EGLConfig config){
        GLES20.glClearColor(0.65f, 0.65f, 0.65f, 0.65f);

        //GLES20.glEnable(GLES20.GL_CULL_FACE);

        GLES20.glEnable(GLES20.GL_DEPTH_TEST);

        GLES20.glEnable(GLES20.GL_TEXTURE_2D);

        Shader shader = null;
        try {
            shader = new Shader(activity, "simple");
        } catch (IOException e) {
            e.printStackTrace();
        }
        Vector position = new Vector();
        Vector speed = new Vector();
        Vector accel = new Vector();
        Model model = null;
        try {
            model = new Model("banana", activity);
        } catch (IOException e) {
            e.printStackTrace();
        }

        banana = new Object(position, speed, accel, model);

        mProgramHandle = shader.getProgramHandle();

        final float eyeX = 0.0f;
        final float eyeY = 0.0f;
        final float eyeZ = 3.5f;

        final float lookX = 0.0f;
        final float lookY = 0.0f;
        final float lookZ = -5.0f;

        final float upX = 0.0f;
        final float upY = 1.0f;
        final float upZ = 0.0f;

        Matrix.setLookAtM(mViewMatrix, 0, eyeX, eyeY, eyeZ, lookX, lookY, lookZ, upX, upY, upZ);

        mMVPMatrixHandle = GLES20.glGetUniformLocation(mProgramHandle, "u_MVPMatrix");
    }

    @Override
    public void onSurfaceChanged(GL10 gl, int width, int height) {
        GLES20.glViewport(0, 0, width, height);

        final float ratio = (float) width / height;
        final float left = -ratio;
        final float right = ratio;
        final float bottom = -1.0f;
        final float top = 1.0f;
        final float near = 1.0f;
        final float far = 10.0f;

        Matrix.frustumM(mProjectionMatrix, 0, left, right, bottom, top, near, far);

    }


    @Override
    public void onDrawFrame(GL10 gl) {      
        GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);

        angle++;

        Matrix.setIdentityM(mModelMatrix, 0);
        Matrix.rotateM(mModelMatrix, 0, angle, 0.0f, 1.0f, 1.0f);

        Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mModelMatrix, 0);

        Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0);

        GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mMVPMatrix, 0);

        banana.draw();
    }
}

`

  • 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-05T18:01:42+00:00Added an answer on June 5, 2026 at 6:01 pm

    Tried some glGetError() and got to errors, one regarding a variable that had its value unchanged and another was that glGetAttributeLocation() return a -1 if the attribute is not used in the vertex shader. Thaks for the help!

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

Sidebar

Related Questions

I have a problem using opengl on android to draw a simple rectangle. This
I have a problem to load more than one file. Obj in OpenGL. I
I have a problem with incorrect alpha blending results with openGL ES on iPhone.
I have this problem that when there is an OpenGL application I am working
I have a problem with lighting in my OpenGL application. When one of the
I have a problem somehow similar to this post : glTexGen in OpenGL ES
I have a problem when rendering cubes in OpenGL.I am drawing two cubes, one
I seem to have a curious problem. I set up OpenGL like this: glViewport(0,
I'm learning OpenGL from this tutorial: http://openglbook.com/the-book/ . I have problem with shaders. I'm
Several years ago, I wrote a small Cocoa/Obj-C game framework for OpenGL ES 1.1

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.