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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:16:57+00:00 2026-06-14T11:16:57+00:00

I used an object exporter to get a model of cube from Blender. For

  • 0

I used an object exporter to get a model of cube from Blender. For some reason I can’t get the cube rendered – it’s probably my lack of view and projection matrices understanding. Could you point out my mistake ?

Rendering a simple triangle with the same renderer, however, 0.0f, 0.49f, 0.0f, -0.49f, 0.0f, 0.0f, 0.49f, 0.0f, 0.0f completes fine.

public class CubeRenderer implements Renderer {

public float xAngle = 0;
public float yAngle = 0;

    public CubeRenderer() {
        cubeBuffer = ByteBuffer.allocateDirect(CubeModel.VERTICES.length * 8)
                .order(ByteOrder.nativeOrder()).asDoubleBuffer();
        cubeBuffer.put(CubeModel.VERTICES).position(0);
    }


@Override
public void onDrawFrame(GL10 arg0) {
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
    GLES20.glUseProgram(iProgramHandle);
    cubeBuffer.position(0);
    GLES20.glVertexAttribPointer(iPositionHandle, 3, GLES20.GL_FLOAT, false, 0,
            cubeBuffer);
    GLES20.glEnableVertexAttribArray(iPositionHandle);
    Matrix.setIdentityM(m_fIdentity, 0);
    Matrix.rotateM(m_fIdentity, 0, -xAngle, 0, 1, 0);
    Matrix.rotateM(m_fIdentity, 0, -yAngle, 1, 0, 0);


    Matrix.multiplyMM(m_MVPMatrix, 0, m_fViewMatrix, 0, m_fIdentity, 0);

    Matrix.multiplyMM(m_MVPMatrix, 0, m_fProjMatrix, 0, m_MVPMatrix, 0);

    GLES20.glUniformMatrix4fv(iMVPMatrixHandle, 1, false, m_MVPMatrix, 0);

    GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, CubeModel.VERTICES_COUNT);
}

@Override
public void onSurfaceChanged(GL10 arg0, int width, int height) {
    GLES20.glViewport(0, 0, width, height);
    float ratio = (float) width / height;
    Matrix.frustumM(m_fProjMatrix, 0, -ratio, ratio, -1.0f, 1.0f, 1.0f, 10.0f);
}

@Override
public void onSurfaceCreated(GL10 arg0, EGLConfig arg1) {
    GLES20.glClearColor(0.5f, 0.5f, 0.5f, 1);
    GLES20.glEnable(GLES20.GL_DEPTH_TEST);
    GLES20.glFrontFace(GLES20.GL_CCW);



    Matrix.setLookAtM(m_fViewMatrix, 0, 0.0f, 3.0f, 5.5f, 0.0f, 0.0f, -10.0f, 0.0f, 1.0f, 0.0f);

    iProgramHandle = Utils.LoadProgram(CubeModel.VERTEX_SHADER_CODE, CubeModel.FRAGMENT_SHADER_CODE);
    iColorHandle = GLES20.glGetAttribLocation(iProgramHandle, "a_color");
    iPositionHandle = GLES20.glGetAttribLocation(iProgramHandle, "a_position");
    iMVPMatrixHandle = GLES20.glGetUniformLocation(iProgramHandle, "u_MVPMatrix");
}

}


public class CubeModel {

    public final static String VERTEX_SHADER_CODE = "attribute vec4 a_position;\n"
            + "attribute vec4 a_color;" + "uniform mat4 u_MVPMatrix;\n"
            + "varying vec4 v_color;" 
            + "void main()" + "{"
            + "v_color = a_color;"
            + "gl_Position = u_MVPMatrix * a_position;" + 
            "}";

    public final static String FRAGMENT_SHADER_CODE = "precision mediump float;"
            + "varying vec4 v_color;" + "void main()" + "{"
            + "gl_FragColor = vec4 ( 1.0, 0.0, 0.0, 1.0 );" + "}";

