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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:27:17+00:00 2026-05-26T14:27:17+00:00

I have a problem using opengl on android to draw a simple rectangle. This

  • 0

I have a problem using opengl on android to draw a simple rectangle.
This is what I have done.

I drew a simple rectangle with sketchup. I exported the result using
a 3d-model collada .dae file. I then copied the vertices data from
the .dae (xml) file and put in an array. I copied the array in native
format to a float buffer. I then drew the triangles using stripe
mode. The result is nearly a rectangle. It is missing a triangle on
each surface.

Here is the relevant portion of code and the result.

public void draw(GL10 gl) {
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexBuffer);
    // Enable color tracking
    gl.glEnable(GL10.GL_COLOR_MATERIAL);
    for (int i=0; i<108/4; i=i+4) {
        myDrawColor(gl,i);
        gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP,i,4);// mode, first, count
    }
}

the result is shown here
https://i.stack.imgur.com/KhnNz.jpg

  • 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-26T14:27:18+00:00Added an answer on May 26, 2026 at 2:27 pm

    I got the code working. There were three problems.

    1. DrawArrays works forward through the vertex array. ie. you draw one element from the array at a time and then go to the next. You can not hop back and forth thru it.
    2. Using the offset list in the .xml file I created an array that I could use with glDrawElements where it hops around in the vertices list.
    3. You need to use unsigned short of the offset. I was using an integer and fixed which did not work.

    Here is the resulting code that works. The problem was mine. Not the .xml file produced from sketchup.

    public void draw(GL10 gl) {
        gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexBuffer);
        gl.glColorPointer(4, GL10.GL_FLOAT, 0, mColorsBuffer);
        gl.glEnable(GL10.GL_COLOR_MATERIAL); 
    // Enable color tracking 
        gl.glEnable(GL10.GL_COLOR_MATERIAL);
        gl.glDrawElements(GL10.GL_TRIANGLES, myoffsets.length, GL10.GL_UNSIGNED_SHORT, mIndicesBuffer); // mode, count, type, indices
    }
    
    • 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 the Catch Clipboard Events code found on this link
I need to draw a spinning globe using opengl es in android. I think
I have problem while using jquery maskedinput with asp.net textbox. I have a check
I have a problem using the Java search function in Eclipse on a particular
I have a problem using Linq to NHibernate to load an object and eagerly
I have a problem using the SSIS. I try to import data from database
I have a problem using JSON and arrays. Here is my code: while($row =
Greetings, I have a problem using jqgrid and jquery tab (I am coding in
I have the following problem using subversion: I'm currently working on the trunk of
I have the following problem using template instantiation [*]. file foo.h class Foo {

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.