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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:43:41+00:00 2026-06-10T09:43:41+00:00

I ran into a problem latley. I have a class DrawableTexturedPlane. This class specifies

  • 0

I ran into a problem latley.

I have a class DrawableTexturedPlane. This class specifies a simple Plane with a byte array as Texture. The array data can be changed by a simple function call. Well, the class takes a specific shader program as parameter. In my OpenGL View, i need 2 of those planes. Well, the first renders correctly, but the second does not show up at all. Im quite sure im missing something, but i am not sure which part of my code is incorrect. I would appreciate any help 😉

TexturedPlaneClass (relevant parts):

public DrawableTexturedPlane( float[] fVertices, int nProgrammHandle, int nGLTextureChannel, int nGLTextureID ) 
    {  
        super( nProgrammHandle );
        m_bHasBorder = bHasBorder;

        m_nGLTextureChannel = nGLTextureChannel;
        m_oVertexBuffer = _GetVertexBuffer( fVertices );
        m_oTextureBuffer = _GetTextureCoordinates();



        GLES20.glActiveTexture( m_nGLTextureChannel );  
        // Set filtering
        GLES20.glTexParameterf( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST );
        GLES20.glTexParameterf( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST );
        GLES20.glTexParameteri( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE );
        GLES20.glTexParameteri( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE );

        m_cTexture = new byte[ 640 * 480 ];


        Log.i( "Java/DrawableTexturedPlane", "Drawable Textured Plane created!" );
    }

the Draw Method:

 @Override
    public void Draw( float[] mvpMatrix )
    {

        GLES20.glActiveTexture( m_nGLTextureChannel );

        GLES20.glEnable(GLES20.GL_TEXTURE_2D);
        GLES20.glEnable(GLES20.GL_DEPTH_TEST);

        GLES20.glUseProgram( m_nProgramHandle );


        m_HTextureUniform = GLES20.glGetUniformLocation( m_nProgramHandle, "uTexture" );
        m_HTextureCoordinate = GLES20.glGetAttribLocation( m_nProgramHandle, "TexCoordinate" );


        // get handle to the vertex shader's vPosition member
        m_nPositionHandle = GLES20.glGetAttribLocation( m_nProgramHandle, "vPosition" );


        ByteBuffer oDataBuf = ByteBuffer.wrap( m_cTexture );
        // Prepare the triangle data
        GLES20.glTexImage2D( GLES20.GL_TEXTURE_2D, 0, GLES20.GL_LUMINANCE, 640, 480,
                             0, GLES20.GL_LUMINANCE, GLES20.GL_UNSIGNED_BYTE, oDataBuf );

        // Prepare the triangle data
        GLES20.glVertexAttribPointer( m_nPositionHandle, 3, GLES20.GL_FLOAT, false, 12, m_oVertexBuffer );
        GLES20.glEnableVertexAttribArray( m_nPositionHandle );

        GLES20.glVertexAttribPointer( m_HTextureCoordinate, 2, GLES20.GL_FLOAT, false, 12, m_oTextureBuffer); 
        GLES20.glEnableVertexAttribArray( m_HTextureCoordinate );

        m_nMVPMatrixHandle = GLES20.glGetUniformLocation( m_nProgramHandle, "uMVPMatrix");

        // Apply the projection and view transformation
        GLES20.glUniformMatrix4fv( m_nMVPMatrixHandle, 1, false, mvpMatrix, 0);

        GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 6);

    }

Here is how the textures and the 2 planes are created:

 GLES20.glGenTextures( m_nTextureStorage.length, m_nTextureStorage, 0);

        for( int i : m_nTextureStorage )
        {
            GLES20.glBindTexture( GLES20.GL_TEXTURE_2D, i );
        }


        m_oInfoPlane = new DrawableTexturedPlane( oInfoRect.GetAsFloatArray(), true, m_nShaderPrograms[0], GLES20.GL_TEXTURE0, m_nTextureStorage[0] );   
        m_oMainPlane =  new DrawableTexturedPlane( oMainRect.GetAsFloatArray(), true, m_nShaderPrograms[0], GLES20.GL_TEXTURE1, m_nTextureStorage[1] );

Well the point is, if i initialize BOTH wirh GL_TEXTURE0, it works fine. (Although heavy flickering occurs after 10 – 20 seconds, i dont know why ).

If i initialize them the way i did it above, only the one with TEXTURE_0 is shown correctly, the other one apperas to be black.

I know i should write a TextureManager class, but for 2 Textures, this is a simple overkill.

Thanks in advance

  • 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-10T09:43:43+00:00Added an answer on June 10, 2026 at 9:43 am

    Your not binding the texture at the right time. Plus you can’t bind 2 different textures to GL_TEXTURE_2D.

    It should look like this:

    GLES20.glActiveTexture( m_nGLTextureChannel ); //Activate the texture channel
    
      GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, nGLTextureID); //Bind here!
    //Bind before you draw
    

    I know i should write a TextureManager class, but for 2 Textures, this is a simple overkill.

    As for this its not about right now, but about the needs of the overall project. Will you need a manager later on? Upfront design pays off but don’t go overboard. (Kinda contradicting! Good luck!)

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

Sidebar

Related Questions

Never ran into this problem with jQuery before. I have the following: $(document).ready(function() {
I ran into this problem and I cant solve it. Basically Im making an
I ran into a problem with some C code like this: struct SomeType {
Similar to my last question, but I ran into problem lets say I have
I ran into a problem today at work wherein I have a BindingGroup that
Ran into a problem. I have a spawned thread that must call its finally
I ran into this problem while trying to fix a memory leak with the
I ran into a problem this week regarding implicit conversions in C# on collections.
I ran into such problem: I have one header file: //first variant: #ifndef LIBRARIES_H
I ran into this problem at my old job, and now again at my

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.