    public final static int VERTICES_COUNT = 36;

    public final static double[] VERTICES = new double[]{
      // f 1 2 3 4
      0.499999812500094, -0.499999750000125, -0.499999875000062,
      0.499999812500094, -0.499999750000125, 0.499999625000187,
      -0.499999687500156, -0.499999750000125, 0.499999625000187,
      // f 1 2 3 4
      0.499999812500094, -0.499999750000125, -0.499999875000062,
      -0.499999687500156, -0.499999750000125, -0.499999875000062,
      -0.499999687500156, -0.499999750000125, 0.499999625000187,
      // f 5 8 7 6
      0.499999812500094, 0.499999750000125, -0.499999375000312,
      -0.499999687500156, 0.499999750000125, -0.499999875000062,
      -0.499999687500156, 0.499999750000125, 0.499999625000187,
      // f 5 8 7 6
      0.499999812500094, 0.499999750000125, -0.499999375000312,
      0.499999312500344, 0.499999750000125, 0.500000124999937,
      -0.499999687500156, 0.499999750000125, 0.499999625000187,
      // f 1 5 6 2
      0.499999812500094, -0.499999750000125, -0.499999875000062,
      0.499999812500094, 0.499999750000125, -0.499999375000312,
      0.499999312500344, 0.499999750000125, 0.500000124999937,
      // f 1 5 6 2
      0.499999812500094, -0.499999750000125, -0.499999875000062,
      0.499999812500094, -0.499999750000125, 0.499999625000187,
      0.499999312500344, 0.499999750000125, 0.500000124999937,
      // f 2 6 7 3
      0.499999812500094, -0.499999750000125, 0.499999625000187,
      0.499999312500344, 0.499999750000125, 0.500000124999937,
      -0.499999687500156, 0.499999750000125, 0.499999625000187,
      // f 2 6 7 3
      0.499999812500094, -0.499999750000125, 0.499999625000187,
      -0.499999687500156, -0.499999750000125, 0.499999625000187,
      -0.499999687500156, 0.499999750000125, 0.499999625000187,
      // f 3 7 8 4
      -0.499999687500156, -0.499999750000125, 0.499999625000187,
      -0.499999687500156, 0.499999750000125, 0.499999625000187,
      -0.499999687500156, 0.499999750000125, -0.499999875000062,
      // f 3 7 8 4
      -0.499999687500156, -0.499999750000125, 0.499999625000187,
      -0.499999687500156, -0.499999750000125, -0.499999875000062,
      -0.499999687500156, 0.499999750000125, -0.499999875000062,
      // f 5 1 4 8
      0.499999812500094, 0.499999750000125, -0.499999375000312,
      0.499999812500094, -0.499999750000125, -0.499999875000062,
      -0.499999687500156, -0.499999750000125, -0.499999875000062,
      // f 5 1 4 8
      0.499999812500094, 0.499999750000125, -0.499999375000312,
      -0.499999687500156, 0.499999750000125, -0.499999875000062,
      -0.499999687500156, -0.499999750000125, -0.499999875000062,
    };
}
  • 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-14T11:16:58+00:00Added an answer on June 14, 2026 at 11:16 am

    You’ve got a double buffer and you’re telling OpenGL that it’s a buffer of GL_FLOAT, perhaps that’s a problem?

    You might want to use float buffer instead.

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

Sidebar

Related Questions

Doing code analysis of the project and get the message Reference-counted object is used
a) Can Object.GetType also be used for late binding ( Book I’m reading says
I am filling some Objects from my View Controller using the following Method :
for the longest time now i've used object literals to replace multiple var statements
This is about asp.net mvc3 web application. We have used Object cache to store
I'm thinking of wrapping frequently used Cocoa object selectors with my own code to
It's common to have an object used application wide. What are the different patterns
How to find memory used by an object in PHP? (c's sizeof). The object
In the past I've always used a FileStream object to write or rewrite an
What does 'this' keyword refer to when used in global object? Let's say for

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.