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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:37:40+00:00 2026-05-23T22:37:40+00:00

Here is my GL init code: gl.glEnable(GL10.GL_TEXTURE_2D); gl.glShadeModel(GL10.GL_SMOOTH); gl.glEnable(GL10.GL_BLEND); gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); gl.glDisable(GL10.GL_DEPTH_TEST); gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadIdentity();

  • 0

Here is my GL init code:

    gl.glEnable(GL10.GL_TEXTURE_2D);
    gl.glShadeModel(GL10.GL_SMOOTH);

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

    gl.glDisable(GL10.GL_DEPTH_TEST);
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glLoadIdentity();

    gl.glViewport(0, 0, width, height);

    float left = 0;
    float right = width;
    float top = height;
    float bottom = 0;
    gl.glOrthof(left, right, top, bottom, -1, 1);

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glLoadIdentity();

    textures.put("ball", new Texture(gl, BitmapFactory.decodeResource(context.getResources(), R.drawable.ball)));

And here is my Texture class

public class Texture
{
int[] texture = new int[1];

static int real_width = 0;
static int real_height = 0;

Texture(GL10 gl, Bitmap bmp)
{
    real_width = bmp.getWidth();
    real_height = bmp.getHeight();

    gl.glGenTextures(1, texture, 0);

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

    GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bmp, 0);
    bmp.recycle();

    int error = gl.glGetError();
    if (error != GL10.GL_NO_ERROR)
    { 
        Log.e("ROLL", "GL Texture Load Error: " + GLU.gluErrorString(error));
    }
}

public void draw(GL10 gl, float x, float y)
{
    draw(gl, x, y, real_width, real_height);
}

public void draw(GL10 gl, float x, float y, float w, float h)
{
    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

    float[] vertices = { x + w, y + h, x, y + h, x, y, x + w, y };
    float[] textureCoords = { 1, 1, 0, 1, 0, 0, 1, 0 };

    ByteBuffer byteBuf = ByteBuffer.allocateDirect(vertices.length * 4);
    byteBuf.order(ByteOrder.nativeOrder());
    FloatBuffer vertexBuffer = byteBuf.asFloatBuffer();
    vertexBuffer.put(vertices);
    vertexBuffer.position(0);

    byteBuf = ByteBuffer.allocateDirect(textureCoords.length * 4);
    byteBuf.order(ByteOrder.nativeOrder());
    FloatBuffer textureBuffer = byteBuf.asFloatBuffer();
    textureBuffer.put(textureCoords);
    textureBuffer.position(0);

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

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

    gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 0, 4);

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

}
}

The problem I get is where nothing is drawn but a white box in the correct shape and position of where the texture should be.

The image is size 50×50 and I thought it would be due to the power of 2 thing, but this problem also occurs on the emulator.

Also, I do get an error in the log and it says: “GL Texture Load Error: invalid value”, but I do not know what that means.

Finally, I draw the texture like this:

gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

textures.get("ball").draw(gl, 10, 10);
  • 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-23T22:37:41+00:00Added an answer on May 23, 2026 at 10:37 pm

    From glTexImage2D:

    • GL_INVALID_VALUE is generated if internalFormat is not 1, 2, 3, 4, or
      one of the accepted resolution and format symbolic constants.
    • GL_INVALID_VALUE is generated if width or height is less than 0 or
      greater than 2 + GL_MAX_TEXTURE_SIZE.
    • GL_INVALID_VALUE is generated if non-power-of-two textures are not
      supported and the width or height cannot be represented as 2k + 2
      border for some integer value of k.
    • GL_INVALID_VALUE is generated if border is not 0 or 1.

    I assume that internal format would be wrong. What about trying to specify it for your own. More documentation about GLUtils you can find there.

    But as first i see you haven’t bind texture before loading it to GL.

    gl.glGenTextures(1, texture, 0);
    gl.glBindTexture(GL10.GL_TEXTURE_2D, texture[0]); 
    
    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_NEAREST);
    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST);
    
    GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bmp, 0);
    bmp.recycle();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the code: tinyMCE.init({ mode: textareas, theme: advanced, plugins: autolink,lists,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template, // Theme options
Im using TinyMCE here is my code :- tinyMCE.init({ // General options mode :
Here is the code : @implementation Accumulateur // Constructor - (id) init { return
Here is some code: var class = function(elem,div){ this.elem= elem; this.div = div; this.init
Given the code from here : class lazy_init { mutable std::once_flag flag; mutable std::unique_ptr<expensive_data>
I have two functions here function Preloader() {} Preloader.prototype = { init:function() { //
I can't init lua correctly under Arch Linux. Lua - latest version. Here is
UPDATE: got rid of the line GLES20.glEnable(GLES20.GL_TEXTURE_2D); But the line GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGB, 256,
I'm developing an iPhone app. I have the following INIT code: shapes = [NSMutableArray
I'm doing a little python plasmoid that deals with remote resources. Here's the code

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.