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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:56:04+00:00 2026-05-22T12:56:04+00:00

Currently I am trying to render a .obj model that I loaded into vectors.

  • 0

Currently I am trying to render a .obj model that I loaded into vectors. I am trying to pull the Vector3D object out of the array but it gives me an out of range error. It only goes to five before the array crashes, when the array has 12 objects for example. Here is the code for the rendering.

glBegin(GL_TRIANGLE_STRIP);

for (int indx = 0; indx < mv3_faces.size(); ++indx)
{
    if (mb_print_once)
    {
        std::cout << "Rendering Loop....Faces at 8: " << mv3_faces.at(5).x << " Current Index: " << indx << std::endl;
        std::cout << "Rendering Loop X: " << mv3_faces.at(indx).x << " Y: " << mv3_faces.at(indx).y << " Z: " << mv3_faces.at(indx).z << std::endl;
    }

    glColor4f(1.0f, 1.0f, 0.0f, 1.0f);

    glVertex3f(mv3_vertices.at(mv3_faces.at(indx).x).x, mv3_vertices.at(mv3_faces.at(indx).y).y, mv3_vertices.at(mv3_faces.at(indx).z).z);
}

mb_print_once = false;
glEnd();

Ignore the mb_print_once… that is for debugging purposes.

  • 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-22T12:56:04+00:00Added an answer on May 22, 2026 at 12:56 pm

    Did you remember that vertex indices in .OBJ files start at 1 rather than 0? So you have to decrement the vertex indices by 1 after reading them from an “f” tag.

    And also as a little comment, I would strongly suggest using [] instead of .at, although in this example it was a good idea, so you got the exception. But in general the range-checking overhead is not worth it, especially in such a highly to optimize loop.

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

Sidebar

Related Questions

currently i am trying to laod *.obj-files into my programm. My code is based
I'm currently trying to get ActiveAdmin to work on a model of mine but
I currently trying to find a solution, how to ensure that a test fails
I'm currently trying out db4o (the java version) and I pretty much like what
I'm currently trying to get into the Java EE development with the Spring framework.
I am currently trying to figure out how to do move semantics correctly with
I am trying to render video via the NDK, to add some features that
I am trying to render a UIView hierarchy into a CGContext or ultimately a
I'm trying to convert an ID into a name when I render a detail
I am currently trying to nest a UIWebView (among other elements) into a custom

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.