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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:33:33+00:00 2026-06-02T19:33:33+00:00

I am having problems with my simple 2D OpenGL game. Its really weird, I

  • 0

I am having problems with my simple 2D OpenGL game.
Its really weird, I get textures to display correctly etc. but when I wanted to create particle effect with simple changing colors, for some reason it displays wrong colors from the buffer. I am using Android’s OpenGL ES 1.1 but its the same with any version of OpenGL that uses VBO’s.

I initialize the screen etc. and red triangle is displayed, but according to my color buffer it should be white, whats wrong?

        GL11 gl11 = (GL11) gl;
        gl11.glLoadIdentity();
        gl11.glClear(GL_COLOR_BUFFER_BIT);
        GLU.gluLookAt(gl, 0f, 0f, -container.getCamera().getScale(), 0f, 0f, 0f, 0f, -1f, 0f);
        gl11.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl11.glEnableClientState(GL10.GL_COLOR_ARRAY);

        gl11.glTranslatef(container.getCamera().getX(), container.getCamera().getY(), 0.0f);

        container.addParticle(new ColouredParticle(-container.getCamera().getX(), -container.getCamera().getY(), (float)Math.random(), (float)Math.random(), 0f, 5000));

        particleColorBufferPointer = createFloatBuffer(gl11, GL11.GL_ARRAY_BUFFER, new float[] {
                1f, 1f, 1f, 1f,
                1f, 1f, 1f, 1f,
                1f, 1f, 1f, 1f,

        });

        gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, particleColorBufferPointer);
        gl11.glColorPointer(4, GL10.GL_FLOAT, 0, 0);

        particleVertexBufferPointer = createFloatBuffer(gl11, GL11.GL_ARRAY_BUFFER, new float[]{
                -0.1f, -0.05f,
                0.1f, -0.05f,
                0.0f, 0.05f
        });
        gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, particleVertexBufferPointer);
        gl11.glVertexPointer(2, GL10.GL_FLOAT, 0, 0);

        gl11.glDrawArrays(GL11.GL_TRIANGLES, 0, 3);

        gl11.glDeleteBuffers(2, new int[]{particleVertexBufferPointer, particleColorBufferPointer}, 0);

        gl11.glDisableClientState(GL10.GL_VERTEX_ARRAY);
        gl11.glDisableClientState(GL10.GL_COLOR_ARRAY);

        int error = gl11.glGetError();
        if(error != GL11.GL_NO_ERROR) {
            Log.v(TAG, "error " + Integer.toHexString(error));
        }

Its just simple hardcoded float array containing the triangle vertices and colors, but for some reason the colors are wrong as I said before, what can possibly go wrong with such small amount of code? the color doesn’t change to anything but black, like it only reads the red value from the buffer. Also it gives absolutely no error at all!

createFloatBuffer method:

private int createFloatBuffer(GL11 gl, int type, float[] data) {
    int[] bufferPointerBuffer = new int[1];
    gl.glGenBuffers(1, bufferPointerBuffer, 0);
    int bufferPointer = bufferPointerBuffer[0];
    gl.glBindBuffer(type, bufferPointer);
    FloatBuffer dataBuffer = createFloatBuffer(data);
    gl.glBufferData(type, data.length * FLOAT_SIZE, dataBuffer, GL_STATIC_DRAW);
    gl.glBindBuffer(type, -1);
    return bufferPointer;
}
  • 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-02T19:33:34+00:00Added an answer on June 2, 2026 at 7:33 pm

    Wow.. It all was because I had texture bound and it for some reason tried to draw it even if I had texture coords disabled, I wish i could have just listened when I got told to disable any state thats not needed anymore.. Thanks guys! Problem solved!

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

Sidebar

Related Questions

I'm Basically programming a simple game engine but I'm having problems with my sprites/images
I'm having some problems with the simple 2D game in OpenGL in JOGL I'm
Im having some problems with a simple toggle in Safari. A really annoying flickering
This is probably got a simple answer to it, but I am having problems
My model is quite simple but I'm having some problems with the vector I'm
This should be simple, but I am having problems. Using the eBay .Net library,
I have no idea why I am having problems with something so simple but
No doubt I'm doing something stupid, but I've been having problems running a simple
I know this should be a simple task but I'm having problems selecting a
I'm creating a simple GUI app using Tkinter with Python, but I'm having problems

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.