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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:21:45+00:00 2026-06-17T10:21:45+00:00

We’ve been creating a very basic model loader. The code itself is below; the

  • 0

We’ve been creating a very basic model loader. The code itself is below; the main problem is when the stringstream detects an ‘f’ as a first character. The code has been overly simplified (it was a bit more complicated at first) for the sake of debugging. At the moment, cout << ind3; is giving 0. It should read either a 2 or a 5, depending on which line the reader is on. The two vector parameters are used to write to for drawing, but at the minute I’ve removed this operation.

The two ‘f’ lines are:
f 0 1 2
f 3 4 5

The program reads the v (vertex) lines in just fine; it won’t read in f lines.

bool modelLoader(string fileName,vector<GLfloat>& vertices, vector<GLushort>& indices)
{
vector<GLfloat> localVertices;
ifstream objFile;
string line,testline;
stringstream ss;

GLfloat x, y, z;
//GLushort ind1, ind2, ind3; Excluded for testing
int ind1=0, ind2=0, ind3=0; 
objFile.open(fileName);
if (!objFile.is_open())
{
    cout << "FAILED TO LOAD: OBJ FILE\n";

    return false;
}

while ( objFile.good() )
{
    getline(objFile, line);
    ss.str(line);

    if (line == "")
    {
        continue;
    }

    else if(line[0] == 'v')
    {
        ss.ignore(2);
        ss >> x >> y >> z;
        localVertices.push_back(x);
        localVertices.push_back(y);
        localVertices.push_back(z);
    }

    else if (line[0] == 'f')
    {
        cout<<ss.str()<<endl; // for debug
        ss.ignore(6); // To skip 'f 0 1 ' and get purely a 2. Was originally
                    // set to ss.ignore(2) when reading in all 3 values.
        cout<<ss.str()<<endl; // for debug
        ss >> ind3;
        cout << ind3 << endl; 
    }
}
objFile.close();
cout << "Reader success.\n";
return true;
}

Does anyone have any idea why the three inds are being read in as flat 0’s? It’s not that I’ve initialised them to 0 either – before they all read a large negative number depending on the type used so that doesn’t indicate much.

  • 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-17T10:21:46+00:00Added an answer on June 17, 2026 at 10:21 am

    The string stream probably has error flags set (EOF), which would prevent formatted input. Calling str() on the stream will not reset the flags.

    After calling str(), call clear() to clear the flags.

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

Sidebar

Related Questions

I have been unable to fix a problem with Java Unicode and encoding. The
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I've tracked down a weird MySQL problem to the two different ways I was
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.

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.