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

  • Home
  • SEARCH
  • 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 3402280
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:07:07+00:00 2026-05-18T05:07:07+00:00

I’m currently working on a procedural planet generation tool that works by taking a

  • 0

I’m currently working on a procedural planet generation tool that works by taking a cube, mapping it to a sphere and then applying a heightmap to each face to generate terrain.

I’m using a VBO for each face which is created using the following method:

void Planet::setVertexBufferObject()
{
 Vertex* vertices;
 int currentVertex;
 Vertex* vertex;

 for(int i = 0; i < 6; i++)
 {
  // bottom face
  if(i == 0)
  {
   glBindBuffer(GL_ARRAY_BUFFER, bottomVBO);    
  }
  // top face
  else if(i == 1)
  {
   glBindBuffer(GL_ARRAY_BUFFER, topVBO);    
  }
  // front face
  else if(i == 2)
  {
   glBindBuffer(GL_ARRAY_BUFFER, frontVBO);    
  }
  // back face
  else if(i == 3)
  {
   glBindBuffer(GL_ARRAY_BUFFER, backVBO);    
  }
  // left face
  else if(i == 4)
  {
   glBindBuffer(GL_ARRAY_BUFFER, leftVBO);    
  }
  // right face
  else
  {
   glBindBuffer(GL_ARRAY_BUFFER, rightVBO);    
  } 

  vertices = (Vertex*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);

  currentVertex = 0;

  for(int x = 0; x < size; x++)
  {
   for(int z = 0; z < size; z++)
   {
    currentVertex = z * size + x;

    vertex = &vertices[currentVertex];

    vertex->xTextureCoord = (x * 1.0f) / 512.0f;
    vertex->zTextureCoord = (z * 1.0f) / 512.0f;

    Vector3 normal;

    vertex->xNormal = normal.x;
    vertex->yNormal = normal.y;
    vertex->zNormal = normal.z;

    vertex->x = heightMapCubeFace[i][x][z][0];
    vertex->y = heightMapCubeFace[i][x][z][1];
    vertex->z = heightMapCubeFace[i][x][z][2];

    vertex->x *= (1.0f +((heightMaps[i][z][x]/256.0f) * 0.1));
    vertex->y *= (1.0f +((heightMaps[i][z][x]/256.0f) * 0.1));
    vertex->z *= (1.0f +((heightMaps[i][z][x]/256.0f) * 0.1));
   }
  }
  glUnmapBuffer(GL_ARRAY_BUFFER);
  glBindBuffer(GL_ARRAY_BUFFER, 0);
 }
}

I have left out the setIndexBufferObject() method as that is working OK.

I am then rendering the sphere using this method:

void Planet::render()
{
    // bottom face

    glBindBuffer(GL_ARRAY_BUFFER, bottomVBO);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bottomIBO);

    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), BUFFER_OFFSET(6 * sizeof(float)));

    glEnableClientState(GL_NORMAL_ARRAY);
    glNormalPointer(GL_FLOAT, sizeof(Vertex), BUFFER_OFFSET(3 * sizeof(float)));

    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(3, GL_FLOAT, sizeof(Vertex), BUFFER_OFFSET(0));

 TextureManager::Inst()->BindTexture(textueIDs[0]);
 glClientActiveTexture(GL_TEXTURE0+textueIDs[0]);
 glDrawElements(GL_TRIANGLE_STRIP, numberOfIndices, GL_UNSIGNED_INT, BUFFER_OFFSET(0)); 

    glDisableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_NORMAL_ARRAY);
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);

    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

 // next face and so on...

The textures are being loaded in using free image, as you can see from the above code I am just using the example texture manager that came with freeimage.

Why is binding the texture not working?

  • 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-18T05:07:07+00:00Added an answer on May 18, 2026 at 5:07 am

    Why is binding the texture not working?

    Describing very specifically the behavior you’re seeing, or better attaching a URL to a screenshot, goes a long way when trying to get through graphics questions.

    Next, you need to include the gl error state or at least demonstrate that within the code that you’re checking and failing if glGetError() doesn’t return GL_NO_ERROR.

    Your VBO / draw element state looks reasonable though you’ve deliberately omitted the definition of the index buffer object so we’ll take it on faith that you’re sending real indices into your glDrawElements() call. For a sanity check, do the glDrawElements() call with the raw indices pointer rather than binding a VBO for the elements.

    You’ve also omitted the type definition of Vertex which is required to know if the offsets you’re supplying to glTexCoordPointer() are consistent with the struct definition.

    Lastly, I’m guessing most people on the forum don’t know “free image” which I believe is what you’ve stated you’re using to load textures with. If there’s a texturing problem it’s impossible to see because of the opaque nature of using this 3rd party library to set up texturing on your behalf.

    If they’ve confused texture IDs, set up a wrap mode that isn’t supported, not set the minification filter consistent with the expected mipmapping (on/off), not enabled texturing, or set the texture environment mode such that the modulation with the base geometry color is not as you expect – all of these would make texturing not work / appear to be working.

    To troubleshoot just use the library for texture load and use the texture ID they provide. Then set up the filter modes and texture environment yourself. Turn off mipmapping while troubleshooting. Incomplete mipmap chains is a very common error when texturing.

    You can also turn off per-fragment operations to simplify your troubleshooting. Disable blending, depth testing, and scissoring.

    Assuming your texture is power of two dimensions or your implementation supports NPOT, try these settings immediately before drawing:

    glDisable(GL_DEPTH_TEST);
    glDisable(GL_BLEND);
    glDisable(GL_SCISSOR_TEST);
    glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
    glBindTexture(GL_TEXTURE_2D, texID);
    glTexEnvi(GL_TEXTURE_ENV_MODE, GL_REPLACE); // turn off modulation
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // turn off mipmapping
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); // turn off repeats
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want use html5's new tag to play a wav file (currently only supported
I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a JSP page retrieving data and when single or double quotes are
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.