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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:42:49+00:00 2026-06-15T01:42:49+00:00

I get a white square box and not the texture I what on the

  • 0

I get a white square box and not the texture I what on the screen. Oh I do not think this would matter but just in case I put a linearlayout view first then the surfaceview.

Here my code:

public class GameEngine {

    private float vertices[];
    private float textureUV[];

    private int[] textureId = new int[1];

    private FloatBuffer vertextBuffer;
    private FloatBuffer textureBuffer;

    private short indices[] = {0,1,2,2,1,3};
    private ShortBuffer indexBuffer;

    private float x, y, z;
    private float rot, rotX, rotY, rotZ; 


    public GameEngine() {

    }

    public void setEngine(float x, float y, float vertices[]){
        this.x = x;
        this.y = y;
        this.vertices = vertices;

        ByteBuffer vbb = ByteBuffer.allocateDirect(this.vertices.length * 4);
        vbb.order(ByteOrder.nativeOrder());

        vertextBuffer = vbb.asFloatBuffer();
        vertextBuffer.put(this.vertices);
        vertextBuffer.position(0);
        vertextBuffer.clear();


        ByteBuffer ibb = ByteBuffer.allocateDirect(indices.length * 2);
        ibb.order(ByteOrder.nativeOrder());

        indexBuffer = ibb.asShortBuffer();
        indexBuffer.put(indices);
        indexBuffer.position(0);
        indexBuffer.clear();
    }



    public void draw(GL10 gl){
        gl.glLoadIdentity();
        gl.glTranslatef(x, y, z);
        gl.glRotatef(rot, rotX, rotY, rotZ);

        gl.glBindTexture(GL10.GL_TEXTURE_2D, textureId[0]);

        gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
        gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);


        gl.glVertexPointer(2, GL10.GL_FLOAT, 0, vertextBuffer);
        gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer);



        gl.glDrawElements(GL10.GL_TRIANGLES, indices.length, GL10.GL_UNSIGNED_SHORT, indexBuffer);


        gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
        gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);

    }

    public void LoadTexture(float textureUV[], GL10 gl, InputStream is) throws IOException{

        this.textureUV = textureUV;

        ByteBuffer tbb = ByteBuffer.allocateDirect(this.textureUV.length * 4);
        tbb.order(ByteOrder.nativeOrder());
        textureBuffer = tbb.asFloatBuffer();
        textureBuffer.put(this.textureUV);
        textureBuffer.position(0);
        textureBuffer.clear();

        Bitmap bitmap = null;

        try{
            bitmap = BitmapFactory.decodeStream(is);

        }finally{
            try{
                is.close();
                is = null;
                gl.glGenTextures(1, textureId,0);   
                gl.glBindTexture(GL10.GL_TEXTURE_2D, textureId[0]);


                gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST);
                gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);

                //Different possible texture parameters, e.g. GL10.GL_CLAMP_TO_EDGE
                gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_REPEAT);
                gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_REPEAT);

                //Use the Android GLUtils to specify a two-dimensional texture image from our bitmap
                GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);


                gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);

                //Clean up
                gl.glBindTexture(GL10.GL_TEXTURE_2D, textureId[0]);

                bitmap.recycle();
            }catch(IOException e){

            }

        }

    }



    public void setVector(float x, float y, float z){
        this.x = x;
        this.y = y;
        this.z = z;
    }

    public void setRot(float rot, float x, float y, float z){
        this.rot = rot;
        this.rotX = x;
        this.rotY = y;
        this.rotZ = z;
    }

    public float getZ(){
        return z;
    }
}
  • 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-15T01:42:50+00:00Added an answer on June 15, 2026 at 1:42 am

    Make sure your texture is a power-of-two size. You can’t use NPO2 textures with GL_REPEAT.

    Also I don’t see glEnable(GL_TEXTURE_2D) anywhere.

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

Sidebar

Related Questions

I could not figure out how to get the white fill for this ggplot2
Why does this not display me the graphic? All I get is a white
How in opencart would I only write/get the cache if the domain is not
I'm stuck at not being able to map texture to a square in openGLES.
I think the title is rather self explanatory but just to clarify I am
http://jsfiddle.net/XjsWZ/ I'm trying to get the white box itself to have rounded corners in
i need to get items from a List with no leading or trailing white
Is there a way to get the add (the green circle with the white
my question is simple.... How to get rid of the white background color of
I get this error while accessing a php script: W/System.err: Error reading from ./org/apache/harmony/awt/www/content/text/html.class

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.