What is the best way to manage objects data in OpenGL?

I’m developing 3D modeling tool with OpenGL and way I’m drawing objects to the screen seems not easy to integrate with other solutions (such as Shadow maps, etc).
Like when I look for an Shadow map examples, most of them are using native OpenGL functions which use different data structure than mine.
So far I’ve done

  • Drawing (Line/Line Curve/Triangle/Quad/Cube/Sphere/Dome/Cylinder/Donut/Arc/Circle/Cone/Nurb)
  • Transformation (Move/Sizing/Rotate)
  • 4 view ports

So I’m wondering way I’m doing is wrong and to adjust as others does or just to have integrate with those solution by converting data to make fit there?

struct Point3D {
    unsigned int					id;
    Coordinate3D					position;
    Coordinate3D					normal;
    RGBA						color;
}

struct Line3D {
    unsigned int					id;
    Coordinate3D					position;
    Coordinate3D					normal;
    RGBA						color;

    unsigned int					index[2];
}

struct Surface3D {
    unsigned int					id;
    Coordinate3D					position;
    Coordinate3D					normal;
    RGBA						color;

    unsigned int					index[4];
}

struct Object3D {
    unsigned int					id;
    Coordinate3D					position;

    Point3D						*vPoints;
    Line3D						*vLines;
    Surface3D					*vSurfaces;

    unsigned int					vPointCount, vLineCount, vSurfaceCount;
    unsigned dint					vPointIndex, vLineIndex, vSurfaceIndex;
}

struct Objects3D {
    Object3D						*data;
    unsigned int					size;
    unsigned int					index;
}

For a modelling program, it doesn’t really matter. How you structure the data only really matters for performance. If you want real-time animation, then you need to structure the data in a form that’s convenient for the GPU.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.