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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:11:19+00:00 2026-05-26T08:11:19+00:00

I need a little help with this: android developers, Tutorials: OpenGLES10. a link It

  • 0

I need a little help with this:
android developers, Tutorials: OpenGLES10.
a link

It all works fine for the first Triangle, until I put in the code for Projection & Camera View. This should rezise OpenGLES Square view to match Phone’s screen, so object stay in propotions.
As a Newbie watching, the code looks fine and i have cheked with referencefiles, that there’s not missing a parameter or something like that. But now i’m lost..! Can’t see what’s wrong.
If Projection and Camera code are applied, there is no triangle, but the app. is runing and the View with backgroundcolor are shown.

Here is my code:

    package notme.helloopengles10;

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

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

import android.opengl.GLSurfaceView;
import android.opengl.GLU;

public class HelloOpenGLES10Renderer implements GLSurfaceView.Renderer {

// Set the background frame color
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    gl.glClearColor(0.5f, 0.5f, 0.5f, 1.0f);

    // initialize the triangle vertex array
    initShapes();
    //enable use of vertex arrays
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
}

public void onDrawFrame(GL10 gl) {
    // Redraw background color  
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

 /* // set GL_MODELVIEW transformation mode (If outline from here to after GLU.gluLookAt() - it works when also outlines further down i code!
    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glLoadIdentity();  // reset Matrix to its default state

    // when using GL_MODELVIEW, you must set the view point
    GLU.gluLookAt(gl, 0, 0, -5, 0f, 0f, 0f, 0f, 1.0f, 0.0f);  */

    //Draw Triangel
    gl.glColor4f(0.63671875f, 0.76953125f, 0.22265625f, 0.0f);
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, triangleVB);
    gl.glDrawArrays(GL10.GL_TRIANGLES, 0, 3);
}

// Redraw on orientation changes // adjust for screen size ratio
public void onSurfaceChanged(GL10 gl, int width, int height) {
    gl.glViewport(0, 0, width, height);

    // Make adjustments  for screen ratio 
 /*(If outline from here to after gl.Frumstumf() - it works!
    float ratio = (float) width / height;
    gl.glMatrixMode(GL10.GL_PROJECTION);  // set matrix to projection mode
    gl.glLoadIdentity();                  // reset the matrix to its default state
    gl.glFrustumf(-ratio, ratio, -1, 1, 3, 7);        // apply the projection   */

}

/*
 * Draw a shape, a triangle. first add new member variable to contain
* the vertices of a triangle
*/
 private FloatBuffer triangleVB;

//Create a method, initShaoe(), which populate the members variable
 private void initShapes(){
     //create a array 
     float triangleCoords[] = {
             // X, Y, Z
             -0.5f, -0.25f, 0,
             0.5f, -0.25f, 0,
             0.0f, 0,559016994f, 0
     };
 // initialize vertex Buffer for triangle
     ByteBuffer vbb= ByteBuffer.allocateDirect(
             //(# of coordinates values * 4 bytes per float)
             triangleCoords.length * 4 );
     vbb.order(ByteOrder.nativeOrder()); // use device hardware's native byte order
     triangleVB = vbb.asFloatBuffer(); //create floating point buffer from the ByteBuffer
     triangleVB.put(triangleCoords);  // add coordinates to the FloatBuffer
     triangleVB.position(0);  // set the buffer to read the first coordinate
 }


} // end

I hope some one can tell me, where things go wrong?

DevTool: Eclipse.

  • 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-05-26T08:11:20+00:00Added an answer on May 26, 2026 at 8:11 am

    The code looks resonable (if you uncomment the parts that are commented out at the moment). Your matrix modification code is quite correct and all transformations are applied to the correct matrices.

    But at the moment you are looking from the point (0,0,-5) to the point (0,0,0) and therefore along the +z axis. But since the default OpenGL view looks along the -z axis, you actually rotate the view 180 degrees around the y-axis. Whereas this is absolutely no problem, you now see the back-side of the triangle. So can it be, that you have back-face culling enabled and this back-side is just optimized away? Just try disabling back-face culling by calling glDisable(GL_CULL_FACE) or change the -5 in the gluLookAt call to a 5, so that you look along the -z axis.

    You can also try to use gluPerspective(45, ratio, 3, 7) instead of the glFrustum call, but your arguments to glFrustum look quite reasonable. Of course, keep in mind that both calls create a perspective view, with farther objects getting smaller, like in reality. If you actually want a parallel/orthographic view (where size on screen is independent on depth) you should replace the glFrustum with a glOrtho, though the parameters can stay the same.

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

Sidebar

Related Questions

I need a little help on this subject. I have a Web application written
I need a little help creating a catch-all error handling page in my ICEfaces
Need a little help with string formatting... I have a string like this: Bmw
I need little bit help related to android tabhost. I have 3 tabs and
I need a little help figuring this out because I'm new to stored procedures.
I'm new programing in Python, and what I need a little help with this
I'm so close on this one, but I need a little help. I have
I need a little help getting this jQuery plugin to work correctly for me.
Hey, i need a little help with this django function. I wan't to insert
I'm new to C# (asp.net) so i need little help. On this forum I

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.