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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:04:32+00:00 2026-06-04T09:04:32+00:00

Im working with a parser that handles Wavefront OBJ 3D object files and im

  • 0

Im working with a parser that handles Wavefront OBJ 3D object files and im not quite sure if im doing the loading correctly into OpenGL.

So basically what i do is that i read my Wavefront OBJ files and parse all data.

Normally in OpenGL ES 1.1 i do following when loading data:

glBegin(GL_TRIANGLES);
glNormal3f(normals[faces[i].normal[0]].v[0], normals[faces[i].normal[0]].v[1], normals[faces[i].normal[0]].v[2]);
glVertex3f(vertices[faces[i].vertex[0]].v[0], vertices[faces[i].vertex[0]].v[1], vertices[faces[i].vertex[0]].v[2]);
glNormal3f(normals[faces[i].normal[1]].v[0], normals[faces[i].normal[1]].v[1], normals[faces[i].normal[1]].v[2]);
glVertex3f(vertices[faces[i].vertex[1]].v[0], vertices[faces[i].vertex[1]].v[1], vertices[faces[i].vertex[1]].v[2]);
glNormal3f(normals[faces[i].normal[2]].v[0], normals[faces[i].normal[2]].v[1], normals[faces[i].normal[2]].v[2]);
glVertex3f(vertices[faces[i].vertex[2]].v[0], vertices[faces[i].vertex[2]].v[1], vertices[faces[i].vertex[2]].v[2]);
glEnd();

As for OpenGL ES 2.0 i have tried following for the vertices without any luck:

glBufferData(GL_ARRAY_BUFFER, obj.vertices.size()*sizeof(float), &(obj.vertices[0].v), GL_STATIC_DRAW);

My datastructure:

struct vertex {
    std::vector<float> v;
}

The v vector is created for each vertex offcourse, with {x,y,z}.

class waveObj {
    public:
        std::vector<vertex> vertices;
        std::vector<vertex> texcoords;
        std::vector<vertex> normals;
        std::vector<vertex> parameters;
        std::vector<face> faces;
}

struct face {
    std::vector<int> vertex;
    std::vector<int> texture;
    std::vector<int> normal;
};

How can i load my data as i done with OpenGL ES 1.1 in 2.0?

Also is it even possible to load a vector (v), rather than the positions seperate (float x,y,z)?

  • 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-04T09:04:33+00:00Added an answer on June 4, 2026 at 9:04 am

    There are several options:

    • Create separate VBO for each of you data: one for position, one for normals, etc
    • Create single VBO with interleaved data – but this would require a bit of code changes in your code.

    For start I suggest using one buffer for one vertex attrib + index buffer:

    one thing with the index buffer:

    • you have separate indices for pos, normal, texture (you take those values directly from OBJ file), but if you ant to draw geometry using IBO (index buffer object) you need to create sinlge index.

    here is some of my code to do that:

    map<FaceIndex, GLushort, FaceIndexComparator>::iterator 
               cacheIndex = cache.find(fi);
    
    if (cacheIndex != cache.end()) {
        node->mIndices.push_back(cacheIndex->second);   
    }
    else {
        node->mPositions.push_back(positions[fi.v]);
        node->mNormals.push_back(normals[fi.n]);
        node->mTexCoords.push_back(texCoords[fi.t]);
        node->mIndices.push_back((unsigned int)node->mPositions.size()-1);
    
        cache[fi] = ((unsigned int)node->mPositions.size()-1);
    }
    

    What it does:

    • it has a vector for each pos, nomal and tex cood… but when there is a “f” flag in OBJ file I check if there is a triple in my cache.
    • if there is such triple I put that index in my node’s indices
    • if not I need to create new index
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with a primitive C Parser that does not handle the Preprocessor
I'm working on a java project that will allows users to parse multiple files
I'm working with facebook connect and trying to handle the JSON object that i'm
I recently ran into this problem: Rails 3 link_to (:method => :delete) not working
Im working on a parser here that opens a file, reads it and prints
I am working with NSScanner to parse data that is both comma and line
i am working on a section of a project, that parses Logs from Postgres
The App that I'm working on requires to parse a very big Json file
I'm working on a parser in php which is designed to extract MySQL records
I'm working on a rss parser in android (upgrading a parser I found on

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.