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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:40:18+00:00 2026-06-03T23:40:18+00:00

I am having trouble getting my 3D model textured, I am just diving into

  • 0

I am having trouble getting my 3D model textured, I am just diving into 3D models as I have been using basic primitives for testing purposes and have been working on more engine specific code. I am however having trouble with the glDrawElements function, I know my texture is loaded properly as I am able to draw it to a quad (note the glBegin in comments). However, when using glDrawElements I do not get the texture drawn. It does show the colour of part of the texture (yellow), and when I remove the texturing code it returns the 3D model to the last colour that has been set, so it is doing something. I am thinking maybe it is something to do with my glVertexAttributePointer , I get what these functions do sort of.

glMatrixMode(GL_MODELVIEW);
    glMultMatrixf(m_Props.WorldMatrix.data);

    glEnableVertexAttribArray(0);
    glEnableVertexAttribArray(1);
    glEnableVertexAttribArray(2);

    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(VertexPTN), 0);
    glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(VertexPTN), (const GLvoid*)12);
    glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(VertexPTN), (const GLvoid*)20);

    glBindBuffer(GL_ARRAY_BUFFER, pExtra->GetVB());
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, pExtra->GetIB());

    glScalef(0.05, 0.05, 0.05);

    glEnable(GL_TEXTURE_2D);
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, pTexExtra->GetTexture());

     glDrawElements(GL_TRIANGLES, pExtra->GetIndexCount(), GL_UNSIGNED_INT, 0); 
     /*glBegin(GL_QUADS);
        glTexCoord2f(0, 0); glVertex3f(0.0f, 0.0f, 0.0f);
        glTexCoord2f(0, 1); glVertex3f(10.0f, 0.0f, 0.0f);
        glTexCoord2f(1, 1); glVertex3f(10.0f, 10.0f, 0.0f);
        glTexCoord2f(1, 0); glVertex3f(0.0f, 10.0f, 0.0f);
     glEnd();*/

    glDisable(GL_TEXTURE_2D);


    glDisableVertexAttribArray(2);
    glDisableVertexAttribArray(1);
    glDisableVertexAttribArray(0);

My VertexPTN class is simply a container for a Position, Texture Coordinate and Normal. So I am assuming as the positioning of my vectors in the class goes; Vector3f, Vector2f, Vector3f, I would set the last parameter of the glVertexAttributePointer to 0, 12, 20.

Is there any missunderstanding of anything that I am missing? I’m really not pro with openGL but I do understand a decent amount of the setup and basic rendering. What is causing my texture to not render to my mesh, an unset GL state?

  • 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-03T23:40:20+00:00Added an answer on June 3, 2026 at 11:40 pm

    Some thoughts:

    Are you using shaders? glVertexAttribPointer only works with shaders

    • If Yes:
      Are you certain that your inputs are 0, 1, and 2? If you don’t set these before shader linking with glBindAttribLocation, they aren’t guaranteed to be any particular values.
    • If No: You should be using glVertexPointer, glTexCoordPointer, etc instead of
      AttribPointer

    Also if you’re using shaders, then enabling/disable GL_TEXTURE_2D is redundant, it doesn’t do anything.

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

Sidebar

Related Questions

I am having trouble getting my model manager to behave correctly when using the
I'm having trouble getting Visual Studio to recognize the @model directive in MVC3. As
I'm having trouble getting ThinkingSphinx to recognize my conditions. My Discussion model includes the
I am having trouble getting my modal view controllers to display properly. I have
I am having trouble getting my chat application working correctly. I have 2 textbox's,
I'm having trouble getting url_for to render take to_param into account when choosing which
I have a exceedingly simplistic data model (below). I am having trouble figuring out
I'm having trouble getting the results of a has_many query using php idiorm/paris. Following
I'm having trouble getting C# and JavaScript/jQuery to play nice here. I have a
I'm having trouble getting my models associated, or I'm somehow ignorant about how to

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.