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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:16:37+00:00 2026-05-13T17:16:37+00:00

I want to be able to store an atomic model in an OpenGL program

  • 0

I want to be able to store an atomic model in an OpenGL program I’m writing. Nothing fancy; just constant mesh vertex values stored as GLfloat[3], plus simple textures. I also want the model to be able to move and rotate freely and as a single object. Here’s what I have so far:

typedef struct _coordnode {
 GLfloat    *pts;           /* XYZ (vertex) or XY (texture) */
 struct _coordnode *next;
} coordnode;

typedef struct _facenode {
 GLfloat    *norm;          /* XYZ */
 coordnode  *vertices;      /* head of linked list */
 GLfloat    *color;         /* RGBA */
 coordnode  *textures;      /* head of linked list */
 struct _facenode *next;
} facenode;

typedef struct _model {
 GLenum     mode;
 facenode   *faces;         /* head of linked list */
 GLfloat    *rot;           /* delta-XYZ from Theta-origin */
 GLfloat    *rot_delta;     /* delta-delta-XYZ */
 GLfloat    *trans;         /* delta-XYZ from origin */
 GLfloat    *trans_delta;   /* delta-delta-XYZ from origin */
} model;

This sets itself up in such a way that the model has a linked lists of facenode, each of which has two linked lists of its vertexes and its texture coordinates, respectively.

Since this is my first C program, my question to seasoned programmers is whether this particular method presents any inconsistencies or inefficiencies, or whether it stores enough data.

More information, not necessarily relevant:

  • There will only be a few objects in memory, and a two of them will be involved in collision detection.
  • One model will have a partial transparency.
  • One model will have raised rendered text applied to the model’s faces, and move according to a gravity vector.
  • Two models will rotate as one, based on external input.
  • 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-13T17:16:37+00:00Added an answer on May 13, 2026 at 5:16 pm

    Assuming that you are on a 32 bit architecture, and GLgloat is typedef’d to a 32 bit float this structure

    typedef struct _coordnode {
     GLfloat   *pts;            /* XYZ (vertex) or XY (texture) */
     struct _coordnode *next;
    } coordnode;
    

    is going to consume 8 bytes of memory. Then, if I understand this correctly, pts will point to a separate allocation that will have either 2 or 3 GlFloats, which is 8 or 12 bytes of memory. that’s 16 or 20 bytes in two allocations. while this

    typedef struct _coordnode {
     GLfloat   pts[3];           /* XYZ (vertex) or XY (texture) */
     struct _coordnode *next;
    } coordnode;
    

    Is always 16 bytes, plus one less point of failure since it’s a single allocation rather than two.

    So, even if your allocator has zero overhead (and it doesn’t). Putting 3 GLfloats in the coordnode (even if you only use 2 of them) is less memory than having the GLfloat array be a separate allocaton. Plus, if you make this a single allocation then you get better cache coherency, which translates into better performance most of the time.

    The same analysis can be performed on your other structures.

    The other thing I would say is that if you always put the next pointer first in each of your structures, then a single set of linked list functions can handle all of your lists, so IMO this is better

    typedef struct _coordnode {
     struct _coordnode *next;
     GLfloat   pts[3];           /* XYZ (vertex) or XY (texture) */
    } coordnode;
    

    If you someday change to doubles for GLFloat or move to a 64 bit architecture, then your pointers will no longer be the same size as your GLFloats. In that case, it would be better use of memory to group the floats and pointers together.

    typedef struct _facenode {
     struct _facenode *next;
     coordnode  *vertices;      /* head of linked list */
     coordnode  *textures;      /* head of linked list */
     GLfloat   *norm;           // XYZ (it might be better to make this an array)
     GLfloat   *color;          // RGBA (it might be better to make this an array)
    } facenode;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just want to be able to store and access data from ACCESS,SQLSERVER,SQLCE,SQLLITE based
I have a program in which I want to be able to store certain
I am just learning about databases and I want to be able to store
I have a list that I want to be able to store 20 values.
I want to be able to store information about a song that has been
I want to be able to store various Canvas items in seperate XAML files
I'll be very simple: I want to be able to store Java objects from
hey i want to be able to create multiple shapes and store them perhaps
i want to be able to store and retrieve data online using a username
I want to be able to store multiple List<NameValuePairs> for when multiple users enter

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.